Add custom attributes to order before sending the order confirmation email

Add custom attributes to order before sending the order confirmation email

smtdev1
Visitor
1 0 1

I am creating a webhook that is triggered for the 'orders/paid' topic. From there, I add the order to an internal ERP, which returns some fields for the order. I am adding these fields to the 'note_attributes' parameter of the order using the Admin REST API. However, I need to include these fields before the order confirmation email is sent. Is it possible to achieve this?

Reply 1 (1)

beauxbreaux
Shopify Partner
263 21 45

In Shopify, the order confirmation email is typically sent after the order has been processed and confirmed. Unfortunately, Shopify does not provide a built-in way to customize or delay the sending of confirmation emails directly.

 

However, you can work around this.
Here's a suggested approach:

  1. Create a Draft Order:

    • When the webhook for 'orders/paid' is triggered, instead of immediately updating the existing order, create a draft order using the Admin REST API.
    • Add the necessary note attributes to this draft order.
  2. Send Confirmation Email for Draft Order:

    • After adding the note attributes, you can manually trigger the order confirmation email by marking the draft order as completed using the Admin REST API.

This way, you have control over when the confirmation email is sent because you control when the draft order is marked as completed.

Beaux Barker
Developer
Hire me on Fiverr