PrestaShop - How to retrieve Carrier ID in Smarty

2019-08-08 03:13发布

I am using PrestaShop 1.5.3.1 and I want to retrieve the Carrier ID during the Payment step in the checkout process.

In PrestaShop 1.4 I was using {$id_carrier} and it was working just fine, but it is not working in PrestaShop 1.5.x

I want to show one payment method depending on selected carrier.

For example:

{if $id_carrier == 1}
    my content
{/if} 

2条回答
在下西门庆
2楼-- · 2019-08-08 03:43

$carrier = new Carrier($cart->id_carrier); // in payment module page

查看更多
smile是对你的礼貌
3楼-- · 2019-08-08 03:51

On the payment page, you can retrieve the selected Carrier ID using the following Smarty variable:

{$cart->id_carrier}

This will work anywhere in the Front-end, both on PrestaShop v1.4.x and v1.5.x.

{if isset($cart->id_carrier) && $cart->id_carrier == 1}
   {* Do some stuff here *}
{/if}
查看更多
登录 后发表回答