Skip to content

Instantly share code, notes, and snippets.

@lmartins
Last active August 29, 2015 14:10
Show Gist options
  • Save lmartins/6e8dcf20138ee91b6377 to your computer and use it in GitHub Desktop.
Save lmartins/6e8dcf20138ee91b6377 to your computer and use it in GitHub Desktop.
Display WooCommerce Cart contents (only items quantity and total amount)
/**
* CART CONTENTS
* Mostra informação sobre conteúdo actual do carrinho
*/
add_action( 'genesis_site_title', 'mw_show_cart_contents' );
function mw_show_cart_contents()
{
global $woocommerce;
if ( sizeof( $woocommerce->cart->cart_contents ) !== 0 ) {
$out = '<a class="widget-cart-contents" href="' . $woocommerce->cart->get_cart_url() . '">';
$out .= '<span class="quantity">' . sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count) . "</span>";
$out .= $woocommerce->cart->get_cart_total();
// $out .= $woocommerce->cart->get_cart_subtotal(); // With VAT included
$out .= "</a>";
echo $out;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment