When a user with a specific user role logs in and their cart total is greater than a set limit, free shipping is displayed and they only need to enter their shipping address to complete checkout. All other user roles including logged out users need to calculate the shipping cost before checkout.
The code adds a custom user role named business customer and enables you to set the cart total limit which in this case is 50.
No other shipping options are displayed regardless of user role, logged in/out status or cart limit. Customers can only enter their shipping address with the calculation made only when the total is below the set limit for any user role.
- Copy & paste the PHP code to the end of your child themes functions.php file or custom functionality plugin.
Set your user role name and slug on line 11.
Set your user role slug on line 21.
Set your cart total on line 27.
Display Free Shipping & Local Pickup
Use the PHP code in functions 2.php instead of functions.php and follow the same installation steps.
This PHP code applies the free shipping and local pickup automatically if order is above X amount and the custom user role is set.
- Set the user role name and slug on line 11.
- Set the user role slug on line 21.
- Set the amount for the cart total on line 27.
These solutions may also help :