Add class to body if Woocommerce cart has items

WordPress

A very simple small snippet of code that will add a class to your site <body> tag, if the Woocommerce shopping cart has one or more items.

Add this to your functions.php file, within your theme or child-theme.

Replace ‘mytheme’ with the something to identify your own theme.
‘itemsInCart’ is the class that is added to your site, change this if you wish.

View the Gist: https://gist.github.com/macgraphic/69976d6c79ca4e616af235b8c12bcb49

Photo by: Jomjakkapat Parrueng on Unsplash