Shipping Class Conditional Tag for WooCommerce

This PHP code enables you to set a conditional check based on one or more shipping class i.d’s.

The code loops through the cart contents looking for your shipping class id ( $shipping_class_id ) and sets the value for the $in_cart variable to true if it finds it enabling you to execute code based on your set shipping class or an array of classes.

If not found, your code will not run.

How to Find Shipping Class ID

In your WordPress dashboard, go to WooCommerce > Settings > Shipping > Shipping Classes > Shipping Class and inspect the name of your shipping class like this :

How To Find Shipping Class I.D