Recently I had to work with a WordPress plugin called WooCommerce UPS Shipping – Live Rates and Access Points. This plugin allows us to get UPS shipping price via UPS API. We can also enable Access Points support to show store customers the option to choose an Access Point location. The plugin suggests the nearest points for the customer’s address and saves the selected point to the customer’s order.
On the normal scenario, this plugin works very well. But my client wants to offer Access Points without any costs. Or in other words, my client want to offer free shipping with this shipping method.
How to achieve this goal?
First, we need to find out the method id. You can do this by add any item from your store to the cart and then do checkout. On the shipping calculator section, right click and inspect element. On every WooCommerce store, there will be an <ul> element with id shipping_method and inside it you will see all of available shipping methods on your store.
Find the method that you want to override and get the value. In my case with the UPS plugin, the method value is flexible_shipping_ups:4:70_access_point. Based on that value, we can see that the method id is flexible_shipping_ups.
Now let’s write the code!
On WooCommerce, we can override a shipping cost with
This is the code that I use to override the UPS shipping cost to zero (free shipping) :
You need to put this code on your functions.php file inside your active theme directory. If your code is not working, please try to clear WooCommerce transient. In order to clear your WooCommerce transient, you can go to WooCommerce -> Status. Then click on Tools tab and you will see WooCommerce Transients. Click on the Clear Transients button.
You can use this method to override any shipping method to any shipping cost. You just need to find the right method id and then put it to the code.
If you have any question, feel free to leave the comment below. Thank you!
Will this code automatically be used on the checkout calculations?
yep. as long as you have added the code to your functions.php file - it will automatically be used on the checkout process.
Wow, this was exactly what I was looking for! You just saved me a ton of time I would have spent coding some custom solution. Thank You!