Ways to Save OrderID at the moment it's created when completing checkout

My main question is about how I can know the order ID before the order is finalized, or at least whether there is a way to capture the order ID before the checkout redirects to the order confirmation page (orderConfirmation/OrderPlaced).

Hey LĂşcio (@PrimeSLX), good morning.

Could you give us some more context about the challenge or issue you’re facing?

Keep in mind that the OrderId is only generated after VTEX confirms that it has validated and recorded all the data related to your order. There’s no way to capture the OrderId before the order is completed.

All processing involving the OrderId of confirmed orders is handled on the OrderPlaced page, or by setting up an Order Hook or querying the Order Feed to retrieve the data from a newly created order.

But tell us a bit more about your scenario so the community can help find a solution.

Cheers :slight_smile:

Hey Andre, I have a similar question…

I want to send some data I collect at checkout to a data entity in the master data, as soon as the user confirms the purchase order those data are sent.

However, I want to associate this data with an orderId — how can I get that orderId and send it?Hey André, I have a similar question…

I want to send some data I collect at checkout to a data entity in the master data, as soon as the user confirms the purchase order those data are sent.

However, I want to associate this data with an orderId — how can I get that orderId and send it?

Hey Mariana (@marmarquez), how are you doing?

Wouldn’t it make more sense to add a customData to the order?

Take a look at this documentation:

By adding the customData to the OrderFormId, that information will be available whenever you run a GET Order by Id.

Then, using a VTEX Order Hook, you can capture the order confirmed event and check whether the customData is present in order to handle the desired information, including sending it to Master Data.