简体   繁体   中英

WooCommerce: Change shipping class based on quantity in cart

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?

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';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM