add metafields into order before orders/create hook

Samy023
Shopify Partner
3 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 ?

Replies 2 (2)

Rishihuptech
Shopify Partner
601 108 121

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
3 0 0

@Rishihuptech 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.