npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ebolution/bigcommerce-mini-cart

v1.1.0

Published

Library to display cart information in a side panel using GraphQL

Downloads

12

Readme

BigCommerce Mini Cart

This module grabs information related to the current cart using the storefront GraphQL API to be displayed as a mini cart, replacing the native cart.php request performed by the standard Stencil-based themes.

How to use

The module provides you with the main library that grabs all the information and a base template to use as model but the real integration in your theme is up to you.

Pre-requisites

  1. This module requires TailwindCSS installed in your theme and correctly mapped to generate styles from the templates the modules uses.
  2. The reactivity is controlled by AlpineJS, so you also need this library to be installed in case you want to use the sample approach delivered with the module.

Installation

Run npm install @ebolution/bigcommerce-mini-cart

Integration

The module needs to be initialized within the global javascript initialization performed by all the stencil-based themes. In this case the global.js file which implements the Global class extending from PageManager.

Import the module into the file by adding this in the import section:

import miniCart from '@ebolution/bigcommerce-mini-cart';

Add the following sentence inside the onReady method.

window.miniCart = miniCart;

Also, to provide a correct support on mobile, the built-in preview library call must be removed from the main javascript load script. These lines must be removed from global.js:

import cartPreview from './global/cart-preview';

...

cartPreview(secureBaseUrl, cartId);

The modification should look like this:

adjustments_to_globaljs.jpg

Include the template

As the templates can't be injected directly from modules, you need to create a copy of the model template into your theme. The easiest way is copying the file node_modules/@ebolution/bigcommerce-mini-cart/src/templates/default. html into templates/vendor/ebolution/bigcommerce-mini-cart/default.html and include it in the appropriate template, for example templates/components/common/navigation.

include_template.jpg

Notes

Be aware that this module contains a mechanism to detect the click in the cart element somehow similar to the stencil native utils.hooks. It is based on the existence of the data-cart-preview property associated to the element that triggers the mini-cart display.

For more information about how it's done, see the file js/hooks/cart.js, and how it's used in js/mini-cart.js.

data_cart_preview_property.jpg