Book Image

PrestaShop Module Development

By : Fabien Serny
Book Image

PrestaShop Module Development

By: Fabien Serny

Overview of this book

Table of Contents (19 chapters)
PrestaShop Module Development
About the Author
About the Reviewers

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 set to true, which is the case) and the price range / weight range cost (if the need_range parameter has been set to true, which is the case too)


    At this state, except if you set the shipping handling fee in the administration panel,...