Skip to content

Instantly share code, notes, and snippets.

@huytrq
Created June 21, 2018 10:44
Show Gist options
  • Select an option

  • Save huytrq/24bc65b8c528f92fbffb876d2ee5b36a to your computer and use it in GitHub Desktop.

Select an option

Save huytrq/24bc65b8c528f92fbffb876d2ee5b36a to your computer and use it in GitHub Desktop.
Update Custom Cart Count (or any HTML) after AJAX Add to Cart in WooCommerce
<?php add_filter( 'woocommerce_add_to_cart_fragments', 'iconic_cart_count_fragments', 10, 1 );
function iconic_cart_count_fragments( $fragments ) {
$fragments['div.header-cart-count'] = '<div class="header-cart-count">' . WC()->cart->get_cart_contents_count() . '</div>';
return $fragments;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment