Overview
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.
Index
Usage
writing data
Here is an example on how to write data to a JSMA cart:
# TODO
reading data
Here is an example on how to read data from a JSMA cart:
# TODO
Methods
The JSMA cart provides the following methods:
cartItem cart.addItem(product_id, [project], [custom_price])
Adds an item to the items list of JSMA cartItem
Returns the new cartItem.
Example
... cart.addItem(1); ...
Parameter product_id (required)
Parameter project (optional)
Parameter custom_price (optional)
cartItem cart.addItemFromOrderItem(item_uuid)
Adds a JSMA orderItem* (specified by uuid) to the *items* list of *JSMA cartItem
Returns the new cartItem.
Example
... cart.addItemFromOrderItem(1); ...
Parameter item_uuid (required)
cartItem cart.addVoucher([token])
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
... cart.addVoucher('A_VALID_VOUCHER_TOKEN') ...
Parameter token (optional)
cart.flexAttributes
Returns the flex attributes associated with the cart
Example
... cart.flexAttributes ...
cart.get(key)
Accesses a flex attribute field for the given parameter key
Example
... cart.get(key) ...
Parameter key (required)
cart.has(key)
Returns true if a cart has a flex attribute for the given parameter key, otherwise false.
Example
... cart.has(key) ...
Parameter key (required)
address cart.invoiceAddress
Returns the invoice address as JSMA address.
Example
... cart.invoiceAddress // => address ...
cartItem[] cart.items
Returns a list of cartItems.
Example
... cart.items ...
string cart.paymentMethod
Returns the paymentMethod field of a cart.
Example
... cart.paymentMethod // => 'paypal' ...
string cart.paypalPurchaseUrl(return_url, cancel_url)
Returns the URL to purchase a cart with paypal.
Example
... cart.paypalPurchaseUrl('http://my-website.com/success', 'http://my-website.com/cart') ...
Parameter return_url (required)
The URL to which the user will be redirected after finishing the transaction on the paypal website.
Parameter cancel_url (required)
The URL to which the user will be redirected when cancelling the transaction on the paypal website.
portal cart.portal
Returns the JSMA portal of the cart.
Example
... cart.portal ...
int cart.price
Returns the price of the cart in cents
Example
... cart.price // => 1995 ...
void cart.removeItem(uuid)
Removes the cartItem specified by uuid from the cart.
Example
... cart.removeItem('A_UUID_OF_A_CARTITEM'); ...
Parameter uuid (required)
A uuid from the list of JSMA cartItems of the cart.
cart.set(key, value)
Sets a flex attribute with the given parameters
Example
... cart.set(key, value) ...
Parameter key (required)
Parameter value (required)
cart.remove(key)
Removes a flex attribute for given parameter key.
Example
... cart.remove(key) ...
Parameter key (required)
void cart.setPaymentMethod(payment_mode)
Sets the paymentMethod of the cart to the specified value.
Example
... cart.setPaymentMethod('invoice'); ...
Parameter payment_mode (required)
void cart.setShipping(cent)
Sets the shipping cost of the cart.
Example
... cart.setShipping(495); ...
Parameter cent (required)
bool cart.setShippingMode(shipping_mode)
Sets the shippingMode to the desired value. Returns true if update was successful.
Example
... cart.setShippingMode('shipping_normal_xl'); // => true ...
Parameter shipping_mode (required)
May be either of
- store
- shipping_normal
- shipping_normal_xl
- shipping_express
- shipping_express_xl
int cart.shipping
Returns the shipping cost in cents.
Example
... cart.shipping // => 495 ...
address cart.shippingAddress
Returns the shipping address as JSMA address.
Example
... cart.shippingAddress // => JSMA address ...
int cart.tax
Returns the included VAT of the cart in cents.
Example
... cart.tax // => 205 ...
cartItem cart.updateItem(product_id, project, uuid)
Replace a cartItem by uuid with a new one.
Example
... cart.updateItem(product_id, project, uuid) ...
Parameter product_id (required)
Parameter project (required)
Parameter uuid (required)
string cart.uuid
Returns the cart's uuid.
Example
... cart.uuid ...