.add   RC.Server.Cart.add

Adds a product to the user's shopping cart.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters required hashmap (none) The product identification and quantity to be added to the shopping cart. See the parameters section below for details.
options optional hashmap (none) Request options. See the options section below for details
parameters
Parameter Options Type Default Description
productId required numeric (none) The product ID of the product to add to the shopping cart.
This will normally by the output from {{ product.id }} template fragment.
variantId required 1 numeric null The product variant ID of the product variant to add to the shopping cart.
This will normally by the output from {{ variant.id }} template fragment.
customizationId optional numeric null The product customization ID.
kitId optional numeric null The product kit ID.
quantity 2 optional numeric 1 The quantity to add. If not specified, quantity of 1 is used by default.
options
Parameter Options Type Default Description
post optional hashmap or POST data (none) Additional item-related information to be saved with the item. See post section below for more information.
success optional function (none) Default success handler.
failure optional function (none) Default failure handler.
post
Parameter Options Type Default Description
quantity 2 optional numeric 1 The quantity to add. If not specified, quantity of 1 is used by default.
notes optional string (none) Notes related to the item.
metafields optional string (none) Comma-separated list of metafield names posted with this add request. For example, if there is an option for Gift Packaging and Gift Card, using input names gift-packaging and gift-card respectively, then the metafield has to be set to gift-packaging,gift-card.
  • 1 Only applies to products with variants.
  • 2 Quantity can be specified as parameter or as a post field (when submitting it from a form, for example). The later takes precedence, if both are specified. If none are specified, quantity of 1 is used.
EXAMPLE
RC.Server.Cart.add( { productId: {{ product.id }}, variantId: null, customizationId: null, kitId: null }, { 
	post: $('#add-to-cart-{{ product.id }}').serialize(), 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 

.update   RC.Server.Cart.update

This method can update the quanitty, notes and customization data for a single cart item, identified by its item ID, or update quantities across all cart items in a single submit.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters required hashmap (none) The item identification and new quantity to be set. See the parameters section below for details.
options optional hashmap (none) Request options. See the options section below for details
parameters
Parameter Options Type Default Description
itemId 2 required numeric (none) The item ID of the cart item.
This will normally by the output from {{ item.id }} template fragment.
quantity 1 required 2 numeric (none) The new quantity to set.
options
Parameter Options Type Default Description
post optional hashmap or POST data (none) Additional item-related information to be saved with the item. See post section below for more information.
success optional function (none) Default success handler.
failure optional function (none) Default failure handler.
post
Parameter Options Type Default Description
item_{id}_quantity 3 required numeric (none) The quantity to add. If not specified, quantity of 1 is used by default.
quantity 1 required 2 numeric 1 The quantity to add. If not specified, quantity of 1 is used by default.
notes 1 optional string (none) Notes related to the item.
  • 1 Applicable to single-item updates only.
  • 2 Quantity can be specified as parameter or as a post field (when submitting it from a form, for example). The later takes precedence, if both are specified.
  • 3 Applicable to multi-item updates only.
EXAMPLE (SINGLE ITEM UPDATE)
RC.Server.Cart.update( { itemId: {{ item.id }}, quantity: 4 }, { 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 
EXAMPLE (MULTI-ITEM UPDATE)
RC.Server.Cart.update( {}, { 
	post: $('cart-form').serialize(), 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 

.remove   RC.Server.Cart.remove

Removes single cart item, identified by its item ID, from the user's shopping cart.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters required hashmap (none) The item identification. See the parameters section below for details.
options optional hashmap (none) Request options. See the options section below for details
parameters
Parameter Options Type Default Description
itemId required numeric (none) The item ID of the cart item.
This will normally by the output from {{ item.id }} template fragment.
options
Parameter Options Type Default Description
success optional function (none) Default success handler.
failure optional function (none) Default failure handler.
EXAMPLE (SINGLE ITEM UPDATE)
RC.Server.Cart.remove( { itemId: {{ item.id }} }, { 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 

.clear   RC.Server.Cart.clear

Removes all cart items with a single call.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters optional hashmap (none) Not used, could be set null or empty hashmap.
options optional hashmap (none) Request options. See the options section below for details
options
Parameter Options Type Default Description
success optional function (none) Default success handler.
failure optional function (none) Default failure handler.
EXAMPLE (SINGLE ITEM UPDATE)
RC.Server.Cart.clear( {}, { 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 

.addCoupon   RC.Server.Cart.addCoupon

Adds a coupon to the shopping cart.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters required hashmap (none) The coupon details. See the parameters section below for details.
options optional hashmap (none) Request options. See the options section below for details
parameters
Parameter Options Type Default Description
code required alpha-numeric (none) The coupon code, as entered by the user.
options
Parameter Options Type Default Description
success optional function (none) Callback handler for successful coupons. The callback takes 2 parameters, response code (always 0 on success) and response message.
failure optional function (none) Callback handler for failed coupons. The callback takes 2 parameters, response code and response message. See response code table below for information on the possible errors.
Response Codes
Code Description
180 Voucher not found
181 Voucher inactive
182 Voucher unavailable
183 Voucher not eligible
184 Voucher limited to account
185 Voucher insufficient basket value
186 Voucher insufficient item count
187 Voucher limit reached
EXAMPLE
RC.Server.Cart.addCoupon( { code: 'PROMO100' }, { 
	success: function(responseCode /* always 0 */, responseMsg) { /* ... */ }, 
	failure: function(responseCode /* always non-0 */, responseMsg) { alert(errorMsg); } 
} ); 

.removeCoupon   RC.Server.Cart.removeCoupon

Removes a coupon from the shopping cart.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters required hashmap (none) The coupon details. See the parameters section below for details.
options optional hashmap (none) Request options. See the options section below for details
parameters
Parameter Options Type Default Description
code required alpha-numeric (none) The coupon code to remove. Usually this is injected using the {{ coupon.code }} template fragment.
options
Parameter Options Type Default Description
success optional function (none) Default success handler.
failure optional function (none) Default failure handler.
www
EXAMPLE
www
RC.Server.Cart.removeCoupon( { code: 'PROMO100' }, { 
	success: function(context,html,xml) { /* ... */ }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} ); 

.checkout   RC.Server.Cart.checkout

Creates a new checkout from the shopping cart.

METHOD PARAMETERS
Parameter Options Type Default Description
parameters optional hashmap (none) Not used, could be set null or empty hashmap.
options optional hashmap (none) Request options. See the options section below for details
options
Parameter Options Type Default Description
success optional function (none) Callback handler for successful checkout initialization. The callback takes 1 parameter, the checkout unique key, used in the page URL.
failure optional function (none) Default failure handler.
EXAMPLE
RC.Server.Cart.checkout( {}, { 
	success: function(key) { location.href='/checkout/details/'+key; }, 
	failure: function(context,errorMsg,xml,XHR) { alert(errorMsg); } 
} );