0.1.0 • Published 6 years ago

ember-api-cart v0.1.0

Weekly downloads
25
License
MIT
Repository
-
Last release
6 years ago

Ember API Cart

Addon for easily managing line-items in a cart format.

Service

eac-service is included as the primary data management portion and can be included in routes to handle importing and exporting cart data.

importData(array)

Pass in an array of objects to import as line items

  [
    {id: INT, name: STRING, quantity: INT, price: FLOAT}
  ]

exportData()

setDonationAmount(FLOAT)

Set cart donation amount

addItemToCart(object)

Add object as a line item. If object ID already exist, increment item quantity

{id: INT, name: STRING, quantity: INT, price: FLOAT}

removeItemFromCart(itemId)

Removes all line item via item ID

emptyCart()

Removes all line items from cart and zero's out donation.

Components

{{ember-api-cart}}

This component generates the cart with line items, donation field, empty cart button and total with the option to change quantities and remove line items.

{{eac-add}}

This button will add the passed object to the cart as a line item.

First value is string for button text, second value expects an object with at least 3 values.

{{eac-add "Btn Text" object}}

Expected object values

{id: INT, name: STRING, price: FLOAT}

{{eac-donation}}

This component displays a number input field and a save button. Once a number is input and saved, the value is added to the eacService and displayed in the cart as a donation which is added to the cart total.

{{eac-mini}}

This component displays quantity, name and price for each line item as well as a button for emptying the cart and viewing the cart. The goToCart action is triggered when the button "view" is clicked, and is intended to direct to the cart route.

{{eac-mini goToCart=(action 'goToCart')}}

{{eac-quantity}}

This component displays the cart quantity. If miniCart=true then clicking the number will popup the {{mini-cart}} component. Which requires a goToCart action. This action is triggered when the button "view is clicked".

{{eac-quantity miniCart=true goToCart=(action 'goToCart')}}