Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

add metafields into order before orders/create hook

Solved

add metafields into order before orders/create hook

Samy023
Shopify Partner
6 0 0

Im facing the following situation: I need to add some metafields to an order before the order is created and the order confirmation notification is sent, i plan to use those metafields inside the order confirmed email, i tried adding the metafields on the orders/create webhook handler, but by the time that handler is called the email notification is already sent and the metafields i added to the order do not appear on the email sent to the client, is there no webhook that allowed me to add metafields to the order before the order confirmation email gets sent ?

Accepted Solution (1)

Huptech-Web
Shopify Partner
1169 234 265

This is an accepted solution.

Hello, @Samy023 

 

You can add values to the cart attributes and utilize them in the order confirmation email. You can use the order.attributes object in Liquid in the Order Confirmation Email Template. 

{% for attribute in order.attributes %}
  <p>{{ attribute.name }}: {{ attribute.value }}</p>
{% endfor %}


If the solution presented meets your needs and addresses your query effectively, I encourage you to accept it as the chosen answer. This will acknowledge the support you received and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required

View solution in original post

Replies 2 (2)

Huptech-Web
Shopify Partner
1169 234 265

This is an accepted solution.

Hello, @Samy023 

 

You can add values to the cart attributes and utilize them in the order confirmation email. You can use the order.attributes object in Liquid in the Order Confirmation Email Template. 

{% for attribute in order.attributes %}
  <p>{{ attribute.name }}: {{ attribute.value }}</p>
{% endfor %}


If the solution presented meets your needs and addresses your query effectively, I encourage you to accept it as the chosen answer. This will acknowledge the support you received and aid fellow community members in identifying reliable and effective solutions for their similar concerns.
Thank you.

If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
Samy023
Shopify Partner
6 0 0

@Huptech-Web modifying the cart is too early  for me to insert the information i need, to be more precise with my request => i need to modify the order after the  checkout but before the order is created and the order confirmation email is sent,  is there not "before order create" hook or similar place where i can make such modification?

The data i need to add to the order needs to be added just before the order is created and the email confirmation is sent because i need to invalidate the info right after i attached it to the order so that it can't be used twice, adding that information to places like the cart or checkout etc, leave it open for the same information to be attached to different carts of multiple people and thats a behavior im trying to avoid.