I have enabled WooCommerce Subscriptions plugin in My WooCommerce shop.
Following Set the shipping method in WooCommerce Subscriptions renewal orders answer code to my previous question, I would like to remove the Chronopost shipping method when a user has a product with a subscription on his cart.
Currently there are three different shipping methods and I want to keep the Colissimo domicile and Point Relais only.
Here are the shipping rate keys for each shipping method:
- Colissimo domicile (gratuit):
lpc_nosign:6
- Chronopost domicile 24h:
chrono13
- Point relais (gratuit)";
chronorelais
2
Answers
I finally found how to resolve this by using the following code :
To hide a specific shipping method when there is a subscription product in cart, use:
Code goes in functions.php file of your child theme (or in a plugin). Tested and work.
Important: You will have to empty your cart to refresh shipping method cache.
Sort shipping methods displayed in WooCommerce Cart and Checkout