phiberoptik Posted October 2, 2016 Share Posted October 2, 2016 Hi folks, For some products I have free shipping, so I made 2 carriers, one with free shipping and one weight based. For every product, I chose the carrier in the product edit page, so the ones with free shipping will have only free shipping carrier selected. How do I get the id of the selected carrier in product.tpl to compare it with the id of free shipping carrier so I can display a message or image in the product page? ..or any other suggestion to make this possible. Thank you! Link to comment Share on other sites More sharing options...
Apium Posted October 2, 2016 Share Posted October 2, 2016 I believe {$cart->id_carrier} should work anywhere in the front end, assuming the variable is set! Link to comment Share on other sites More sharing options...
El Patron Posted October 2, 2016 Share Posted October 2, 2016 you can modify .tpl and add {debug}, this will show you all varialbles avail to .tpl file. Link to comment Share on other sites More sharing options...
ENS Enterprises Posted September 13, 2017 Share Posted September 13, 2017 If you want get the carrier details in cart page 1. Open the controllers/front/Cartcontroller.php file 2. And add this coded $carrier_list = $carrier->getCarriers(1); inside the initContent() function 3. Then assign the variable in smarty. See e.g.- public function initContent() { if (Configuration::isCatalogMode() && Tools::getValue('action') === 'show') { Tools::redirect('index.php'); } $presenter = new CartPresenter(); $presented_cart = $presenter->present($this->context->cart, $shouldSeparateGifts = true); $carrier_list = $carrier->getCarriers(1); // Your variable $this->context->smarty->assign([ 'cart' => $presented_cart, 'static_token' => Tools::getToken(false), 'libros'=> $carrier, 'test'=> $carrier_list, // assign your variable ]); } 4. Then go to cart tpl page And get the all value of carrier. As. {foreach from=$test item=carrier key=carrier_id name=count} <p>{$carrier.name}</p> {/foreach} output:- My carrier Link to comment Share on other sites More sharing options...
jnbteste Posted April 27, 2018 Share Posted April 27, 2018 Everytime you edit a carrier, prestashop duplicates it to create a new one. Older versions are hidden in the database (to keep information for older orders). So everytime you edit a carrier, it gets a new id. The id of the first technical carrier which corresponds to this new one is stored in the database. So if you want to make some tests on carrier id, you should use the reference id instead of the carrier id. Unfortunately, $cart->id_carrier does not contain this reference id. I was not able to find a simple way to get it on product.tpl. Link to comment Share on other sites More sharing options...
El Patron Posted April 27, 2018 Share Posted April 27, 2018 FYI: we solved shipping assurance display for non-logged/logged visitors which displays anywhere on the shop. This for the shipping nerds in this post. PrestaHeroes Shipping Commander (think visitor shipping assurance), see front office demo in product tab. https://www.prestaheroes.com/en-us/modules/geo-localization/prestashop-shipping-commander Link to comment Share on other sites More sharing options...
Kami Solutions Posted May 12, 2020 Share Posted May 12, 2020 No changes in php files needed... simply use this in any prestashop .tpl smarty file: {$carrier_id = context::getContext()->cart->id_carrier.id_reference} Link to comment Share on other sites More sharing options...
Sasni Posted February 9, 2021 Share Posted February 9, 2021 {foreach from=$delivery_options item=carrier key=carrier_id} {$carrier.id_reference} {/foreach} Link to comment Share on other sites More sharing options...
baden32 Posted June 21, 2021 Share Posted June 21, 2021 On 5/12/2020 at 2:33 AM, ChineseNorris said: No changes in php files needed... simply use this in any prestashop .tpl smarty file: {$carrier_id = context::getContext()->cart->id_carrier.id_reference} I tried to implement your code in my cart.tpl but it does not seem to work :-( I would like to hide some info on the "cart" page according to the available carrrier for the products added in my cart. In ex. I would like to hide the delay of delivery info if there are only one or more articles with "pick up on site" delivery Unfortunately with this code $carrier_id always contains value 0 (the available carrier(s) defined for my articles has no impact on this info). Hope you can help me. Regards joel Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now