Skip to content

Customizing Shipping Rates based on Cart Subtotal in WooCommerce

In this post, we’ll be discussing how to customize shipping rates based on the subtotal of a customer’s cart in WooCommerce using a simple code snippet. This can be useful for offering different shipping options or discounts for orders above or below a certain amount.

The code snippet uses the woocommerce_package_rates filter to modify the shipping rates that are displayed to customers based on the subtotal of their cart.

The code snippet first calculates the subtotal of the cart using WC()->cart->subtotal, and then it checks the customer’s shipping country. If the subtotal is greater than $29 and the customer’s shipping country is not empty, the DHL shipping rate is removed. On the other hand, if the subtotal is less than $29, the UPS shipping rate is removed. This allows you to offer different shipping options or discounts for orders above or below a certain amount.

It’s worth noting that you can adjust the subtotal amount and shipping methods/options according to your preferences and also you can use this snippet to remove or add any shipping rate based on the cart subtotal.

By adding this code snippet to your functions.php file, you can easily customize shipping rates based on the subtotal of a customer’s cart in WooCommerce. This can be useful for offering different shipping options or discounts for orders above or below a certain amount. Remember to test it before going live and make sure you have the proper backup of your website.

Leave a Reply

Your email address will not be published. Required fields are marked *