Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Where is the JavaScript SDK URL to include? #21

Open
gremo opened this issue Apr 13, 2021 · 5 comments
Open

Where is the JavaScript SDK URL to include? #21

gremo opened this issue Apr 13, 2021 · 5 comments

Comments

@gremo
Copy link

gremo commented Apr 13, 2021

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.

@manuelfdo
Copy link

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

@gremo
Copy link
Author

gremo commented Apr 13, 2021

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

@manuelfdo
Copy link

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>

@ypratham
Copy link

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?

@manuelfdo
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants