Rodrigo B Laurindo Posted January 26, 2013 Share Posted January 26, 2013 Hi I am writing a customised shipping module for PrestaShop 1.4 The module is already working, but i wanted it to dinamically change the shipping delay, from whithin the shipping module. Can this be done? How? I was looking at getDeliveryOptionList and HOOK_BEFORECARRIER, but I don't know how to do it. Any help would be welcome. Thanks Link to comment Share on other sites More sharing options...
Radu Posted March 11, 2013 Share Posted March 11, 2013 I did it for presta 1.5 and it should work with multi shipping also. I did not tested it extensively though in install function of your module: $this->registerHook('displayBeforeCarrier') then implement the hook making sure to replace YOUR_MODULE_ID with your module carrier id! (not your actual module id but carrier id that you use) public function hookDisplayBeforeCarrier($params) { global $appended_text; $delivery_option_list = $params['delivery_option_list']; foreach($delivery_option_list as $id_address => $carrier_list_raw) { $appended_text = 'tetsting appended text'; foreach($carrier_list_raw as $key => $carrier_list) { foreach($carrier_list['carrier_list'] as $id_carrier => $carrier) { if($id_carrier != YOUR_MODULE_ID) { 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); } } } // overwrite the list of shipping options $this->context->smarty->assign('delivery_option_list', $delivery_option_list); } Link to comment Share on other sites More sharing options...
Ehinarr Posted August 28, 2013 Share Posted August 28, 2013 Hi, it returns: Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in this line: $delay = array_map(function ($item) {global $appended_text; return $item.$appended_text;}, $delay); I'm also trying to change delay message, once it changes every time. But I think that I must act directly on order_carrier.tpl file in order to make it work the way as I need. Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2013 Share Posted August 28, 2013 what php version you've got on your server? Link to comment Share on other sites More sharing options...
Ehinarr Posted August 29, 2013 Share Posted August 29, 2013 what php version you've got on your server? 5.2.17 Link to comment Share on other sites More sharing options...
ryan_WO Posted March 25, 2015 Share Posted March 25, 2015 I am also trying to change the shipping delay text to reflect the API response from the shipping company which is stored the MySQL database in prestashop. although i can't figure out in which class/method to override the default delay text. any help would be apreciated. I'm using the canada post shipping module from a 3rd party and prestashop 1.6.0.14 Link to comment Share on other sites More sharing options...
ryan_WO Posted March 26, 2015 Share Posted March 26, 2015 (edited) any help would be appreciated... Edited March 26, 2015 by ryan_WO (see edit history) Link to comment Share on other sites More sharing options...
aflores Posted June 2, 2017 Share Posted June 2, 2017 this worked for me on prestashop 1.6 public function hookDisplayBeforeCarrier($params) { global $appended_text; $delivery_option_list = $params['delivery_option_list']; foreach($delivery_option_list as $id_address => $carrier_list_raw) { $appended_text = "Custom text"; foreach($carrier_list_raw as $key => $carrier_list) { foreach($carrier_list['carrier_list'] as $id_carrier => $carrier) { if($id_carrier != YOUR_CARRIER_ID) { continue; } $delay = $delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier]['instance']->delay; $delay = array_map(function ($item) {global $appended_text; return $appended_text;}, $delay); $delivery_option_list[$id_address][$key]['carrier_list'][$id_carrier]['instance']->delay=$delay; } } } // overwrite the list of shipping options $this->context->smarty->tpl_vars["delivery_option_list"]->value=$delivery_option_list; } Link to comment Share on other sites More sharing options...
Recommended Posts