Wix Bookings Trying to get the order informations from a thank you page

Question:
In my website when a course is ordered and the user gets to the thank you page, i want to get the orders infomations like the order number and put that into a variable and then put the variable into a CMS.

I’m using Velo with wix studio editor and i’m working with wix bookings

I wan’t to get the order number when a course is ordered and the user is on the thank-you-page. I’m using wix bookings widget and we can see the order number when a course is ordered but i think we can’t access the order informations using code when we are into the thank-you page.

I did not found anything about a solution to get the order number.

i can give more informations about my issue. Help me pleeaaase

Regards
Yoann

https://dev.wix.com/docs/velo/api-reference/wix-pricing-plans-backend/events/on-order-created

Thanks for your answer, but i already tried this and i have put this in my event.js file but nothing happens when i order something.
I have this file

How does the backend work ?

And also i want to do this into my front file, is it possible ? In my thank-you-page.js

Why wixPricingPlans_onOrderCreated? I don’t think this has anything related to the wixpricingplans, where’d you copy the code from?
Use wixEvents_onOrderConfirmed


Yes, it is possible to do in the frontend, but I can’t think of any reason why you’d want to do that…

I have my code here

When i book a course and i get to the thank-you-page, i can’t see my console.log. It seems that nothing happened.

I also wanted to do that into my thank-you page to get the order number, put that into a variable and then submit that variable into a CMS because into my thank-you page, there is a form, see that capture in my following answer
I don’t see my order number :frowning:


In that capture i can’t see my input.js’ console.log

In that case, instead of

or wixPricingPlans_onOrderCreated,

I’d recommend you use wixBookings_onBookingConfirmed.

1 Like

Of course you won’t see the logs in your browser, it doesn’t occur on your browser, it’s in the backend, it runs on the server, so the logs are also on the server, you can see them in Site Monitoring on your dashboard

Now, let’s say you do have this code execute from the frontend for some obscure reason
That means the clients browsing your site need permission to add items to that collection
Giving such access would allow any site visitor to simply add records to that CMS collection as they please, regardless of actually making purchases

Ok, i’ve found a solution to get my booking information in the event.js file and i get my console log in my backend monitoring.

Now i want to put my variables like titleBalade into the thank-you-page. How can i import my variables from the backend to the frontend ?
I red about getting through a .jsw file to get my informations

You did mention that you need to put specific order related info into the CMS, which is why we suggested doing it through the backend as it is the best practice, given that your frontend code is exposed and can be tampered with.

However you DID NOT mention that you need to put this info in a ‘FORM’, which you have placed on the Thank You page and you want the user to manually submit it with some additional details. I only realised this when I saw the screenshots you had provided in your now deleted posts above. You should have mentioned that you need to put this info in a form, not directly into the CMS, and we would have never suggested you to use the backend, as the backend code cannot directly communicate with the fronted

That being said, it is pretty easy to fetch all the order related info from the Thank You page itself. Simply use the getOrder() function in your Thank You page and it will fetch all the info you need related to the specific order. Now you don’t need any backend code in events.js that was suggested earlier so you may get rid of that. This should solve your query.

1 Like

Pratham, Thank you for your answer and your understanding. It is exactly what i want but i have an error when i use my getOrder() into my thank-you-page because my code see my #thankyoupage as a IFrame like in this capture.


In my next post i’ll show my element #thankYouPage1.

Here is my element

Which element should i take to use my getOrder() ?

I found the solution, this error is not an error, i ignored that and it works. thank you all for your help ! :slight_smile:

1 Like