The "Notify cart information" event is used to describe the shopping cart that the contact has at a given time. It notifies, via Mobile SDK, the products and the cart status of a contact using the Connectif.sendCart method.
How to use it
This notification describes the complete cart. Connectif is responsible for detecting changes and generating the appropriate events when a product is added 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 | Mandatory | Type | Description |
---|---|---|---|
cartId | Yes | String | Unique identifier of the cart. |
totalQuantity | Yes | Int | Total number of products in the cart. |
totalPrice | Yes | Int | Total price of the cart. |
products | Yes | Product Basket Item | Items contained in the cart, along with their quantity and price. |
Notify products using Product Basket Item
This object represents the products, their quantity, and the total price in a shopping cart or a purchase. It includes all the properties of the Product object type (more information in Notify product visited event), along with the following:
Name | Mandatory | Type | Description |
---|---|---|---|
quantity | Yes | Int | Number of units of this product. |
price | Yes | Int | Total price of the products represented by this Product Basket Item. It is usually quantity * unitPrice . |
Other considerations
It is very important to establish 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:
let productBasketItem = ProductBasketItem( productDetailUrl: "https://example.com/product/12345", productId: "59a31949a1a562d4979fbca2", name: "Example Product", unitPrice: Decimal(51.88), description: "This is an example product", imageUrl: "https://example.com/product/images/12345.jpg", availability: "instock", categories: ["Electronics", "Gadgets"], tags: ["Trending", "New Arrival"], brand: "ExampleBrand", reviewCount: 150, rating: Decimal(4.5), ratingCount: 124, thumbnailUrl: "https://example.com/product/thumbnails/12345.jpg", relatedExternalProductIds: ["54321", "67890"], priority: 10, unitPriceOriginal: Decimal(120.00), unitPriceWithoutVAT: Decimal(80.00), discountedAmount: Decimal(20.00), discountedPercentage: Decimal(16.67), publishedAt: Date(), customField1: "Special Edition", customField2: "Limited Stock", customField3: "Online Only", price: Decimal(51.88), quantity: 1 ) let cart = Cart( products: [productBasketItem], totalQuantity: 1, totalPrice: Decimal(51.88), cartId: "cart-0098caf9-42f4-44e9-afdd-45eafe892293" ) Connectif.sendCart(cart)
Callbacks (Opcional)
Si queremos tener feedback de posibles errores al enviar eventos, podremos añadir un EventCallbacks cuando usemos nuestro método.
EventCallbacks( onSuccess: { // Manejo en caso de éxito }, onError: { error in // Manejo en caso de error })
Keep Learning!
To fully unlock the potential of your Connectif account, we recommend continuing with the following articles:
- Android SDK Get Started, to add Connectif Mobile SDK to your Android project.
- Firebase Cloud Messaging Setup, to enable push sending and receiving via the Android Mobile SDK.
- iOS SDK Get Started, to add Connectif Mobile SDK to your iOS project.
- Apple Push Notifications Service Setup, to enable push sending and receiving via the iOS Mobile SDK.