This code enables you to hide shipping methods on the cart and checkout pages based on the product categories your cart items are assigned to.
In this case, we have configured 3 shipping methods:
- Standard Flat rate
- Express Flat Rate
- Click & Collect Local Pickup
There are standard products assigned the dress category and products assigned the accessory category.
Shipping Method Display
Shipping options are displayed and hidden based on products in cart :
- When only products in the accessory category are in cart, only the Standard Delivery: $6.00 and Click & Collect ( Local Pickup ) options are displayed
- When products from both the dress and accessory categories are in cart, Standard Delivery: $26, Express Delivery: $36.0 and Click & Collect shipping options display
- When only products from the dress category are in cart, Standard Delivery: $20, Express Delivery: $30.0 and Click & Collect shipping options are displayed.
There’s 2 different solutions in the download folder :
- The 1st solution only shows shipping methods when products from the dress and/or accessory categories are in cart based on the above conditions.
- The 2nd solution shows shipping methods for all categories.
Screenshots
Click to enlarge. Shows the cart page based on the 3 scenarios above.
Usage
- Swap out your product category slugs on lines 21 and 23.
- On lines 31, 32 and 33, swap out your shipping ids. ( How To Find Shipping Method Ids ).
- Copy and paste the PHP code to the end of your child themes functions file or custom code snippets plugin.
Versions
Current version is V2-121595.
Reviews
There are no reviews yet.