---
title: "Viewed Products"
description: "With the ‘viewed product functionality’, it is possible to gain insight into all products viewed by the customer and the contents of the shopping cart. This is possible with a method that is loading the products in the conversation and display the cart in the panel. If you use this method, you are not dependent on a page load."
canonical: "https://docs.cm.com/mobile-service-cloud/widget-api/viewed-products"
---

# Viewed Products

> With the ‘viewed product functionality’, it is possible to gain insight into all products viewed by the customer and the contents of the shopping cart. This is possible with a method that is loading the products in the conversation and display the cart in the panel. If you use this method, you are not dependent on a page load.

Source: https://docs.cm.com/mobile-service-cloud/widget-api/viewed-products

# Introduction

With the ‘viewed product functionality’, it is possible to gain insight into all products viewed by the customer and the contents of the shopping cart. This is possible with a method that is loading the products in the conversation and display the cart in the panel. If you use this method, you are not dependent on a page load.

# Viewed products

To register a viewed product, the following method should be used.

```javascript
__robin.addViewedProduct(viewedProduct)
```

## Properties

| Name | Description |
| :- | :- |
| id | Product Id or code |
| name | Name of the product |
| url | The URL of the product |
| imageUrl | The URL of the image of product |
| price | The price of the product |
| currency | The currency of the product price |
| availability | Stock description |

```javascript title="Example"
__robin.addViewedProduct({
	id: "p1",
	name: "prod 1",
	description: "product 1",
	url: "http://robinhq.com/",
	imageUrl: "https://cm.com/product-image.jpg",
	price: "1.23",
	currency: "€",
	availability: "Available"
});		
```

# Shopping cart

To publish the complete contents of the shopping cart, the following method should be used. It is important to keep the update the all shopping cart contents and not just the mutations.

```javascript
 __robin.setCartContents(cart)
```

## Properties

| Name | Description |
| :- | :- |
| id | Product Id or code |
| name | Name of the product |
| quantity | The quantity of the product that are placed in the cart |
| unitPrice | The price of the product |
| currency | The currency of the product price |

```javascript title="Example"
__robin.setCartContents ([
	{
		id: "p1",
		name: "prod 1",
		quantity: "1",
		unitPrice: "1.23",
		currency: "€"
	},
	{
		id: "p2",
		name: "prod 2",
		quantity: "2",
		unitPrice: "4.56",
		currency: "€"
	}
]);	
```
