This PHP code changes the cart price per unit based on the chosen shipping method using multiple shipping methods with a single shipping zone. When a shipping method is chosen, the price per unit changes and the cart totals are updated dynamically.
The shipping methods in this example are setup like this :
You can use the code with any amount of shipping methods linked to any amount of custom prices.
Note : You can use this code with multiple shipping methods, multiple prices and any shipping plugin.
Code Installation
There’s 2 simple steps :
- Copy and paste the PHP code to the end of your child themes functions.php file or custom functionality plugin.
-
Swap out the shipping method ids on lines 17, 18 and 20 and the price on line 31.
Find Shipping Method ID’s
You can inspect each shipping method to find the id for each.
Reviews
There are no reviews yet.