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.
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…
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
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
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.
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.