Android Mobile SDK: Notify Cart Information

 

The "Notify Cart Information" event is used to describe the shopping cart that the user currently has. It sends the cart's products and state via the Mobile SDK using the Connectif.sendCart method.

 

How to Use

This notification describes the complete cart. Connectif automatically detects changes and generates the appropriate events when a product is added or removed from the cart.

 

Notify Cart Information

This object represents a complete shopping cart at a specific moment in time and includes the following properties:

Name Required Type Description
cartId Yes String Unique identifier of the cart.
totalQuantity Yes Int Total quantity of products in the cart.
totalPrice Yes Int Total price of the cart.
products Yes Product Basket Item Products in the cart, including their quantity and price.

 

Notify Products via Product Basket Item

This object represents the products, their quantities, and the total price in a shopping cart or purchase.

It includes all properties of the Product object (more info in Notify Product Visited), in addition to the following:

Name Required Type Description
quantity Yes Int Quantity of units of this product.
price Yes Int Total price of the products represented by this Product Basket Item. Usually quantity * unitPrice.

This type of event automatically collects the following information:

  • Operating system: Android or iOS.
  • App version.
  • Operating system version.
  • Connectif SDK version.

 

Other Considerations

It is very important to set a cart identifier (cartId) and notify Connectif when the cart is emptied to prevent abandoned cart events from being triggered.

 

Example

The notification will look like this:

val cart =
Cart(
products = listOf(
ProductBasketItem(
productDetailUrl = "https://example.com/product/12345",
productId = "59a31949a1a562d4979fbca2",
name = "Example Product",
unitPrice = BigDecimal("96.80"),
description = "This is an example product",
imageUrl = "https://example.com/product/images/12345.jpg",
categories = listOf("Electronics", "Gadgets"),
tags = listOf("Trending", "New Arrival"),
brand = "ExampleBrand",
reviewCount = 150,
rating = BigDecimal("4.5"),
ratingCount = 124,
thumbnailUrl = "https://example.com/product/thumbnails/12345.jpg",
unitPriceOriginal = BigDecimal("120.00"),
unitPriceWithoutVAT = BigDecimal("80.00"),
discountedAmount = BigDecimal("23.20"),
discountedPercentage = BigDecimal("19.33"),
publishedAt = Date(),
customField1 = "Special Edition",
customField2 = "Limited Stock",
customField3 = "Online Only",
price = BigDecimal("51.88"),
quantity = 2
)
),
totalQuantity = 2,
totalPrice = BigDecimal("193.60"),
cartId = "cart-0098caf9-42f4-44e9-afdd-45eafe892293",
)
Connectif.sendCart(cart)

 

Callbacks (Optional)

If you want feedback on potential errors when sending events, you can add an EventCallbacks when using our method.

 object : EventCallbacks {
    override fun onSuccess() {
        //Handle success
    }
    override fun onError(message: String?) {
         //Handle error
    }
}

 

 

Congratulations!
You've reached the end of the lesson.

 

Do you still have unresolved questions?
Remember that our Connectif specialists are available to assist you. To contact them, simply open a support ticket by clicking on the blue "Help" button in your dashboard.


Keep Learning!

To fully unlock the potential of your Connectif account, we recommend continuing with the following articles:

Was this article helpful?
0 out of 0 found this helpful