我正在调用一个应该创建woocommerce迷你购物车自定义标记的功能:
<?php
function tmc_wc_print_mini_cart() {
?>
<div class="widget_shopping_cart">
<div class="hide_cart_widget_if_empty">
<div class="widget_shopping_cart_content">
<?php if ( sizeof( WC()->cart->get_cart() ) > 0 ) : ?>
<ul class="cart_list product_list_widget ">
<?php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) :
$_product = $cart_item['data'];
// Only display if allowed
if ( ! apply_filters('woocommerce_widget_cart_item_visible', true, $cart_item, $cart_item_key ) || ! $_product->exists() || $cart_item['quantity'] == 0 ) continue;
// Get price
$product_price = get_option( 'woocommerce_tax_display_cart' ) == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
$product_price = apply_filters( 'woocommerce_cart_item_price_html', woocommerce_price( $product_price ), $cart_item, $cart_item_key );
?>
<li class="mini_cart_item">
<a class="item-link" href="<?php echo get_permalink( $cart_item['product_id'] ); ?>">
<div class="item-image">
<?php echo $_product->get_image(); ?>
</div>
<div class="item-details">
<span class="name"><?php echo apply_filters('woocommerce_widget_cart_product_title', $_product->get_title(), $_product ); ?></span>
<?php echo apply_filters( 'woocommerce_widget_cart_item_quantity', '<span class="quantity">' . __('Quantity', 'sage') . ':' . $cart_item['quantity'] . '<span>x</span></span>', $cart_item, $cart_item_key ); ?>
<?php echo apply_filters( 'woocommerce_widget_cart_item_price', '<span class="price">' . __('Unit Price', 'sage') . ':' . $product_price . '</span>', $cart_item, $cart_item_key ); ?>
</div>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php else : ?>
<div class="widget_shopping_cart" style="display: none;">
<div class="hide_cart_widget_if_empty">
<div class="widget_shopping_cart_content">
<ul class="cart_list product_list_widget ">
<div class="empty-minicart"><?php _e( 'There are currently no products in your bag.', 'sage' ); ?></div>
</ul>
</div>
</div>
</div>
<?php endif; ?>
<?php if (sizeof( WC()->cart->get_cart()) > 0) : ?>
<p class="total">
<strong><?php _e( 'Total', 'sage' ); ?>:</strong> <?php echo WC()->cart->get_cart_subtotal(); ?>
</p>
<p class="buttons">
<a href="<?php echo WC()->cart->get_cart_url(); ?>" class="cart btn btn-default">
<i class="fa fa-shopping-cart"></i> <?php _e( 'View Bag', 'sage' ); ?>
</a>
</p>
<?php endif; ?>
</div>
</div>
</div>
<?php
}
当窗口加载div中的新内容时,widget_shopping_cart_content&#34;被删除并添加默认的迷你购物车标记?该函数存储在一个必须使用的插件而不是functions.php中,但我想知道是否有我在这里缺少的东西?
任何帮助都会很棒