Answer the question
In order to leave comments, you need to log in
How to display the cart on the product page and update it in real time?
Hello.
How to display the cart on the product page and update it as products are added?
Answer the question
In order to leave comments, you need to log in
you need to hang your cart on woocommerce_add_to_cart_fragments
like this
add_filter( 'woocommerce_add_to_cart_fragments', 'header_add_to_cart_fragment', 30, 1 );
function header_add_to_cart_fragment( $fragments ) {
global $woocommerce;
ob_start();
?>
<a class="cart-customlocation" href="<?php echo esc_url(wc_get_cart_url()); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
<?php
$fragments['a.cart-customlocation'] = ob_get_clean();
return $fragments;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question