Good afternoon, everyone! How’s it going?
I’m working on an abandoned cart integration between VTEX and RD Station and I’ve run into a problem.
I can’t find a variable within the data entity that gives me the total number of items in the customer’s cart (which is essential for making the POST request to the RD Station API).
Has anyone dealt with something similar and can help me out?
Thanks a lot in advance!
@HiranOliveira hey, how’s it going?
I believe you won’t be able to do it directly through MasterData. You’ll need to create a new field just to save that info.
Have you tried using the OrderForm to capture that information? When the customer adds products to the cart, there’s a running total of items they add to the CART.
I think from there you can capture the data and send it to MasterData, and then work with this variable based on that information: VTEX ORDERFORM GITHUB
Hope this helps!
Cheers,
Estevão.
PO ENEXT
@estevao_santos I just created the new field here in MasterData and found where in the OrderForm to capture the cart’s total item count.
I just don’t know exactly where to make this assignment — I believe it’s in the checkout. I tried doing it through the console on the checkout page of my test profile on the site (since the checkout in the admin panel is currently under maintenance), but I got a 403 error with the response: “Cannot write in private fields”.
I have one more question:
The integration token only lasts 24h. Would there be any way to do a refresh_token through MasterData and temporarily store this new token between trigger requests? I don’t want to keep it saved so as not to compromise security.
Thanks so much for the tips!
Hey @HiranOliveira, just confirming — you get this data right in the Checkout itself.
So, logically, you would do a GET on the Orderform to capture the data you need, and then do a POST to MasterData, saving that information in the new field you created.
Important: before you use the method, check whether the new field is set to public inside the Data Entity, because if it isn’t, it will throw the error you’re seeing.
For more information, see this article and this other one here
More details on creating fields in Master Data see this document
Regarding the token refresh issue, you would need to create a middleware for that, since you would encapsulate only the token within the application to keep it off the front end. If you have backend knowledge, you can build that kind of app yourself. Otherwise, I’d suggest reaching out to someone on your team who’s familiar with that side of things, so the application follows best practices, ok?
Hope this information helps.
Best,
Estevão.
PO ENEXT
Good afternoon, @estevao_santos
Thank you for the information, I’ll keep trying here and will keep this ticket updated.
Cheers!