WooCommerce – Hide shipping methods if items of specific Shipping Class is NOT in cart

[vc_cta h2=”The Below Code Works for the Following Plugins:”]

[/vc_cta]

Below snippet will hide shipping methods if none of the items in the cart belongs to the specific Shipping Class.

Use the array variable $shipping_classes to define the shipping classes.
Define the services to_hide.

If you are looking for a plugin do this job, visit ELEX Hide Shipping Methods Plugin. Using this plugin, You can easily hide shipping methods based on various conditions.

If you want to hide all the shipping methods, you can refer this snippet article for reference code.

 

 

2 thoughts on “WooCommerce – Hide shipping methods if items of specific Shipping Class is NOT in cart”

  1. how to add or remove shipping class based on the quantity of product added to cart. like if 3 or > 3 of a product added, then apply a shipping class “free” otherwise apply normal shipping.

Comments are closed.

Scroll to Top