Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active January 3, 2016 02:09
Show Gist options
  • Save srikat/8393474 to your computer and use it in GitHub Desktop.
Save srikat/8393474 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