The jsma cart provides access to the current session cart object. Whenever a user creates a session, a cart object will be created lazily (it will be created when first time accessing JSMA carts method carts.current).
What can JSMA cart do for me?You can use the JSMA cart to manage a users shopping session and facilitate the transaction. |
Here is an example on how to write data to a JSMA cart:
# TODO |
Here is an example on how to read data from a JSMA cart:
# TODO |
The JSMA cart provides the following methods:
Adds an item to the items list of JSMA cartItem
Returns the new cartItem.
... cart.addItem(1); ... |
Adds a JSMA orderItem* (specified by uuid) to the *items* list of *JSMA cartItem
Returns the new cartItem.
... cart.addItemFromOrderItem(1); ... |
If a valid voucher token was given as first argument this method will add a voucher to the cart and return a corresponding JSMA cartItem
... cart.addVoucher('A_VALID_VOUCHER_TOKEN') ... |
Returns the flex attributes associated with the cart
... cart.flexAttributes ... |
Accesses a flex attribute field for the given parameter key
... cart.get(key) ... |
Returns true if a cart has a flex attribute for the given parameter key, otherwise false.
... cart.has(key) ... |
Returns the invoice address as JSMA address.
... cart.invoiceAddress // => address ... |
Returns a list of cartItems.
... cart.items ... |
Returns the paymentMethod field of a cart.
... cart.paymentMethod // => 'paypal' ... |
Returns the URL to purchase a cart with paypal.
... cart.paypalPurchaseUrl('http://my-website.com/success', 'http://my-website.com/cart') ... |
The URL to which the user will be redirected after finishing the transaction on the paypal website.
The URL to which the user will be redirected when cancelling the transaction on the paypal website.
Returns the JSMA portal of the cart.
... cart.portal ... |
Returns the price of the cart in cents
... cart.price // => 1995 ... |
Removes the cartItem specified by uuid from the cart.
... cart.removeItem('A_UUID_OF_A_CARTITEM'); ... |
A uuid from the list of JSMA cartItems of the cart.
Sets a flex attribute with the given parameters
... cart.set(key, value) ... |
Removes a flex attribute for given parameter key.
... cart.remove(key) ... |
Sets the paymentMethod of the cart to the specified value.
... cart.setPaymentMethod('invoice'); ... |
Sets the shipping cost of the cart.
... cart.setShipping(495); ... |
Sets the shippingMode to the desired value. Returns true if update was successful.
... cart.setShippingMode('shipping_normal_xl'); // => true ... |
May be either of
Returns the shipping cost in cents.
... cart.shipping // => 495 ... |
Returns the shipping address as JSMA address.
... cart.shippingAddress // => JSMA address ... |
Returns the included VAT of the cart in cents.
... cart.tax // => 205 ... |
Replace a cartItem by uuid with a new one.
... cart.updateItem(product_id, project, uuid) ... |
Returns the cart's uuid.
... cart.uuid ... |