0.2.9 ā€¢ Published 11 months ago

shopper v0.2.9

Weekly downloads
3,637
License
MIT
Repository
github
Last release
11 months ago

šŸ›’ shopper

šŸš€ live demo of shopper

šŸ•¹ļø also see the codepen demo

šŸ’° plug your shopify store onto any website!
šŸ›ļø full shopping cart experience with shopify checkout button
āœØ easy html installation! works on any website
šŸ’± users get currency conversions to view prices
šŸ’– free and open source, just for you

āœØ easy html install

  1. add <script> elements in your html <head>

    <script type="importmap-shim">
      {"imports": {
        "shopper/": "https://unpkg.com/shopper@0.2/",
        "shopper": "https://unpkg.com/shopper@0.2/x/shopper.js"
      }}
    </script>
    <script type="importmap-shim" src="https://unpkg.com/shopper@0.2/x/importmap-cloud.json"></script>
    
    <script defer type=module-shim>
      import "shopper/x/install-xiome-menu-system.js"
      import "shopper/x/install-shopper.js"
    </script>
    
    <script defer src="https://unpkg.com/es-module-shims@1.5/dist/es-module-shims.wasm.js"></script>

    note: this technique uses es-module-shims, and if you're already using es-module-shims for something else on the page, just don't repeat that last line (you only want that once per page).

  2. place a <shopper-config> element in your html <head>

    <shopper-config
      mock
      base-currency="cad"
      currencies="usd gbp eur"
    ></shopper-config>

    the above config is in mock mode, which lets you play around with fake products

    we'll explain how to connect your real store in the next section

  3. place the <shopper-cart> element somewhere on your page

    this is all you need

    <shopper-cart></shopper-cart>

    however, you may wish instead to place the cart inside a menu system (like in the demo)

    <xio-menu sticky>
      <xio-menu-item>
    
        <shopper-button></shopper-button>
        <shopper-cart slot="panel"></shopper-cart>
    
      </xio-menu-item>
    </xio-menu>

    also, the cart can take a checkout-in-same-window attribute, if you want to avoid a popup during checkout

    <shopper-cart checkout-in-same-window></shopper-cart>
  4. list products for sale

    list all store products with a <shopper-collection> element and the all attribute

    note: your products have to be in any collection, for them to appear this way.

    <shopper-collection all></shopper-collection>

    list a single collection. get the link by copying and pasting the url from your shopify admin panel

    <shopper-collection link="https://dev-bakery.myshopify.com/admin/collections/424441479"></shopper-collection>

    display a single product for sale.

    <shopper-product link="https://dev-bakery.myshopify.com/admin/products/10232162183"></shopper-product>

    again, you simply copy the link from the product page's url in the shopify dashboard.

    you actually don't need the whole link, just the numbers from the end part of the url.

  5. customize the display of products

    <shopper-product
      link="10232162183"
      href="/products/avocado-toast"
      show-image
      image-size="300x200"
    ></shopper-product>
    • link ā€” product url from the shopify admin dashboard
    • href ā€” make the item clickable, taking the user to any url
    • show-image ā€” attach this attribute if you want the product's first image to be displayed
    • image-size ā€” specify the dimensions the image should be loaded at
      • if omitted, the image will be full-resolution
      • image-size="200" will constrain the image to 200x200
      • image-size="300x200" will constrain the image to 300x200
    <shopper-collection
      show-images
      image-sizes="300x200"
    ></shopper-collection>

šŸ“” connect shopper to your real shopify store

  • replace your <shopper-config>
    use the example below, but use your own values!

    <shopper-config
      base-currency="cad"
      currencies="usd gbp eur"
      shopify-domain="dev-bakery.myshopify.com"
      shopify-storefront-access-token="5f636be6b04aeb2a7b96fe9306386f25"
    ></shopper-config>
  • get your baseCurrency correct!
    this is the same as your store base currency setting in shopify.

  • if you provide currencies, they'll be available for the user to choose
    this is how you specify which currencies you want to allow the currency conversion system to use.
    see crnc for more details.

  • obtain your shopify-domain and shopify-storefront-access-token

    • login to your shopify store's admin area
    • copy your shopify-domain from your browser address bar's url
    • create a new private app (a connection point for your website)
      1. click on the "apps" section on the left sidebar
      2. click the sneaky "Manage private apps" link
      3. check on the agreements and stuff to enable private apps
      4. click "Create new private app"
      5. enter the app name, and developer email
      6. skip the whole "Admin API" section
      7. enable "Storefront API" and check on all "Read" permissions
      8. save your app
    • copy your app's "Storefront access token" (NOT TO BE CONFUSED with the "API Token") and use this as your shopify-storefront-access-token

šŸ’… customize shopper's appearance with css

  • shopper looks very plain and ugly by default
    that's because it's designed to be customized.
    shopper only comes with bare-bones layout styles, so it's as easy as possible to customize to match your store
  • shopper's web components render to light-dom
    this allows complete css customization
  • basic css knowledge is required for visual customizations
    the recommended workflow, is to right-click inspect-element anything you want to customize, look at it's element names and class names, and then write some CSS rules on your page.
    you have to be a bit of a nerd to get this done.
    we're open to somebody writing some standard themes so people can avoid this step in the future

šŸ‘©ā€šŸ”§ under the hood

  • published as an npm package shopper
  • written in typescript
  • es modules
  • universally-compatible web components
  • only makes network requests to shopify, and to https://www.bankofcanada.ca/valet/docs to fetch exchange rates via crnc
  • saves cart data to localStorage to keep track of your cart between page loads

šŸ’– made with open source love, just for you

  • please file issues and collaborate šŸ»
  • we should make some example css themes that look good so people don't have to customize the css
  • we should publish an optimized rollup build for end-use (not suitable for consumption from apps with their own build)
0.2.7

1 year ago

0.2.9

11 months ago

0.2.8

1 year ago

0.2.6

1 year ago

0.2.3

1 year ago

0.2.5

1 year ago

0.2.4

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.2.0-dev.13

2 years ago

0.2.0-dev.12

2 years ago

0.2.0-dev.11

3 years ago

0.2.0-dev.10

3 years ago

0.2.0-dev.9

3 years ago

0.2.0-dev.6

3 years ago

0.2.0-dev.7

3 years ago

0.2.0-dev.8

3 years ago

0.2.0-dev.5

3 years ago

0.2.0-dev.4

3 years ago

0.2.0-dev.3

3 years ago

0.2.0-dev.2

3 years ago

0.2.0-dev.1

3 years ago

0.2.0-dev.0

3 years ago

0.1.5

3 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.1.0-dev.20

4 years ago

0.1.0-dev.21

4 years ago

0.1.0-dev.19

4 years ago

0.1.0-dev.18

4 years ago

0.1.0-dev.15

5 years ago

0.1.0-dev.14

5 years ago

0.1.0-dev.11

5 years ago

0.1.0-dev.10

5 years ago

0.1.0-dev.8

5 years ago

0.1.0-dev.7

5 years ago

0.1.0-dev.6

5 years ago

0.1.0-dev.5

5 years ago

0.0.0

6 years ago