Changing shipping cost in Woocommerce


I am creating a plugin that connects to an 3rd API to request the shipping cost based on the address of the person and the dimensions of the product.

Everything is fine but now I need the values ​​returned by the API to be added to the prices of the shipping methods and I tried with this code but it still doesn’t work.

function test_overwrite_($rates,$package) {

foreach ($rates as $rate) {

//Set the price
$rate->cost = $phpVar1;   <-//variable that receives the value of the shipment

return $rates;

But I don’t find any way to change the shipping cost with functions..

Is it possible ? Thanks

Yoseph_Reyes 4 months 0 Answers 14 views 0

Leave an answer