Solved

Pass custom delivery times per product to an order (to inform merchant)

ecompiraten
Shopify Partner
6 2 1

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.

Kind regards,
Steven
Accepted Solution (1)
ecompiraten
Shopify Partner
6 2 1

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!


Kind regards,
Steven

View solution in original post

Replies 2 (2)

paul_n
Shopify Staff
957 128 226

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. 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
ecompiraten
Shopify Partner
6 2 1

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!


Kind regards,
Steven