ecwid-api-docs icon indicating copy to clipboard operation
ecwid-api-docs copied to clipboard

Where is the JavaScript SDK URL to include?

Open gremo opened this issue 4 years ago • 5 comments

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.

gremo avatar Apr 13 '21 14:04 gremo

....
<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 avatar Apr 13 '21 14:04 manuelfdo

@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?

gremo avatar Apr 13 '21 15:04 gremo

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>

manuelfdo avatar Apr 13 '21 15:04 manuelfdo

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?

ypratham avatar Oct 14 '22 18:10 ypratham

Yes, using this https://api-docs.ecwid.com/reference/ecwidcartaddproduct

manuelfdo avatar Oct 14 '22 18:10 manuelfdo