Android Mobile SDK: Notify Cart Information

Android Mobile SDK: Notify Cart Information

The “Notify Cart Information” event is used to describe the shopping cart that the contact has at a given time. To do this, it notifies Connectif of a contact's products and cart status via the Mobile SDK using the Connectif.sendCart method.

 

How to use it

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

 

Notify the shopping cart

This object represents a complete shopping cart at a specific point in time. It includes the following properties:

Name Required Type Description
cartId Yes String Unique cart identifier.
totalQuantity Yes Int Total quantity of products in the cart.
totalPrice Yes Int Total cart price.
products Yes Product Basket Item Items contained in the cart, together with their quantity and amount.
cartRecoveryUrl No Cart recovery URL URL associated with the cart from which its contents can be recovered. It must be a valid URL and cannot exceed 1,000 characters.

 

Notify products using Product Basket Item

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

It includes all the properties of the Product object type (more info in Notify Product Viewed Event), as well as the following:

Name Required Type Description
quantity Yes Int Number of units of this product.
price Yes Int Cumulative price of the products represented by this Product Basket Item. It is usually quantity * unitPrice.

This event type 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 also notify Connectif when the cart is emptied to prevent abandoned cart events from being generated.

 

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 about possible errors when sending events, you can add an EventCallbacks when using our method.  

 object : EventCallbacks {
    override fun onSuccess() {
        //Handling in case of success
    }
    override fun onError(message: String?) {
         //Handling in case of error
    }
}

 

 

Congratulations!
You have reached the end of the lesson.

  

Do you still have unanswered questions?
Remember that our Connectif specialists are available to help you. To contact them, simply open a ticket with Support by clicking the blue “Help” button in your dashboard.


Keep learning!

To take full advantage of your Connectif account, we recommend continuing with the following articles: