# @hadimalikdev/shopifycart

> A plug and play shopify cart

Latest version **0.1.1** (published 2023-11-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install @hadimalikdev/shopifycart
pnpm add @hadimalikdev/shopifycart
yarn add @hadimalikdev/shopifycart
bun add @hadimalikdev/shopifycart
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-11-26 |
| First published | 2023-11-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Hadi |
| Maintainers | hadimalikdev |
| Keywords | shopify, cart |

## Links

- npm: https://www.npmjs.com/package/@hadimalikdev/shopifycart
- Repository: https://github.com/HadiMalikDev/ShopifyCart
- Homepage: https://github.com/HadiMalikDev/ShopifyCart#readme
- Issues: https://github.com/HadiMalikDev/ShopifyCart/issues
- npm.io page: https://npm.io/package/@hadimalikdev/shopifycart

## Recent versions

- 0.1.1 (latest) — 2023-11-26
- 0.1.0 — 2023-11-26

## README

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### Table of Contents

*   [ShopifyCart][1]
    *   [Parameters][2]
    *   [addItem][3]
        *   [Parameters][4]
    *   [modifyCartItemByKey][5]
        *   [Parameters][6]
    *   [modifyCartItemByIndex][7]
        *   [Parameters][8]
    *   [modifyCartItemByID][9]
        *   [Parameters][10]
    *   [getCart][11]
    *   [updateCart][12]
        *   [Parameters][13]
    *   [clearCart][14]
    *   [generateShippingRates][15]
        *   [Parameters][16]
    *   [getShippingRates][17]
        *   [Parameters][18]

## ShopifyCart

Represents a simple Shopify cart

Uses the `fetch` API

### Parameters

*   `root_url` **[String][19]** Locale aware root URL. Most commonly accessed using `window.Shopify.routes.root` (optional, default `'/'`)
*   `logging` **[Object][20]** Set up logging (optional, default `{}`)

### addItem

Adds an item to the cart

#### Parameters

*   `variant_id` **[Number][21]**&#x20;
*   `quantity` **[Number][21]?** Quantity of variant to be added. (optional, default `1`)
*   `line_item_properties` **[Object][20]<[string][19], [string][19]>?** Key-value pairs of line item properties
*   `selling_plan` **[Number][21]?** ID of selling plan

Returns **[Promise][22]** Returns API response

### modifyCartItemByKey

Modifies quantity of a line item using line\_item\_key

#### Parameters

*   `line_item_key` **[String][19]**&#x20;
*   `quantity` **[Number][21]** New quantity
*   `line_item_properties` **[Object][20]<[string][19], [string][19]>?** Key-value pairs of line item properties
*   `selling_plan` **[Number][21]?** ID of selling plan

Returns **[Promise][22]** Returns API response

### modifyCartItemByIndex

Modifies quantity of a line item based on 1-based index position of the item in the cart

#### Parameters

*   `index` **[Number][21]** 1-based index of item in cart
*   `quantity` **[Number][21]** Updated quantity
*   `line_item_properties` **[Object][20]<[string][19], [string][19]>?** Key-value pairs of line item properties
*   `selling_plan` **[Number][21]?** ID of selling plan

Returns **[Promise][22]** Returns API response

### modifyCartItemByID

Modifies quantity of a line item based on variant id

#### Parameters

*   `variant_id` **[String][19]** Variant ID of item in cart
*   `quantity` **[Number][21]** New quantity of item
*   `line_item_properties` **[Object][20]<[string][19], [string][19]>** Properties of the cart item
*   `selling_plan` &#x20;
*   `Number` &#x20;

Returns **[Promise][22]** Returns API response

### getCart

Fetches cart

Returns **[Promise][22]** Returns API response

### updateCart

Updates the cart note and attributes

#### Parameters

*   `note` **[String][19]** Cart note. Pass undefined if want to leave as is
*   `attributes` **[Object][20]<[string][19], [string][19]>** Cart attributes. Pass undefined if want to leave as is

Returns **[Promise][22]** Returns API response

### clearCart

Removes all items from cart.

Returns **[Promise][22]** Returns API response

### generateShippingRates

Generates shipping rates
Use the getShippingRates function to retrieve rates once calculations are complete

#### Parameters

*   `zip` **[String][19]**&#x20;
*   `country` **[String][19]**&#x20;
*   `province` **[String][19]**&#x20;

Returns **[Promise][22]** Returns API response

### getShippingRates

Gets shipping rates
Use the generateShippingRates function to calculate the rates

#### Parameters

*   `zip` **[String][19]**&#x20;
*   `country` **[String][19]**&#x20;
*   `province` **[String][19]**&#x20;

Returns **[Promise][22]** Returns API response

[1]: #shopifycart

[2]: #parameters

[3]: #additem

[4]: #parameters-1

[5]: #modifycartitembykey

[6]: #parameters-2

[7]: #modifycartitembyindex

[8]: #parameters-3

[9]: #modifycartitembyid

[10]: #parameters-4

[11]: #getcart

[12]: #updatecart

[13]: #parameters-5

[14]: #clearcart

[15]: #generateshippingrates

[16]: #parameters-6

[17]: #getshippingrates

[18]: #parameters-7

[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object

[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise

---
_Source: https://npm.io/package/@hadimalikdev/shopifycart · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
