Jump to content

Custom Shipping tab


Recommended Posts

I am building a module to display shipping carriers based on users's  zipcode on checkout.

I don't want to show carriers that do not have delivery in that zipcode.

I am using "hookDisplayBeforeCarrier" hook and modify delivery_option_list variable.But this is not working.. still it shows all carriers.

Here is my code..


public function hookDisplayBeforeCarrier($params) {

$address_id = $params['cart']->id_address_delivery;
 	 	$zip = CheckCode::getZipAddress($address_id);
		$res = CheckCode::my_checkCode($zip);
		$crr= array();
		foreach($res as $r){
		 $crr[] = $r['id_carrier'];

$carriers = $this->context->smarty->getVariable('carriers');

$delivery = $this->context->smarty->getVariable('delivery_option_list');
$delivery_option_list = $delivery->value;

 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) {
		 $car = &$delivery_option_list[$id_address];
	  $this->context->smarty->assign('carriers', $carriers);
	  $this->context->smarty->assign('delivery_option_list', $delivery);


Share this post

Link to post
Share on other sites

This topic is now closed to further replies.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More