Using web services on shipping cost calculation
In order to keep the code clear in the module's main class, we will create a controller for shipping cost calculation:
public function getOrderShippingCost($params, $shipping_cost) { $controller = $this->getHookController('getOrderShippingCost'); return $controller->run($params, $shipping_cost); }
As you can see, we've passed the two parameters available in the method to the controller. The two parameters are:
$params
: In this case (thegetOrderShippingCost
function),$params
is in fact theCart
object$shipping_cost
: This parameter corresponds to the shipping cost calculated by PrestaShop, which is the addition of the shipping handling fee (if theshipping_handling
parameter of the carrier has been set totrue
, which is the case) and the price range / weight range cost (if theneed_range
parameter has been set totrue
, which is the case too)Note
At this state, except if you set the shipping handling fee in the administration panel,...