Basket Tracking methods

This page details the available methods in the Basket Tracking script.

Description of Fields

Basket

NameTypeDescription
customer_idintThis is the ID for the customer space on the system. This is used to identify which customer space the requests are relevant to.
recipientstringThis is the email address of the recipient who is currently using the e-commerce system. This is used to identify the recipient to whom the triggered emails will be sent, and whose profile information is created.
tokenstringThis security token is the unique hash created for each recipient. The section on Creating the Token shows how to get this field.
basket_type_idintThis field identifies the basket type for customer spaces with more than one type of basket. If a customer space only has one type of basket, this will be 1.
stagestringThe stage is a string representing the current stage in the process of the e-commerce system. Stages are set by customers on the basket type, and the last stage is always 'complete'.
total_valuedecimal (2 d.p.)The total value of all of the items within the basket. As it cannot be assumed that the total value of the basket is always the sum of the values of all of the items (due to the possibility of discounts/promotions etc.) this field is used to give a total value for the basket to be used in gathering statistics. This field is always optional, but if it is used, it should be set with every request.
custom_fieldsobjectThe custom fields are given as an object literal containing any additional fields that need to be set on a basket.
itemsarrayThe array of items currently in the basket. All fields are optional, though providing either a product name or product code would prove useful as a unique identifier for each item. The fields that can be set on an item are shown below.

Items

NameType
namestring (255 max chars)
quantityint
valuedecimal (2 d.p.)
product_codestring (255 max chars)
descriptionstring
custom_fieldsobject

clearItems

Mxm.Basket.clearItems( {object} data )

This method sends a request to the system.

Used to clear the items in the basket. data is an object literal containing the following fields:

  • stage
  • customer_id
  • token
  • recipient
  • basket_type_id
  • total_value
  • custom_fields

stage is optional, though it cannot be set in the defaults. If stage is not given, the stage provided in the last request is used. If there was no last request, this method will throw an exception.


getBasketTypeId

{number} Mxm.Basket.getBasketTypeId( )

Gets the current basket_type_id in the defaults. If not set, uses default of 1.


getCustomerId

{number} Mxm.Basket.getCustomerId( )

Gets the current customer_id in the defaults if set, null if not set.


getCustomFields

{object} Mxm.Basket.getCustomFields( )

Gets the current custom_fields in the defaults if set, null if not set.


getDefaults

{object} Mxm.Basket.getDefaults( )

Returns an object literal containing the defaults.


getItems

{array} Mxm.Basket.getItems( )

Gets the current items in the basket.


getRecipient

{string} Mxm.Basket.getRecipient( )

Gets the current recipient in the defaults if set, null if not set.


getStage

{string} Mxm.Basket.getStage( )

Gets the current stage in the defaults if set, null if not set.


getToken

{string} Mxm.Basket.getToken( )

Gets the current token in the defaults if set, null if not set.


getTotalValue

{number} Mxm.Basket.getTotalValue( )

Gets the current total_value in the defaults if set, '0' if not set.


setBasketTypeId

{this} Mxm.Basket.setBasketTypeId( {number} id )

Sets the current basket_type_id in the defaults.


setCustomerId

{this} Mxm.Basket.setCustomerId( {number} id )

Sets the current customer_id in the defaults.


setCustomFields

Mxm.Basket.setCustomFields( {object} fields )

Sets the current custom_fields in the defaults.

Additional fields set via the setCustomFields() method are not visible in the UI. To access them, the below token needs to be placed in your shopping cart snippet: [basket(incomplete):custom.customField]

Example

var custom = {
 deliveryRate : 10,
 customUrl: oxfordstones.com
}
 
Mxm.Basket.setCustomFields(custom);
<!-- in a live email, this token will be converted to '10' -->
[basket(incomplete):custom.deliveryRate]

<!-- in a live email, this token will be converted to 'oxfordstones.com' -->
[basket(incomplete):custom.customUrl]

setDefaults

{this} Mxm.Basket.setDefaults( {object} data )

Used to set the defaults for all subsequent requests. An object literal containing any of the fields:

  • customer_id
  • token
  • recipient
  • basket_type_id
  • total_value
  • custom_fields
  • debug

setItems

{this} Mxm.Basket.setItems( {array} data )

👍

Active call

This method sends a request to the system.

Used to set the items currently in the basket. An object literal containing the following fields:

  • items
  • stage
  • customer_id
  • token
  • recipient
  • basket_type_id
  • total_value
  • custom_fields

🚧

Set the correct stage

stage is optional, though it cannot be set in the defaults. If stage is not given, the stage provided in the last request is used. If there was no last request, this method will throw an exception.


setRecipient

{this} Mxm.Basket.setRecipient( {string} recipient )

Sets the current recipient in the defaults.


setStage

{this} Mxm.Basket.setStage( {string|object} data )

👍

Active call

This method sends a request to the system.

Used to set the current stage of the basket. The argument given can either be the string containing the current stage, or the data object, which is an object literal containing the following fields;

  • stage
  • customer_id
  • token
  • recipient
  • basket_type_id
  • total_value
  • custom_fields

setToken

{this} Mxm.Basket.setToken( {string} token )

Sets the current token in the defaults.


setTotalValue

Mxm.Basket.setTotalValue( {number} value )

Sets the current total_value in the defaults.


setDebug

Mxm.Basket.setDebug( {boolean} enabled )

Sets the debug value in the defaults.


† Fields marked with (†) are optional