RemoveFromCartEvent

Class

Package 

com.salesforce.marketingcloud.sfmcsdk.components.events

Description 

An E-commerce event for when a user removes an item from their shopping cart.

Platform 

  • Target: androidJvm (Android/JVM)
  • SDK Version: 11.0.0
  • Module: SFMC SDK v3.1.0

Declaration 

1class RemoveFromCartEvent : CartEvent

Inheritance Hierarchy 

1Event (interface)
2  └── EngagementEvent (sealed class)
3      └── CartEvent (sealed class)
4          └── RemoveFromCartEvent (class)

Overview 

RemoveFromCartEvent is part of the Salesforce Marketing Cloud Unified SDK’s event tracking system for e-commerce applications. This event should be tracked when a user removes one or more items from their shopping cart. The event extends CartEvent and inherits all cart-related event functionality.

Properties 

Inherited from CartEvent 

lineItems 

1val lineItems: List<LineItem>

A list of line items representing the items being removed from the cart. Each line item describes a purchasable catalog object with quantity and optional pricing information.

Inherited from EngagementEvent 

category 

1open override var category: Event.Category

The Event category name. Contains a list of allowed values that classify the event type.

priority 

1open override val priority: Priority

Defines the priority level of the event for processing and handling by the SDK.

Methods 

Inherited from EngagementEvent 

attributes() 

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

Returns the event attributes as a map of key-value pairs associated with this event.

Returns: Map<String, Any> - A map containing the event attributes


name() 

1open override fun name(): String

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.

Returns: String - The event name

Related Classes 

LineItem 

Line items describe purchasable items for Cart and Order events.

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

LineItem Parameters 

ParameterTypeRequiredDefaultDescription
catalogObjectTypeStringYes-Type name for the referenced catalog object
catalogObjectIdStringYes-Unique identifier for the referenced catalog object
quantityIntYes-Number of catalog objects in the line item
priceDouble?NonullPrice of the referenced catalog object
currencyString?NonullCurrency code for the price field
attributesMap<String, Any>NomapOf()User-supplied key-value pairs

Usage 

To track when items are removed from a cart, create a RemoveFromCartEvent with the appropriate line items and track it using the SDK’s event tracking system.

Example 

1// Create line items for products being removed
2val lineItem1 = LineItem(
3    catalogObjectType = "Product",
4    catalogObjectId = "product_123",
5    quantity = 1,
6    price = 29.99,
7    currency = "USD"
8)
9
10val lineItem2 = LineItem(
11    catalogObjectType = "Product",
12    catalogObjectId = "product_456",
13    quantity = 2,
14    price = 15.50,
15    currency = "USD"
16)
17
18// Create the remove from cart event
19val removeEvent = RemoveFromCartEvent(listOf(lineItem1, lineItem2))
20
21// Track the event through the SDK
22SFMCSdk.track(removeEvent)

Related Events 

  • AddToCartEvent - E-commerce event for when a user adds an item to their shopping cart
  • ReplaceCartEvent - E-commerce event for when a user replaces their shopping cart with a list of items

See Also 

Notes 

  • The event name must match the configuration in the Marketing Cloud UI to trigger associated actions
  • Line items support custom attributes for additional metadata
  • All cart events inherit from the sealed CartEvent class, ensuring type safety at compile time
  • Events are processed according to their priority level