I have a number of shipping classes with prices set in multiple shipping zones. Is it possible to detect if ANY product within the cart belongs to a specific shipping class, and if so set the shipping cost to 0 and display a message?
I would like to use this mechanism for products which require special handling and would be shipped via freight. So if a customer's order contains any of these products the shipping quote would be provided manually post-sale.
Thanks for the help.
The following code will set all shipping cost to zero, when a specific defined shipping method is found in cart items and will display a custom notice.
The second hooked function is optional and will display the custom notice in checkout page.
You will have to temporarily "Enable debug mode" in Shipping settings under Shipping options (tab).
In the code bellow define in each function your shipping class slug and your custom notice:
Code goes in function.php file of your active child theme (or active theme). It should works.
Set up a Shipping Class and Shipping Method for Free Shipping, assign that Class to the product you want to offer free shipping for, and then ensure that Free Shipping Method is set at the default shipping method.
Good Luck!