Code Snippet to adjust price for a service based on state!

The code snippet facilitates you to adjust the price for a service based on the state!

Note: This snippet should work with WooCommerce UPS Shipping plugin only. Also, before using this snippet, kindly ensure that you have version “2.7.6” or higher.

Add the following code to your functions.php or anywhere relevant.

In the above snippet, you can add the states for which you want to adjust the price. Here for convenience, we have added “CA” California State.

Also, you can provide the adjustment percentage value for particular service code. For example, for UPS Ground, the service code is “03” and we have kept .12 adjustment. So the rates will 12% of the actual value.

You can find the list of service codes from the plugin settings page as shown below :

Service and Package

Service and Package

As see from the cart page, the rates come up 12% of the actual value.

The original rate was 47.59.

The new rate is 5.7 as seen from the cart page:



Leave a Reply