Cart

Cart

Cart management methods

Constructor

new Cart(api)

Main constructor

Source:
Parameters:
Name Type Description
api MkmApi

Parent api to make the calls

Methods

(async) addArticle(idArticle, amount) → {Promise}

Adds or remove an article from the shopping cart

Source:
Parameters:
Name Type Description
idArticle number

id of the article

amount number

Ammount to add or remove (negative numbers remove items)

Returns:
Type:
Promise

Operation result

(async) checkout() → {Promise}

Completes the order and pay as many orders as possible with the current funds.

Source:
Returns:
Type:
Promise

Operation result

(async) empty() → {Promise}

Clears the shopping cart

Source:
Returns:
Type:
Promise

Operation result

(async) get() → {Promise}

Get the current contents of the shopping cart

Source:
Returns:
Type:
Promise

Contents of the shopping cart

(async) getShippingMethods(idReservation) → {Promise}

Gets the list of all possible shipping methods for a reservation (all the items from a single user)

Source:
Parameters:
Name Type Description
idReservation number

id of the reservation, it can be retrieved with Cart#get

Returns:
Type:
Promise

Options for shipping that reservation.

(async) removeArticle(idArticle, amount) → {Promise}

Removes an article from the shopping cart

Source:
Parameters:
Name Type Description
idArticle number

id of the Article to be removed

amount number

Amount of elements to be removed

Returns:
Type:
Promise

Operation result

(async) setShippingAddress(shippingAddress) → {Promise}

Updates the shipping address for all the items in the cart.

Source:
Parameters:
Name Type Description
shippingAddress Object

Object with the new address.

Returns:
Type:
Promise

Operation result

(async) setShippingMethod(idReservation, idShippingMethod) → {Promise}

Sets the shipping method for a single reservation.

Source:
Parameters:
Name Type Description
idReservation number

id of the reservation, it can be retrieved with Cart#get

idShippingMethod number

id of the shipping method, it can be retrieved with Cart#getAvailableShippingMethods

Returns:
Type:
Promise

Operation result

(async) updateArticles(articles) → {Promise}

Upadte shopping cart, with this method multiple items can be added or removed from the shopping cart but MKM does not support adding and removing at the same time.

Source:
Parameters:
Name Type Description
articles Array.<{idArticle: number, amount: number}>

Array of elements to be added or removed.

Returns:
Type:
Promise

Operation result