Run custom script from storefront template

Hello there,

I’m trying to get the orderFormId from each current cart and sending them to our API, but without results. Is possible to fetch this orderFormId from the frontend (Storefront with Site-Editor - Template) and send it via API?

The closest I’ve got is to run two scripts in the base html, one for installing vtexjs and the other to send the information to the API, but I couldn’t handle to execute any custom script from the base html itself, how can I achieve this?

An as another option, that is actually the final purpose of this, is there any other way to do not offer the final stock of a product as the added stock of this product in all of the warehouses? And just to select one warehouse as the max stock upper bound?

An important consideration is that I’m not using any VTEX IO functionality. I’m looking forward for this. Thank you so much for your time.

Regards.

Hey there @matioportus, hope you’re doing fine!

As for your final purpose, I understand you want to make available on your store only the products from a specific Warehouse, and not the total amount of multiple Warehouses. Is that right?

The relation between Warehouses and Trade Policies lies on the Loading Docks.

I don’t know with how many Policies you are working with, but you could create a Loading Dock and link it to a single Warehouse and link only this Loading Dock to the concerned Trade Policy. Would it work for you?

Thanks!