Class: AddToCartButtonListener

AddToCartButtonListener(cart)

'ga4_add_to_cart' - triggered when the user clicks a '+' button on an item in the sidecart. Uses the CartJS cart to query the item that was updated and generate the event payload.

Constructor

new AddToCartButtonListener(cart)

Parameters:
Name Type Description
cart Object the CartJS cart object
Source:

Extends

Classes

AddToCartButtonListener

Members

addedItems :Array

Getter that returns an array of items that were added to the cart. The array is empty if no items were added. Subclasses can override this method to control the event payload.
Type:
  • Array
Source:

Methods

getQuantityDifference(item) → {number}

Compares the added item against the existing cart and returns the difference in quantity.
Parameters:
Name Type Description
item Object the item added
Properties
Name Type Description
id string | number
quantity number
Source:
Returns:
the quantity increase in the added item
Type
number