This PHP code removes all shipping options except free shipping based on 2 conditions :
- A minimum spend limit which is set in Marketing > Coupons > Coupon Data > Minimum Spend.
- When a coupon is applied on the cart or checkout page.
In this example, we create a coupon :
- with a $10 coupon amount( you can add a coupon without an amount and use any discount type )
- without checking the “Allow free shipping”. ( you can enter a coupon expiry date )
- without any “Usage restriction” ( you can add any restrictions )
- without any Usage “limits” ( you can add any limits you like ).
Demo Coupon Settings
Shows the exact settings used in the demo. The only compulsory settings are the coupon name. The minimum spend is optional.
Copy & paste the PHP code to the end of your child themes functions.php file or custom functionality plugin.
Set your coupon name on line 11.
Create a coupon with the same name as used on line 11.
These solutions may also help :