0.0.7 • Published 4 years ago

gatsby-plugin-snipcart-3 v0.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

SnipCart V3 plugin for Gatsby JS (Beta version)

Snipcart

This plugin include a Context for quantity in cart and detect if user is logged or not

Install

    npm install gatsby-plugin-snipcart-3

API KEY

Declare API KEY Snipcart in environment variable

  • GATSBY_SNIPCART_API_KEY

The plugin use :

process.env.GATSBY_SNIPCART_API_KEY

Usage

In your gatsby-config.js file, add:

module.exports = {
  plugins: [
    {
        resolve: `gatsby-plugin-snipcart-3`,
        options: {
            version: '3.0.12',
            lang: 'fr',
            currency: 'eur',
            openCartOnAdd: false,
            locales: {},
            innerHTML: `
            <billing section="bottom">
                ...
            </billing>`,
        },
    },
  ],
}

Options

  • version : define version of snipcart / default 3.0.12
  • lang : define lang / default "en"
  • currency : define currency / default "usd"
  • openCartOnAdd : open the cart when user click on "add to cart" btn / default: true
  • locales : object of locales string / default {} localisation files is here => https://github.com/snipcart/snipcart-l10n
  • innerHTML : code for override snipcart element / default '' customization doc => https://docs.snipcart.com/v3/setup/customization)

use the context in component

import {SnipCartContext} from 'gatsby-plugin-snipcart-3/context';

const MyComponent = () => {
  const {userStatus, cartQuantity} = useContext(SnipCartContext);
return (
    <div>
      {userStatus === 'SignedOut' ? (
        <button className="snipcart-customer-signin">
          <span>Se connecter</span>
        </button>
      ) : (
        <button className="snipcart-customer-signin">
          <span>Mon compte</span>
        </button>
      )}
      <button className="snipcart-checkout">
        <span>{cartQuantity}</span>
      </button>
    </div>
  );
}
0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago