Jigoshop – body class dependent on cart state

In one of recent projects, we needed to add an extra styling if the shopping cart contained any products. Below is the snippet, that add extra class on body: “cart-has-items” if there is nothing in the cart and “cart-has-no-items” if there are products in the cart. We use standard filter:”body_class“. The snipped can be added to your theme’s functions.php file

//extra class when cart has items

function cartCheck($classes = '') {
$classes[] = 'cart-has-items';
else {
$classes[] = 'cart-has-no-items';
return $classes;

Leave a Reply

Your email address will not be published. Required fields are marked *