Skip to content

Instantly share code, notes, and snippets.

@About2git
Forked from srikat/gist:8393474
Created February 15, 2015 22:24
Show Gist options
  • Select an option

  • Save About2git/7e3e10a27988c75807dd to your computer and use it in GitHub Desktop.

Select an option

Save About2git/7e3e10a27988c75807dd to your computer and use it in GitHub Desktop.
WooCommerce: Shortcode for outputting number of products in cart. Usage: [wc_num_items]. Reference: http://docs.woothemes.com/document/show-cart-contents-total/
add_shortcode('wc_num_items', 'function_wc_num_items');
function function_wc_num_items($atts) {
global $woocommerce;
$cart_contents_count = $woocommerce->cart->cart_contents_count;
return $cart_contents_count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment