PrestaShop - How to retrieve Carrier ID in Smarty during the checkout process

本秂侑毒 提交于 2019-12-24 15:18:52

问题


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} 

回答1:


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}



回答2:


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



来源:https://stackoverflow.com/questions/15946376/prestashop-how-to-retrieve-carrier-id-in-smarty-during-the-checkout-process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!