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 (the getOrderShippingCost function), $params is in fact the Cart object
  • $shipping_cost: This parameter corresponds to the shipping cost calculated by PrestaShop, which is the addition of the shipping handling fee (if the shipping_handling parameter of the carrier has been ...

Get PrestaShop Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.