Skip to content

Instantly share code, notes, and snippets.

@MarkoSh
Last active February 11, 2018 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarkoSh/68ef01fa4caff5c3574f483f3a995d85 to your computer and use it in GitHub Desktop.
Save MarkoSh/68ef01fa4caff5c3574f483f3a995d85 to your computer and use it in GitHub Desktop.
Woocommerce count items in cookie
add_action( 'wp', 'woocommerce_set_custom_cookie', 100 );
add_action( 'woocommerce_add_to_cart_handler', 'woocommerce_set_custom_cookie' );
function woocommerce_set_custom_cookie() {
setcookie( 'woocommerce_cart_contents_count', WC()->cart->cart_contents_count, 0, '/' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment