Jump to content

Cash on delivery for one carrier


Wytas

Recommended Posts

Hello,

Can anybody tell me what file to edit so that cash on delivery would be seen only after choosing one specific shipping method and would not be available for all others. I saw similar thread about this where Rocky provided an answer but it was about prestashop 1.4. I am using 1.6.1.5 and can' seem to find a file mentioned there.

Link to comment
Share on other sites

You can use the hook mentioned here

http://nemops.com/prestashop-virtual-products-specific-payment/#.V2JltLv5jmg

But instead of looping through all products, it's enough to use $params['id_carrier']
I am not sure id_carrier is the correct one, but in any case you have to get the carrier id there, and return false if it;s not the one you want

Edit: it's $params['cart']->id_carrier

  • Like 1
Link to comment
Share on other sites

Hey,

Something went wrong when I followed your guide and tried to get carrier id reference.

 

in override/modules/cashondelivery I created cashondelivery.php with following code:

 

if (!defined('_CAN_LOAD_FILES_'))
    exit;
  
class CashondeliveryOverride extends Cashondelivery
{






public function hookPayment($params)
{
            $id_carrier = $params['cart']->id_carrier;
        $carrier = new Carrier($id_carrier);
        d($carrier);
if (!$this->active)
return ;


global $smarty;


// Check if cart has product download
if ($this->hasProductDownload($params['cart']))
return false;




$smarty->assign(array(
'this_path' => $this->_path, //keep for retro compat
'this_path_cod' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment.tpl');
}
}

And on top of the page I get exact same code. Like in the picture I attached. post-1253765-0-40398500-1466376683_thumb.png 

What I did wrong?

Edited by Wytas (see edit history)
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...