ReplaceCartEvent

Package 

com.salesforce.marketingcloud.sfmcsdk.components.events

Overview 

1class ReplaceCartEvent : CartEvent

An E-commerce event for when a user replaces their shopping cart with a list of items.

Platform 

  • Target Platform: androidJvm
  • SDK Version: 11.0.0
  • Available Since: 10.0.0

Description 

The ReplaceCartEvent class represents a complete replacement of a user’s shopping cart contents. This event is triggered when the entire cart is replaced with a new set of items, as opposed to incrementally adding or removing individual items (which would use AddToCartEvent or RemoveFromCartEvent respectively).

Inheritance Hierarchy 

1Event (abstract)
2  └── EngagementEvent (sealed)
3        └── CartEvent (sealed)
4              └── ReplaceCartEvent

Related Classes 

Parent: CartEvent 

ReplaceCartEvent extends the sealed class CartEvent, which provides cart-specific functionality for engagement events.

Sibling Classes 

  • AddToCartEvent - Event for adding items to the cart
  • RemoveFromCartEvent - Event for removing items from the cart

Inherited Properties 

From CartEvent 

lineItems 

1val lineItems: List<LineItem>

A list of line items associated with the cart event. Each LineItem represents a product or catalog object being replaced in the cart.

From EngagementEvent 

category 

1open override var category: Event.Category

The Event category Name. Category contains list of allowed values.

priority 

1open override val priority: Priority

Defines the priority level for this engagement event.

Inherited Methods 

From EngagementEvent 

attributes() 

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

Returns: A map containing key-value pairs of event attributes.

Description: The Event attributes for this event.

name() 

1open override fun name(): String

Returns: The event name as a String.

Description: 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.

Associated Types 

LineItem 

The lineItems property uses the LineItem data class to represent individual products in the cart.

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

LineItem Properties 

PropertyTypeDescriptionMutable
catalogObjectTypeStringA type name representing the catalog object referenced in the line itemNo
catalogObjectIdStringA unique identifier representing the catalog object referenced in the line itemNo
quantityIntThe number of catalog objects in this line itemNo
priceDouble?The price of the catalog object referenced in the line item (nullable)Yes
currencyString?The currency for the price field (nullable)Yes
attributesMap<String, Any>A map of user-supplied valuesYes

Usage Notes 

  • As ReplaceCartEvent extends the sealed class CartEvent, it can only be instantiated directly using its constructor
  • The event name returned by the name() method must correspond to event configurations in the Marketing Cloud UI to trigger associated actions
  • ReplaceCartEvent is part of the engagement tracking system and integrates with Salesforce Marketing Cloud for e-commerce analytics
  • When creating a ReplaceCartEvent, you must provide a list of LineItem objects representing the complete new contents of the cart