Skip to content

Ecwid Ecommerce SDK is a lightweight JavaScript library which does not require Ecwid widget for interacting with Ecwid API to manage online store data.

License

Notifications You must be signed in to change notification settings

Ecwid/ecwid-js-sdk

Repository files navigation

Ecwid

build npm (scoped) npm bundle size (scoped) codecov License

Ecwid Ecommerce SDK

Ecwid Ecommerce SDK allows you to add Ecwid buying experience to any platform or application: Site Builder, POS, Website, App, etc. It is a lightweight JavaScript library which does not require Ecwid widget for interacting with Ecwid API to manage online store data. It is taking on Storefront JavaScript API functions and allows you to optimize your integrations with Ecwid for performance and flexibility.

For full API documentation, visit API docs page.

Installation

NPM

Make sure you have npm installed.

npm install @ecwid/sdk

Usage

SDK initialization

import Ecommerce from "@ecwid/sdk";

const ecommerce = new Ecommerce({
	storeId: 1002,
	storeLocationPath: '/store' // optional
});

Cart operations

Get cart data in current store

const cart = ecommerce.cart.get()
	.then((result) => console.log(result))
	.catch((error) => console.error(error))

Cart model in result object:

{
    "cartId": "XXXXXXX-XXXXXX-XXXXXX-XXXX",
    "productsQuantity": 1,
    "items": [
        {
            "product": {
                "price": 99.99,
                "name": "Example",
                "id": 1000001,
                "sku": "00001"
            },
            "quantity": 1
        }
    ]
}

Navigate to checkout page with current cart data

ecommerce.cart.goToCheckout();

Development

Run tests

npm run test

Roadmap

In future releases SDK will be able to manage:

  • products and categories data;
  • cart data (extended);
  • customers data;
  • storefront pages;
  • storefront appearance.

License

This project is Apache2.0 licensed.

About

Ecwid Ecommerce SDK is a lightweight JavaScript library which does not require Ecwid widget for interacting with Ecwid API to manage online store data.

Resources

License

Stars

Watchers

Forks

Packages

No packages published