0
votes

I'm currently trying to find away to pass some custom data to each one of my shopify order confirmations. Specifically I need to pass a custom URL that will be displayed in the order confirmation email. According to the shopify documentation I can receive a property from a product and pass it to my confirmation form like so.

{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
  {% for p in item.properties %}
    {% assign first_character_in_key = p.first | truncate: 1, '' %}
    {% unless p.last == blank or first_character_in_key == '_' %}
      {{ p.first }}:
      {% if p.last contains '/uploads/' %}
        <a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
      {% else %}
        {{ p.last }}
      {% endif %}
      <br>
    {% endunless %}
  {% endfor %}
{% endif %}

Using this I figure I can pass a custom url by doing something like this:

mycustomurl.com/linepropertyitem

My problem is that each line property includes the tittle of the line property item and the input value. So my url using this method would be

mycustomurl.com/linepropertyitem = linepropertyitemtext Any ideas or pointers how this can be done? which wouldn't work in a URL.

1
Is the custom data needed for each separate line_item or you need custom data for the whole order? If you need custom data for the whole order it's better to use cart attributes instead help.shopify.com/en/themes/customization/cart/…drip
Yes I need custom data for each separate line_item. @dripFabricioG
Is that sample code pasted from some where else? It already seems to contain your answer. Do you understand the code you pasted?bknights
A little for example the code above returns Custom: TEXTINPUT however I would need just the value in this case TEXTINPUT. That's where I'm stuck. @bknightsFabricioG

1 Answers

0
votes

You could do it like this:

{% assign property_size = item.properties | size %}
{% if property_size > 0 %}
  {% for p in item.properties %}
    {% assign first_character_in_key = p.first | truncate: 1, '' %}
    {% unless p.last == blank or first_character_in_key == '_' %}

      {% if p.last contains '/uploads/' %}
        <a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
      {% else %}
        {{ p.first }}:
        {{ p.last }}
      {% endif %}
      <br>
    {% endunless %}
  {% endfor %}
{% endif %}

But the best thing you could do would be to analyze the code from Shopify and understand what is going on. That way you'll be able to do a lot more on your own.