php - Update details in cart widget without loading page by using ajax in Woocommerce -


i developing woocommerce widget show cart subtotal, cart total, cart items, , shipping total working fine want update shipping total cart total whenever toggle between shipping methods use of ajax. updates after page reload. there hook available purpose ?

you can add_to_cart_fragments filter.

my implementation updates number of items shown ajax can used update totals, etc well. normal code in template displays cart details:

<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>"> (<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?>)</a> 

this filter added in functions.php:

// update items in cart via ajax add_filter('add_to_cart_fragments', 'woo_add_to_cart_ajax'); function woo_add_to_cart_ajax( $fragments ) {     global $woocommerce;     ob_start();     ?>         <a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>">(<?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count); ?>)</a>     <?php     $fragments['a.cart-contents'] = ob_get_clean();     return $fragments; } 

there resources / documentation on out there - remember using reference when wrote code bit tough google for.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -