Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

getting the code/sku of a product into a {{ placeholder }}

saint_malosaint_malo Member
in Help edited October 2016
I'm trying to add the SKU/CODE of a product in to a hidden field on the cart / checkout template.

My cart only ever has 1 item in it at one time.

I've tried to work out the syntax from the cheatsheet (View Data / Cart):
https://wiki.foxycart.com/v/2.0/cheat_sheet#product_parameters

Using...

{{ items[0].code }}
{{ items[].code }}
{{ item.code }}

But this doesn't output the SKU/CODE.

Any help would be appreciated!
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @saint_malo,

    Could you confirm how you're passing in the code? If you're definitely passing it as code=abc123, then getting the first products code like {{ items[0].code }} should work just fine. The other way to access it is to loop through the products like:
    {% for item in items %}
    {{ item.code }}
    {% endfor %}
  • thanks @fc_adam - will give this a try!
Sign In or Register to comment.