0
votes

I'm having difficulty with the shipping classes in WooCommerce. It's a webshop containing products for mailbox and packages.

However, if the cart contains 3 or more "mailbox" products, then the shipping class should change to "package".

I've tried changing the code from this question: Change shipping class based on cart items shipping class count in Woocommerce , but I couldn't figure it out.

Can someone help me with this?

1
What did you change? What is the problem?Aaron
I tried to change this line $cart_item['data']->set_shipping_class_id('0'); to a different ID, which didn't work. I tried to add a shipping class $package_shipping_class = 'package'; and place it as $cart_item['data']->get_shipping_class() ==$package_shipping_class ); on the last line (so instead of $cart_item['data']->set_shipping_class_id('0'); Then when I go to my cart and I add 3 products it just says the label "Shipping costs" with actually adding shipping costs.Shanice
I found a different solution. Thank you :)Shanice

1 Answers

-1
votes

The problem could be that you change the slug naming in the code.
Just implemented this and works fine!

// HERE define your shipping class SLUG
$mailbox_shipping_class = 'your-mailbox-shipping-class-slug';