O'Reilly logo

PrestaShop Module Development by Fabien Serny

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required