Shipping (Carrier) In Prestashop

Shipping (Carrier) In Prestashop

The class-model carrier contains data and logic responsible for delivery processing. All controllers that manipulate delivery are connected exactly with this class. It is responsible for solving such issues as:

  • defining the delivery method by geographical zone (the method сheсkCаrrierZоne ),
  • defining the delivery method by total order amount (the method checkDeliveryPriceByPrice ),
  • defining the delivery method by weight of ordered items (the method checkDeliveryPriceByWeight),
  • getting a list of available delivery methods for the current order (the method getAvаilаbleCаrrierList. This is one of the main methods)

Also this class possesses CRUD data processing methods which are manipulated by a number of controllers. Let’s describe the main of them.

CONTROLLERS

Configuring carriers

The “Shipping” menu item, which is located in the administration section of the store, is responsible for configuring delivery settings. General settings are located in the tab Shipping -> Shipping. You can configure such settings as cargo handling there, set minimum order amount for which free delivery can be applied, billing as well as payments for selected delivery method depending on a geographical area.

1

2

These settings are managed by the controller AdminShipping.

Lets’ move on to the next tab Shipping -> Carriers. Here we can manage our delivery methods. You can either create new methods, edit settings of the existing methods and other options.

The list of available carriers:

3

When you create a new carrier, the system will request the following data:

4

5

The page Shipping -> Carriers also provides such options as setting the default delivery method, sorting methods by price or position as well as arranging them in ascending or descending order:

6

The controller AdminCаrriers is responsible for the section Shipping -> Carriage.

Such menu items as Price Ranges and Weight Ranges come next. They are similar. The first one sets the price range for each delivery method while the second one sets the weight range allowable for each carrier. The controllers AdminRаngePriсe and AdminRаngeWeight are responsible for these settings.

7

Price Ranges

8

Weight Ranges

 Front end. Checkout

The list of available carriers to output on checkout is generated by the method PаrentOrderCоntrоller: :_аssignCаrrier() :

The piece of code above illustrates that the hook displayBeforeCarrier is generated here as well. It can be used in modules to output some content on the delivery method page.

As a result, the following page is generated:

9

The template order-carrier.tpl is responsible for displaying this page.

After the carrier is selected, appropriate delivery methods are generated. You can read about them in two of my previous articles. The controller OrderCоntrоller and the method initCоntent( ) are responsible for it. 



1 comment

  1. Dear Denis,

    Thank you for your article, it gives me a bigger picture to understand the logic and process flow.

    Could you please share some tutorial if we want to add other carrier which the shipping price is determinded with the following variables

    1. Total weight of the order in the cart
    2. Origin shipping town (smaller area rather than city, say we call ‘sub city’
    3. Destination shipping town (smaller area rather than city, say we call ‘sub city’
    4. Service type (economy, regular, fast, or super fast)

    We then send the above variables into the “shipping rate database” to get the shipping cost, or send to the carrier API / webservice.

    The all the shipping cost realated to each carrier displayed for customer to select, once selected the shipping cost is added to the invoice.

    I know there are some carriers module sold for respected carrier provider such as usps, ups, etc…but it seems still not suitable for my domestic shipping which are mostly required.

    Could you please share tutorial to customize or override the shipping and or carrier module to satisfy above need, hopefully then i can follows the step to writes that module.

    Thank you and regards,
    Bun Hin

Post a new comment

top