PrestaShop Developer Conference
PrestaShop Developer Conference
Paris, France - November 6, 2024
Let's talk code, commerce and open source.

Hook displayBeforeCarrier

Informations

Before carriers list This hook is displayed before the carrier list in Front Office
Hook displayBeforeCarrier
Locations
FO
Type display
Origin core
Aliases [beforeCarrier]

Located in

Origin File
core classes/checkout/CheckoutDeliveryStep.php

Parameters details

    <?php
    array(
        'carriers' => array(
            array(
                'name' => (string) Name,
                'img' => (string) Image URL,
                'delay' => (string) Delay text,
                'price' =>  (float) Total price with tax,
                'price_tax_exc' => (float) Total price without tax,
                'id_carrier' => (int) intified option delivery identifier,
                'id_module' => (int) Module ID
        )),
        'checked' => (int) intified selected carriers,
        'delivery_option_list' => array(array(
            0 => array( // First address
                '12,' => array( // First delivery option available for this address
                     carrier_list => array(
                         12 => array( // First carrier for this option
                             'instance' => Carrier Object,
                             'logo' => <url to the carrier's logo>,
                             'price_with_tax' => 12.4, // Example
                             'price_without_tax' => 12.4, // Example
                             'package_list' => array(
                                 1, // Example
                                 3, // Example
                              ),
                         ),
                     ),
                     is_best_grade => true, // Does this option have the biggest grade (quick shipping) for this shipping address
                     is_best_price => true, // Does this option have the lower price for this shipping address
                     unique_carrier => true, // Does this option use a unique carrier
                     total_price_with_tax => 12.5,
                     total_price_without_tax => 12.5,
                     position => 5, // Average of the carrier position
                 ),
             ),
         )),
         'delivery_option' => array(
             '<id_address>' => Delivery option,
             ...
         )
    );

Call of the Hook in the origin file

Hook::exec('displayBeforeCarrier', ['cart' => $this->getCheckoutSession()->getCart()])