...
Here is an example on how to write data to a JSMA cart:
Code Block | ||||
---|---|---|---|---|
| ||||
function updateShipping(countryCode) { //calculate current shipping cost var cart = carts.current; //retrieve country code var country = countryCode; if (!country) { country = cart.shippingAddress.countryCode; } if (!country) { cart.setShipping(0); return; } [...] } |
...
Here is an example on how to read data from a JSMA cart:
Code Block | ||||
---|---|---|---|---|
| ||||
CartApi.prototype.doUpdate = function () { var result = { status : "OK", id : null, price : 0, shipping : 0, tax : 0, items : [], voucher : null }; var cart = carts.current; //core values for cart result.id = cart.uuid; result.amount = cart.price; result.shipping = cart.shipping; result.tax = cart.tax; result.attributes = {}; //add cart attributes cart.flexAttributes.forEach ( function ( key ) { result.attributes[key] = cart.get(key); }); [...] } |
...
Adds an item to the items list of JSMA cartItem
Returns the new cartItem.
...
Adds a JSMA orderItem (specified by uuid) to the items list of JSMA cartItem
Returns the new cartItem.
...
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
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... cart.addVoucher('easter25', 495, 'Oster-Rabatt!') // => cartItem ... |
...
Returns the invoice address as JSMA address.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... cart.invoiceAddress // => JSMA address ... |
...
portal cart.portal
Returns the JSMA portal of the cart.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... cart.portal // => 'Rhino Staging' ... |
...
Parameter uuid (required)
A uuid from the list of JSMA cartItems of the cart.
cart.set(key, value)
...
Returns the shipping address as JSMA address.
Example
Code Block | ||||
---|---|---|---|---|
| ||||
... cart.shippingAddress // => JSMA address ... |
...