The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

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):


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

But this doesn't output the SKU/CODE.

Any help would be appreciated!
  • fc_adamfc_adam FoxyCart Team

    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.