Jump to content

Edit Smarty variables on HOOK_BEFORECARRIER


sujithsam

Recommended Posts

I have a module to check whether a carrier can deliver in a postcode(I have custom tables and functions for this).But I am stuck in select "Shipping" step.

I want to disable a carrier on "Shipping" step,based on availability on postcode..

in mymodule.php
//mymodule.php

public function hookDisplayBeforeCarrier($params) {
$delivery_option_list = $params['delivery_option_list'];
$carriers = $params['carriers'];
//updated $delivery_option_list and $carriers here.Removed unavailable carriers in that delivery address.
// overwrite the list of shipping options
$this->context->smarty->assign('carriers', $carrires);
$this->context->smarty->assign('delivery_option_list', $delivery_option_list);
}

But its not reflecting in the front end..Still its showing all the carriers..

I checked order-carrier.tpl.

order-carrier.tpl line no 51

 

<div class="delivery_options_address">
                {if isset($delivery_option_list)}

{$delivery_option_list|@print_r}
                    {foreach $delivery_option_list as $id_address => $option_list}
                        <p class="carrier_title">
                            {if isset($address_collection[$id_address])}
                                {l s='Choose a shipping option for this address:'} {$address_collection[$id_address]->alias}
                            {else}
                                {l s='Choose a shipping option'}
                            {/if}
                        </p>
 

Please help me to remove a carrier on hookDisplayBeforeCarrier hook..

Edited by sujithsam (see edit history)
Link to comment
Share on other sites

  • 1 month later...

I'm trying to do the same.

 

I checked the controler ParentOrderController, after calling _assignCarrier(), Prestashop assign the variable delivery_option_list again in calling another function _assignWrappingAndTOS(), replacing the variable you altered in the hook.

 

Unfortunately we don't have any hooks in _assignWrappingAndTOS(), or Prestashop fix this or add another hook for _assignWrappingAndTOS()

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...