Where is the JavaScript SDK URL to include?
I'd like to get storefront details, open pages, add products to the cart... using the JavaScript SDK.
I'm reading https://api-docs.ecwid.com/reference/get-storefront-details but I still can't find a <script> to include and get the Ecwid object to work on.
....
<body>
<div id="my-store-XXXXXX"></div>
<div>
<script
data-cfasync="false"
type="text/javascript"
src="https://app.ecwid.com/script.js?XXXXXXXXX&data_platform=code&data_date=2021-04-12"
charset="utf-8"
></script>
<script type="text/javascript">
xProductBrowser("categoriesPerRow=3","views=grid(20,3) list(60) table(60)","categoryView=grid","searchView=list","id=my-store-XXXXXXX"
);
</script>
</div>
<script>
Ecwid.OnPageLoaded.add(function(page){
console.log("Current page is of type: " + page.type);
});
</script>
</body>
@manuelfdo thank you so much! Where do you have found that information?
I'm only interested in addProduct, openPage and a few other methods (not xProductBrowser)... should I import the whole script?
You can import the script and use onapiloaded https://api-docs.ecwid.com/reference/subscribe-to-events#ecwidonapiloaded
<script type="text/javascript" data-cfasync="false" src="https://app.ecwid.com/script.js?XXXXXX" charset="utf-8"></script>
Hey, I have been developing an API to manage Ecwid and I am not quite getting how I can add products to cart? By using this script tag can we add products to cart through front-end?
Yes, using this https://api-docs.ecwid.com/reference/ecwidcartaddproduct