Fetch custom product options on custom Cart, receipt and email templates

AkashAkash Member
in Help edited January 2014
Hi all

I am using custom templates for Cart, receipt and email templates. While adding products into foxycart, we also store custom properties into the options property of individual properties as specified in[url=" https://wiki.foxycart.com/v/0.7.2/cheat_sheet"] https://wiki.foxycart.com/v/0.7.2/cheat_sheet[/url]

I need to fetch those individual custom properties stored in products in twig template to manipulate the output that is to be generated.

Any help is appreciated :-)
  • winstonwinston FoxyCart Team

    Twig templates are only available starting in FoxyCart version 1.0. I see that you linked to a 0.7.2 documentation page. Are you working on a 0.7.2 store or later? If you're at least on 1.0, you can access custom properties in the twig like so:
    {% for item in items %}
      {% if item.options|length > 0 %}
        {% for option in item.options %}
         {# any logic goes in here #}
          {{ option.name }}
          {{ option.value }}
        {% endfor %}
      {% endif %}
    {% endfor %}
  • @winston
    Hey, first of all thanks a lot for sharing the code. Yes it worked in almost a similar way as your sample code.
    And regarding the version, I am using the latest one, I just mentioned the one that I found first.
    I got confused, as in case of JSON, the data is directly stored inside options object, but in twig, its deep inside.

    Thanks :-)
  • winstonwinston FoxyCart Team

    Awesome! Glad to help. Just so you know, there are example twig tutorials here: https://wiki.foxycart.com/v/1.1/templates#getting_even_more_advanced_with_twig that should help you find different twig variables!
  • @winston Thanks for the help, that contains a lot of useful code snippets.
Sign In or Register to comment.