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

Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.

You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page

Hook actionFilterDeliveryOptionList

Informations

Modify delivery option list result This hook allows you to modify delivery option list
Hook actionFilterDeliveryOptionList
Locations
FO
Type action
Origin core
Aliases

Located in

Origin File
core classes/Cart.php

Parameters details

    <?php
    [
        'delivery_option_list' => (array) &$delivery_option_list,
    ]

Call of the Hook in the origin file

Hook::exec(
    'actionFilterDeliveryOptionList',
    [
        'delivery_option_list' => &$delivery_option_list,
    ]
)

Example implementation

For example :

  • a module can decide to display or not a certain carrier depending on the customer group
  • a module can decide to block a means of delivery for a specific customer or group of customers
  • a module can decide to display or not a carrier according to the date?

In this example, we disable the express delivery carrier on saturdays and sundays because our delivery promise of 24 hours cannot be satisfied:

<?php
class MyCarrierConditionDisablerModule extends Module 
{
        
    public function install()
    {
        return parent::install() && $this->registerHook('actionFilterDeliveryOptionList');
    }

    public function hookActionCustomFilterDeliveryOptionList($params)
    {
        $deliveryOptionList = $params['delivery_option_list'];
        
        if(0 == date('w') || 6 == date('w')){ // sundays or saturdays
            // find carrier in $deliveryOptionList, and remove it
        }
    }
}