Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 732 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prestashop 1.6 / How to get carrier id, to use it in order-carrier.tpl

#1
I'm using Prestashop 1.6

In **order-carrier.tpl**, I'm trying to get the **carrier id**, because I would like to use it in the css class of the `<div>`.

For exemple : `div.delivery_option.carrier_id_33`

I tried this :

{$cart->id_carrier}

But it doesn't really work.
Reply

#2
If it's in TPL file, you need to use **getcontext()** first

So in this case it would be

{context::getContext()->cart->id_carrier}
Reply

#3
Try this code

<div class="delivery_option {if ($option@index % 2)}alternate_{/if}item {foreach $option.carrier_list as $carrier}carrier_id_{$carrier.instance->id}{/foreach}">

The carriers are not directly accessible, but they are encapsuled inside the variable `$option`
Reply

#4
Late answer here, but I write mainly for future reference.

First, there should always be a global $carrier smarty variable available to templates. Just check placing a `{debug}` tag on the place you want to use it and see if it's there.

Second, DO NOT use `id_carrier`. It's quite strange but you will loose it. It's not a really reliable property. I discussed the issue with the developers some time ago. You should use id_reference instead: that won't change.

[To see links please register here]


So, to sum up:

{assign var=carrier_instance value=$carrier.instance}

{* then later somewhere: *}

{$carrier_instance->id_reference}

this will do the job.
Reply

#5
Since I always get here whenever I search for id_reference from smarty I'll post my solution for 1.7

{$carrier_id = context::getContext()->cart->id_carrier.id_reference}

Returns the carrier_id_reference, the nice one cause carrier_id changes everytime you modify a carrier, so the real ID you need in order to operate with carriers is id_reference
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through