pushAddToCart()

Example 1: Adding The Current Product To The Cart

When a shopper clicks on the "add to cart" button or starts checking out with a product you can use this code to let fera know:

fera.push('addToCart'); // FYI fera.push('pushAddToCart' also works, this is just more readable

Example 2: Adding a Specific Product To The Cart

Fera will assume that the product added to the cart is the product current being viewed by the shopper. If it is not, then specify the product data like this:

fera.push('addToCart', {
product_id: 'product-123',
variant_id: 'variant-123' // Optional, if a variant is selected
});

Example 3: Adding a Specific Product And Providing Product Data

fera.push('addToCart', {
product: {
"id": "product-123", // String
"name": "Product 123", // String
"status": "complete", // (Optional) String
"created_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"modified_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"stock": 123, // (Optional) Integer, If null assumed to be infinite.
"in_stock": true, // (Optional) Boolean
"url": "https://www.example.com/products/product-123", // String
"thumbnail_url": "https://cdn.example.com/products/product-123/image.png", // String
"needs_shipping": true, // (Optional) Boolean
"hidden": false, // (Optional) Boolean
"variants": [{
"id": "variant-123", // String
"name": "Variation 123", // String
"status": "complete", // (Optional) String
"created_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"modified_at": "2019-03-18T21:01:10+00:00", // (Optional) String (ISO 8601 format DateTime)
"stock": 123, // (Optional) Integer, If null assumed to be infinite.
"in_stock": true, // (Optional) Boolean
"url": "https://www.example.com/products/product-123", // String
"thumbnail_url": "https://cdn.example.com/products/product-123/image.png", // String
"needs_shipping": true, // (Optional) Boolean
"hidden": false, // (Optional) Boolean
"variants": [Variant], // (Optional) Array<Variant>: Variants that are applicable to this product.
"platform_data": { "any": "data" } // (Optional) Hash/Object of attributes to store about the product specific to the integration platform (can be used in future filters)
}],
"platform_data": { "any": "data" } // (Optional) Hash/Object of attributes to store about the product specific to the integration platform (can be used in future filters)
}
variant_id: 'variant-123' // Optional, if a variant is selected
});

‚Äč