EDIT :
Maybe wa can't change the smarty vars once the tpl is loaded?
and the 'delay' text change occurs juste because its an instance ?
-----------------------------------------------------------------------------------
Hi,
I want to disable a carrier for some users (depending on their address).
I tried to develop a module but i'm failing in removing the carrier
In my module.php I have :
public function hookDisplayBeforeCarrier($params)
{
global $appended_text;
$appended_text = "aa";
$delivery_option_list = $this->context->smarty->getTemplateVars('delivery_option_list');
foreach($delivery_option_list as $id_address => $carrier_list_raw) {
foreach($carrier_list_raw as $key => $carrier_list) {
foreach($carrier_list['carrier_list'] as $id_carrier => $carrier) {
if($id_carrier != "3") {
continue;
}
$delay = &$delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier]['instance']->delay;
$delay = array_map(function ($item) { global $appended_text; return $item.$appended_text;}, $delay);
unset($delivery_option_list[$id_address][$key]);
}
}
}
$this->context->smarty->assign('delivery_option_list', $delivery_option_list, false);
}
If i var_dump 'delivery_option_list' in module.php the entry is removed, but if I debug the tpl, it is still here!
I'm new to this, Am I doing something bad?
Thanks in advance for your answer.