AddToCartEvent

Class

Package 

1com.salesforce.marketingcloud.sfmcsdk.components.events

Description 

An e-commerce event that represents when a user adds an item to their shopping cart. This class is part of the Salesforce Marketing Cloud Unified SDK and extends CartEvent to provide functionality for tracking add-to-cart actions in e-commerce applications.

Declaration 

1class AddToCartEvent : CartEvent

Platform: androidJvm

SDK Version: 11.0.0

Inheritance Hierarchy 

1Event
2  └── EngagementEvent
3      └── CartEvent
4          └── AddToCartEvent

Inherited Properties 

lineItems 

A list of line items associated with the cart event.

1val lineItems: List<LineItem>

Type: List<LineItem>

Access: Read-only

Inherited from: CartEvent


category 

The event category name. Category contains list of allowed values.

1open override var category: Event.Category

Type: Event.Category

Access: Read/write

Inherited from: EngagementEvent


priority 

Priority level for this event.

1open override val priority: Priority

Type: Priority

Access: Read-only

Inherited from: EngagementEvent


Inherited Methods 

attributes() 

Returns the event attributes for this event.

1open override fun attributes(): Map<String, Any>

Returns: Map<String, Any> - A map containing the event’s attributes as key-value pairs.

Inherited from: EngagementEvent


name() 

Returns the name for the event. This value must match the Event Name used when creating the event in the Marketing Cloud UI for any action to result from tracking this event.

1open override fun name(): String

Returns: String - The event name.

Inherited from: EngagementEvent


Related Types 

LineItem 

Data class that describes purchasable items for Cart & Order events.

Constructor 

1@JvmOverloads
2constructor(
3    catalogObjectType: String,
4    catalogObjectId: String,
5    quantity: Int,
6    price: Double? = null,
7    currency: String? = null,
8    attributes: Map<String, Any> = mapOf()
9)

Parameters 

ParameterTypeRequiredDescription
catalogObjectTypeStringYesType name for the catalog object in the line item
catalogObjectIdStringYesUnique identifier for the catalog object
quantityIntYesNumber of catalog objects in this line item
priceDouble?NoPrice of the catalog object (defaults to null)
currencyString?NoCurrency for the price field (defaults to null)
attributesMap<String, Any>NoMap of user-supplied values (defaults to empty map)

Properties 

PropertyTypeMutabilityDescription
catalogObjectTypeStringRead-onlyType name for the referenced catalog object
catalogObjectIdStringRead-onlyUnique identifier for the referenced catalog object
quantityIntRead-onlyNumber of catalog objects in the line item
priceDouble?MutablePrice of the referenced catalog object
currencyString?MutableCurrency for the price field
attributesMap<String, Any>MutableMap of user-supplied values

See Also 

  • CartEvent - Base sealed class for cart-related events
  • RemoveFromCartEvent - Event for when a user removes an item from their shopping cart
  • ReplaceCartEvent - Event for when a user replaces their shopping cart with a list of items
  • EngagementEvent - Base sealed class for engagement-related events
  • EventManager - Manages event tracking (initialized during SFMCSdk.configure call)
  • LineItem - Data class describing purchasable items