The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.
 
 
Thread Tools Display Modes
  #1  
Old 04-20-2016, 06:20 PM
jefferis1's Avatar
jefferis1 is offline
Junior Member
 
Join Date: May 2013
Posts: 16
Default

Help with JS syntax for API?


Hi folks, I'm using ecwid inside of WordPress and can't get the API examples to display anything and perhaps I'm writing it incorrectly...

What I'm trying to do is get the URL and parse it to get the category id to enable an hide the "add to bag" panel, but i cannot get anything to display and I'm not sure the examples in the docs are complete OR that they work inside WP. .. The first if statement is an attempt to match the category id and then print. the second should be a global one that should reveal the main category ID on any product. Neither displays anything on any page.

Any help greatly appreciated!
Jeff

Code:
<script type="text/javascript">
var StaticBaseUrl = Ecwid.getStaticBaseUrl();

 
if (StaticBaseUrl.match(18530265) {

console.log(StaticBaseUrl);
document.write("WE HAVE THE URL") ;
 
};

Ecwid.OnPageLoaded.add(function(reveal)) {
 alert("My Main Category is: " + mainCategoryId);
};
</script>
The browser says that Ecwid.getStaticBaseUrl is not a function... so I'm missing something from the docs which imply that it is...

Last edited by jefferis1; 04-20-2016 at 06:27 PM.
  #2  
Old 05-09-2016, 02:18 AM
smartMart's Avatar
smartMart smartMart is offline
 
Join Date: Oct 2014
Posts: 278
Default

Quote:
Originally Posted by jefferis1 View Post
HTML Code:
<script type="text/javascript">
var StaticBaseUrl = Ecwid.getStaticBaseUrl();
 ...
</script>
The browser says that Ecwid.getStaticBaseUrl is not a function... so I'm missing something from the docs which imply that it is...
Hi Jeff!
Maybe it's too early to call Ecwid.getStaticBaseUrl()?

Try Ecwid.OnAPILoaded event from this sample: https://developers.ecwid.com/api-documentation#subscribe-to-events

Good luck!
The Following User Says Thank You to smartMart For This Useful Post:
Liza P (05-09-2016)
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Tags
api, categoryid, url

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:24 AM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.