shopify-api-js
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

ShopifyFrontendHelper

This npm package is designed to simplify Shopify front-end development by providing a set of helper methods.

Installation

You can install the package using npm:

npm install shopify-api-js

Usage

After installing the package, you can import and use the helper methods in your code:

import { ShopifyFrontendHelper } from 'shopify-frontend-helper';
const sfh = new ShopifyFrontendHelper();
sfh.addToCart([{id: 123, quantity: 1}]).then((response) => {
  console.log(response);
});

API

The package provides the following helper methods:

  • addToCart(items: Array<CartItem>): Promise<any> : Adds items to the cart.
  • addVariantToCart(variantId: number, quantity: number): Promise<any> : Adds a variant of a product to the cart.
  • removeFromCart(variantId: number): Promise<any> : Removes a variant from the cart.
  • updateQuantityInCart(variantId: number, quantity: number): Promise<any> : Changes the quantity of a variant in the cart.
  • updateCartItem(updatedItem: any): Promise<any> : Changes the item in the cart. It's important to send id, quantity and properties.
  • search(query: string, type: string = 'product', limit: number = 10, unavailable_products: string = 'last', fields: string = 'title,product_type,variants.title,vendor'): Promise<any> : Searches for resources on the store.
  • clearCartItems(): Promise<any> : Clears the cart of items.
  • clearCartFully(): Promise<any> : Clears the cart of items, attributes, and note.
  • customerLogin(email: string, password: string, redirectUrl: string = '/account/'): Promise<any> : Logs in a customer.

The package also exports the following interfaces:

  • interface FetchConfig
  • interface CartItem

Additionally, the package extends the global window object with the following properties:

  • window.shopifyFrontendHelper
  • window.Shopify

To use the package, you must have a valid Shopify storefront API key and password.

Package Sidebar

Install

npm i shopify-api-js

Weekly Downloads

20

Version

1.0.7

License

Apache

Unpacked Size

26.3 kB

Total Files

6

Last publish

Collaborators

  • soundsgoodagency1