Pages with parameters

To open a page with parameters, you must specify them in the object in second argument of Ecwid.openPage function.

Open product details page of product with ID: 12345

Ecwid.openPage('product', {'id': 12345});

Product

For product details pages, the first argument of Ecwid.openPage function will be 'product'.

Additional parameters include: 'id', 'name', 'variation' and 'options':

  • 'id' is a required parameter, which helps Ecwid identify which exact product page to open in storefront. If it is not specified, the function call will be ignored.
  • 'name' is an optional parameter, used to set custom product name for the page URL. If it is not specified, Ecwid will use the original product name set by store owner.
  • 'variation' is an optional parameter, used to select a specific product variation when opening product details page. If it is not specified, Ecwid will use the default set of product options for that product page.
  • 'options' is an optional parameter, used to select specific product option selections. It supports dropdown and radio button product options. If it is not specified, Ecwid will use the default set of product options for that product page.
Ecwid.openPage('product', {'id': 72585497, 'name': "Apple"});
Ecwid.openPage('product', {'id': 72585497, 'name': "Rip Curl Channel Island", 'variation': 16351010});
Ecwid.openPage('product', {'id': 72585497, 'name': "Rip Curl Channel Island", 'options': [2,2]});

📘

If you need more information about a product or category, use REST API. Public access token can be used in the client-side code, and private token on the server-side.

Category

For category pages, the first argument of Ecwid.openPage function will be 'category'.

Additional parameters include: 'id', 'name' and 'page'

  • 'id' is a required parameter, which helps Ecwid identify which exact category page to open in storefront. If it is not set, Ecwid will use store home page, i.e. id will be 0
  • 'name' is an optional parameter, used to set custom product name for the page URL. If it is not specified, Ecwid will use the original category name set by store owner.
  • 'page' is an optional parameter, used to open a specific page with products. If the page value is bigger than there are pages in category, Ecwid will open the last available page. If integer value is not passed, 'page' parameter is ignored.

Open category page and set product name in URL as 'Fruit':

Ecwid.openPage('category', {'id': 20671017, 'name': "Fruit", 'page': 3});

📘

If you need more information about a product or category, use REST API. Public access token can be used in the client-side code, and private token on the server-side.

Search

For the search page, the first argument of Ecwid.openPage function will be 'search'.

Ecwid.openPage('search', {'keyword': 'surfboard', 'page': 2});
Ecwid.openPage('search', {'priceTo': '50'});
Ecwid.openPage(
    'search', 
    {
      'keyword': 'shoes', 
      'attribute_Brand': 'Nike',
      'inventory': 'instock',
      'offset': 50
    }
  );

Additional parameters include:

  • 'keyword': works as a search stringfor product title, description, and some other fields
  • 'inventory=instock': returns only products "In stock"
  • 'onsale=onsale': returns only products with "Compare to" prices
  • 'priceFrom': minimum product price for search. The decimal separator is dot. No currency symbol.
  • 'priceTo': maximum product price for search. The decimal separator is dot. No currency symbol.
  • 'offset': offset from the beginning of the returned items list
  • 'categories': category IDs, to which products belong. Accepts several values separated by a comma
  • 'includeProductsFromSubcategories=true': show products from subcategories, if the "categories" parameter is indicated
  • 'attribute_[name]=[value]': search by product attributes. "Name" is the attribute name (spaces will work). "Value" is the attribute value. Accepts several values separated by a comma. To search for an exact match to attribute value, enclose it in quotation marks
  • 'option_[name]=[value]': search by product options. "Name" is the option name (spaces will work). "Value" is the option value. Accepts several values separated by a comma. To search for an exact match to attribute value, enclose it in quotation marks
  • 'createdFrom': minimum product creation date in the same format as in REST API, e.g. createdFrom=2020-01-30 10:00:00 +0000
  • 'createdTo': maximum product creation date in the same format as in REST API, e.g. createdFrom=2020-01-30 10:00:00 +0000

Sign in

For the sign in page, the first argument of Ecwid.openPage function will be 'account'.

Additional parameters include: 'returnurl':

  • 'returnurl' is an optional parameter, which can redirect user to a specific URL after the successful login.

Open sign in page and redirect user to a custom page on success:
Ecwid.openPage('account', {'returnurl': 'https://www.ecwid.com/demo/Surfboards-c20671017'});

Account Subscriptions

For the account subscriptions page, the first argument of Ecwid.openPage function will be 'account/subscription'.

Ecwid.openPage('account/subscription', {'id': 1006502});

Additional parameters include: 'id':

  • 'id' is mandatory parameter, which can redirect user to a specific subscription page.