Giter Site home page Giter Site logo

terrorizer1980 / commerce.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chec/commerce.js

0.0 1.0 0.0 1.53 MB

Open source, JS eCommerce SDK for building headless, Jamstack applications. Build custom storefronts, carts, and checkouts in any frontend framework, platform, or device. Integrates with Stripe, Square, PayPal, Paymill and Razorpay with support for 135+ currencies.

Home Page: https://commercejs.com

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

commerce.js's Introduction

Fast, powerful, and easy to use JavaScript SDK for building and managing carts, checkouts and receipts. Build custom eCommerce experiences to sell physical and digital products from the Chec API.

CircleCI Version Downloads/week License
commercejs.com | @commercejs | Slack

Installation

With NPM

npm install @chec/commerce.js or yarn add @chec/commerce.js

TypeScript

You may also install our TypeScript definitions:

npm install @types/chec__commerce.js or yarn add @types/chec__commerce.js

Note that when using TypeScript, the definitions are always compliant with our latest version of the API. If you specify a custom API version, or your API key uses an older version, you may get type errors.

Documentation

See the documentation webpage.

Our documentation module source code resides in commerce.js/docs

If you would like to make contributions to the Commerce.js documentation source, here is a guide in doing so.

Configuration

The following configuration options are available to be defined as the third argument in the Commerce constructor:

  • disableStorage: Whether to disable persistent storage (e.g. cookies). Enable for use in server-side environments. Default: false.
  • cartLifetime: Number of days that a cart should be stored for (between 1 and 30). Default: 30.
  • timeoutMs: The number of milliseconds before a request will time out. Default: 60000.
  • axiosConfig: An optional object containing configuration options for axios, if used.
    • headers: A list of request headers. Defining headers here will override the defaults.
  • allowSecretKey: Commerce.js will prevent you from using a secret API key for authorization. Use this option to override. Default: false.

Upgrading

Upgrading to 2.4.0

Commerce.js 2.4.0 only supports API version 2021-03-31 when adding products to a cart with variants. Please consider updating your API version, using the changes listed in the API docs as a guide.

Upgrading to 2.0.0

The major change in Commerce.js v2 is that most methods now return a promise that is fulfilled when the HTTP request is completed. Instead of providing callbacks to the methods in this module, you will have to use promise syntax instead.

- Commerce.Cart.retrieve(function (data) {
+ Commerce.cart.retrieve().then(function (data) {
  // ...
});

Additionally, the API for the various features are now lower-cased.

The cart.add() method now separates its arguments:

- Commerce.Cart.add({ productId: 1, quantity: 2, variant: { foo: 'bar'} })
+ Commerce.cart.add(1, 2, {foo: 'bar'})

Contributing

Check out the contributing guide

Get help

Commerce.js is a project by many contributors. Reach us on Slack and Twitter.

Compilation

The lib files are automatically compiled by our continuous integration pipeline. You only need to commit changes to the src files.

Running the tests

You can run the unit tests for this library from your command line using npm run test, or npm run test:watch to watch for changed and re-run the tests automatically.

Code style

We use the Airbnb JavaScript style guide, and Prettier as our linting tool. To lint your code, use npm run lint or npm run lint:fix to automatically fix violations.

commerce.js's People

Contributors

robbieaverill avatar scopeynz avatar jaepass avatar dvnkshl avatar vocalfan avatar dependabot-preview[bot] avatar dependabot[bot] avatar eufandem avatar john-raymon avatar fmendoza avatar notrab avatar karansinghbisht avatar paitoanderson avatar sinithh avatar guykh avatar ahmadwaleed avatar anugya-gogoi avatar better-boy avatar daniloff200 avatar hariom1625 avatar imagentleman avatar kitfud avatar kvisca avatar mananchawla2005 avatar amaau avatar michizhou avatar sanket143 avatar sudiptog81 avatar zb2oby avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.