Skip to content

Instantly share code, notes, and snippets.

@siaeb
Created November 21, 2021 17:44
Show Gist options
  • Save siaeb/dd17c5c9bf7edf2a7d8a76d45d9d1565 to your computer and use it in GitHub Desktop.
Save siaeb/dd17c5c9bf7edf2a7d8a76d45d9d1565 to your computer and use it in GitHub Desktop.
WooCommerce : Append number of cart items into ajax response when add or delete product
add_filter( 'woocommerce_add_to_cart_fragments', 'siaeb_change_cart_fragments' );
function siaeb_change_cart_fragments($args) {
$args['items'] = [
'count' => WC()->cart->get_cart_contents_count(),
];
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment