Product status addToCart
- 1 Minute to read
- Print
- DarkLight
Product status addToCart
- 1 Minute to read
- Print
- DarkLight
Article summary
Did you find this summary helpful?
Thank you for your feedback
You can analyze in detail which products on your website are placed in the shopping cart. The status is typically set to "AddToCart" if the "add to cart" button has been clicked.
Methods
The addToCart object contains the following four methods, which are contained in the objects data and parameter:
set: Overwrites all existing values.
add: Overwrites only the corresponding values.
get: Returns the current configuration.
remove: Removes the current configuration or individual values.
data
set
/**
* @param {{
* id: string,
* [cost=0]: number,
* [quantity=0]: number,
* [soldOut=false]: boolean,
* [parameter={}]: {[number]: string},
* [category={}]: {[number]: string}
* }[]} data
*
* @returns {wtSmart.product.addToCart.data}
*/
wtSmart.product.addToCart.data.set(data);
add
/**
* @param {{
* id: string,
* [cost=0]: number,
* [quantity=0]: number,
* [soldOut=false]: boolean,
* [parameter={}]: {[number]: string},
* [category={}]: {[number]: string}
* }[]} data
*
* @returns {wtSmart.product.addToCart.data}
*/
wtSmart.product.addToCart.data.add(data);
get
/**
* @returns {{
* id: string,
* cost: number,
* quantity: number,
* soldOut: boolean,
* parameter: {[number]: string},
* category: {[number]: string}
* }[]}
*/
wtSmart.product.addToCart.data.get();
remove
/**
* @param {number[]} [removeAddToCart]
*
* @returns {wtSmart.product.addToCart.data}
*/
wtSmart.product.addToCart.data.remove(removeAddToCart);
Example
var product = {
id: 'ABC-123',
cost: 99.90,
quantity: 2,
soldOut: false,
parameter: {
1: 'L'
},
category: {
1: 'tops',
2: 'noname'
}
};
// set product addToCart data
wtSmart.product.addToCart.data.set([product, product2]);
// add product addToCart data
wtSmart.product.addToCart.data.add([product3, product4]);
// get product addToCart data
var data = wtSmart.product.addToCart.data.get();
// remove all product addToCart data
wtSmart.product.addToCart.data.remove();
// remove only the first (product) product addToCart data
wtSmart.product.addToCart.data.remove([1]);
parameter
set
/**
* @param {{[number]: string}} data
*
* @returns {wtSmart.product.addToCart.parameter}
*/
wtSmart.product.addToCart.parameter.set(data);
add
/**
* @param {{[number]: string}} data
*
* @returns {wtSmart.product.addToCart.parameter}
*/
wtSmart.product.addToCart.parameter.add(data);
get
/**
* @returns {{[number]: string}}
*/
wtSmart.product.addToCart.parameter.get();
remove
/**
* @param {number[]} [removeAddToCart]
*
* @returns {wtSmart.product.addToCart.parameter}
*/
wtSmart.product.addToCart.parameter.remove(removeAddToCart);
Example
// set product addToCart parameter
wtSmart.product.addToCart.parameter.set({
1: 'bar'
});
// add product addToCart parameter
wtSmart.product.addToCart.parameter.add({
7: 'foo.bar'
});
// get product addToCart parameter
var data = wtSmart.product.addToCart.parameter.get();
// remove all product addToCart parameter
wtSmart.product.addToCart.parameter.remove();
// remove only product addToCart parameter 7
wtSmart.product.addToCart.parameter.remove([7]);
Code Generator
Use the code generator to create individual code that you can then integrate directly into the website.
Was this article helpful?