Arslan Ali
Arslan Ali

Reputation: 17802

The correct email address when a webhook gets hit for order creation from Shopify

When an order is created at Shopify, a callback is initiated from Shopify that hits the webhook given in the settings.

The parameters that it uses to hit the webhook, those contain multiple emails, and there are no docs for those.

You can see those parameters here: https://codebeautify.org/jsonviewer/cb3e0c52

One email is in the root. 2nd is by the name contact_email, and the third one falls under customer and goes by the name: email.

As of now, there is no documentation that states which email stands for what.

My question is: how would I know which email has the customer used for purchasing the product, and it would be the very email that I will use for contacting back with a customer.

Shopify webhooks: https://help.shopify.com/en/api/reference/events/webhook

Upvotes: 0

Views: 57

Answers (1)

David Lazar
David Lazar

Reputation: 11427

You can do the following. One. Check to make sure a customer record was attached to the order. Surprisingly, it has been known to happen that you get an order without a customer due to a glitch. Assuming you have a customer record, use the email field from that. If the customer record does not exist, the one at the root is likely your best bet.

That is it. Any other emails floating around can be safely ignored by you. And also, be double dog sure you do not email this customer unless you are allowed to. Otherwise, you are spamming, and that will get you hammer-banned by the merchant, who will take the brunt of the abuse from your spam.

That means checking the buyer_accepts_marketing attribute.

Upvotes: 1

Related Questions