Shopify Flow is an ecommerce automation platform that enables you to automate tasks and processes within your store and across your apps.
For a store we have set specific delivery times per product. For that we use a Custom Product Metafield "DELIVERY-TIME" (which is different per product, like; 'Delivery time is 1 week').
We would like to be able to pass that metafield value from the ordered product(s) to the order, when an order comes in using Shopify flow. It is important for us to manage client's expectations on the delivery time for each product as this changes sometimes.
We already created a Custom Order Metafield (also called "DELIVERY-TIME") which could be used to store the Custom Product Metafield value (DELIVERY-TIME).
All those custom metafields are formatted for "Single line text".
I couldn't find any template to achieve this. Can some tell us what code we'd need to somehow inform the merchant with the stored delivery times for each product? 🙏🙏
Ps. Not sure if this is even possible with Shopify flow as each product could have different Delivery Times which should be some stored per product in an order where a customer orders multiple products with different delivery times. So, maybe we need to store the SKU with each ordered product's Delivery Time??
If there is a better way of achieving this we'd love to hear about it on how to do this.
Solved! Go to the solution
This is an accepted solution.
We managed to figure this out finally 😉 It turned out they where using a Pagebuilder, so we manually changed some templates to add the metafields data to the cart, checkout, and ultimately the orders.
We also had to add this code to cart-item.liquid:
{% 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 %}
We updated the product template to parse the custom metafield data to the cart using this code:
{% if product.metafields.custom['XYZ'] %}
<input type="hidden" id="XYZ" name="properties[XYZ]" value="{{ product.metafields.custom.XYZ }}">
{% endif %}
This article from Avada was also very helpful:
https://avada.io/shopify/devdocs/display-line-item-properties-in-the-cart.html
This was our solution. It works fine now.
Cheers!
I'm not sure what would be the best way to implement this, as is depends on many factors including how you plan to use the Delivery Time values downstream. But you should be able to get and set the metafields values whatever way you want.
As you note, one issue is that an order could have multiple delivery times based on multiple products. I think you need to figure out how you want that to work. You could list all of the times using a "List of single line text". You could use a List of dates instead. Or maybe you could pick the product with the earliest delivery time.
This is an accepted solution.
We managed to figure this out finally 😉 It turned out they where using a Pagebuilder, so we manually changed some templates to add the metafields data to the cart, checkout, and ultimately the orders.
We also had to add this code to cart-item.liquid:
{% 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 %}
We updated the product template to parse the custom metafield data to the cart using this code:
{% if product.metafields.custom['XYZ'] %}
<input type="hidden" id="XYZ" name="properties[XYZ]" value="{{ product.metafields.custom.XYZ }}">
{% endif %}
This article from Avada was also very helpful:
https://avada.io/shopify/devdocs/display-line-item-properties-in-the-cart.html
This was our solution. It works fine now.
Cheers!
We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024Starting 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, 2024