Personalized checkout and custom promotions with Shopify Scripts
I am using Book That App (BTA) on my store for customers to select the dates that they'd like for the services we offer. The dates are stored in line properties and I can see them when I export the order using Matrixify so I sure they are there.
When I try to have the dates appear on the confirmation email, they do not appear.
Here is the code I've tried without success.
{% assign propertySize = item.properties | size %}
{% if propertySize > 0 %}
{% for p in item.properties %}
{% assign first_character_in_key = p.first | truncate: 1, '' %}
{% unless p.last == blank or first_character_in_key == '_' %}
<br>
{{ p.first }}:
{% comment %}
Check if there was an uploaded file associated
{% endcomment %}
{% if p.last contains '/uploads/' %}
<a href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
{% else %}
{{ p.last }}
{% endif %}
{% endunless %}
{% endfor %}
{% endif %}
I have also tried the following code, also without success
{% unless line_item.properties == empty %}
<ul>
{% for property in line_item.properties %}
<li>{{ property.first }}: {{ property.last }}</li>
{% endfor %}
</ul>
{% endunless %}
any ideas what's going on?
It's a pity the line item properties are not included by default in the order confirmation email template. We get so many people who have problems setting it up, as I'm sure every other App that uses them will attest to, and Shopify support just throws it over to us even though they are a standard feature of the Shopify platform. (We have requested this several times through various channels, over several years, but no joy).
Anyhoo...
I'd recommend checking the name of the line_item variable. We commonly see line, line_item and item being used. In your example code you used 2 different variables (line_item and item).
To find out what is being used, look for the code in the confirmation template that reads something like this: {% for line in subtotal_line_items %}. In this case it is using line, so the following code will display the line item properties:
{% for p in line.properties %}
<br>{{ p.first }}: {{ p.last }}
{% endfor %}
HTH, Gavin.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024