Question:
[Clearly ask your question.]
I have a backend wixEcom_onCheckoutCompleted() event which generates licenses for the purchase and emails them to the customer. It all works properly, however I recently had a couple instances where it failed because the event didn’t have a contactId (event.data.checkout.buyerInfo.contactId) associated with it, instead only having a vistorId. This doesn’t seem to make a lot of sense to me, given that these customers all have contacts created for them with the purchase.
I don’t know if it is some sort of order of operations problem where sometimes it completes the checkout before creating the contact. Is there any way to guarantee that a contactId will be available? (Forcing a certain type of checkout process maybe). My other thought for a work around is to query for the contactId if only a visitorId is available, but I don’t think this will work if the contactId hasn’t actually been created yet.
I know this is a bit in the weeds, but if anybody has any insight into this problem I would love help figuring it out! It is very annoying to have to check after every purchase to make sure the email went out properly and not super professional to manually send a follow up email. Let me know if I can provide any useful follow up information.
Product:
[Which editor or feature is your question most relevant to? e.g. Wix Editor, Wix Studio Editor, Editor X.]
Wix Editor
What are you trying to achieve:
[Explain the details of what you are trying to achieve. The more details you provide, the easier it is to understand what you need.]
Guarantee a contactId will be passed into the wixEcom_onCheckoutCompleted() or query for the correct contactId from the provided visitorId in that event (without interfering with the automated backend functioning).
What have you already tried:
[Share resources, forum topics, articles, or tutorials you’ve already used to try and answer your question.]
Tried looking for an alternative way to email the customer based on the visitorId, but this doesn’t seem like the right approach. Haven’t tried anything practical yet because I don’t want to have unintended side effects on the normal checkout functions.
Additional information:
[Include any other pertinent details or information that might be helpful for people to know when trying to answer your question.]