jeudi 16 juin 2016

WooCommerce: Cart count by product type

I found this script that allows me to show cart contents total above the shopping cart icon within WooCommerce:

<a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>

If there are 100 items in my cart it shows 100.

What I really want is to display the count by item types. So if there are 50 t-shirts and 50 shorts, I want that 2 item types count to be displayed individually.

Does anyone know how I can achieve this?

Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire