Cart
The user needs to be authenticated to perform Cart
operations, either with a regular user account or with an AnonymousSession
(see Authentication).
Add Product
Adding a product into the cart requires a Product
and an AccessMode
which represents a mode of access (subscription, rent, purchase, ...), as well as quality and other properties at a set price.
First of all, let's retrieve a Product
and its AccessModes
.
query Products {
cms {
products (includeIds: [1]) {
items {
id
name
type
extension {
... on ProductTVOD {
accessModes {
id
type
mode
quality
duration
priceFormat
}
}
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
In the response, we can see that the Product is accessible if we have an active Subscription
, otherwise it ca be rented for a month for streaming, download or both.
{
"data": {
"cms": {
"products": {
"items": [
{
"id": "1",
"name": "The line",
"type": "TVOD",
"extension": {
"accessModes": [
{
"id": "64",
"type": "SUBSCRIPTION",
"mode": "ALL",
"quality": "ALL",
"duration": null,
"priceFormat": null
},
{
"id": "2",
"type": "RENT",
"mode": "STREAMING",
"quality": "ALL",
"duration": 31,
"priceFormat": "$3.83"
},
{
"id": "3",
"type": "RENT",
"mode": "DOWNLOAD",
"quality": "ALL",
"duration": 31,
"priceFormat": "$4.75"
},
{
"id": "1",
"type": "RENT",
"mode": "ALL",
"quality": "ALL",
"duration": 31,
"priceFormat": "$6.57"
}
]
}
}
]
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Assuming that the user wants to rent the movie for a month with streaming access only (accessMode: 2), you would perform the following mutation :
mutation AddProductToCart {
addProductToCart (product: 1, accessMode: 2) {
...CartFragment
}
}
fragment CartFragment on Cart {
totalPrice
totalPriceWithoutTax
content {
pagination {
total
}
items {
accessMode {
id
priceFormat
... on TVODAccessMode {
type
mode
quality
duration
}
}
product {
id
name
type
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"data": {
"addProductToCart": {
"totalPrice": 3.5,
"totalPriceWithoutTax": 3.5,
"content": {
"pagination": {
"total": 1
},
"items": [
{
"accessMode": {
"id": "2",
"priceFormat": "€3.50",
"type": "RENT",
"mode": "STREAMING",
"quality": "ALL",
"duration": 31
},
"product": {
"id": "1",
"name": "The line",
"type": "TVOD"
}
}
]
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
SVOD / TVOD
SVOD and TVOD Products cannot exist in the same Cart due to their different checkout process.
When adding a SVOD Product into a cart containing TVOD Products, the cart will be emptied first before the action is performed (same goes for the other way around).
Product Ownership
When adding a Product already owned by the user to the cart, you will see the following error:
{
"errors": [
{
"message": "This customer already has an access for this product",
"locations": [
{
"line": 37,
"column": 3
}
],
"path": [
"addProductToCart"
],
"extensions": {
"code": "BAD_USER_INPUT"
}
}
],
"data": null
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
To check if the user already has access to a ProductTVOD
, see here. To check if a user already owns an active ProductSVOD
see here.
Remove Product
The removeProductFromCart
mutation removes a product from the cart.
mutation RemoveProductFromCart {
removeProductFromCart (product: 1, accessMode: 2) {
...CartFragment
}
}
1
2
3
4
5
{
"data": {
"removeProductFromCart": {
"totalPrice": 0,
"totalPriceWithoutTax": 0,
"content": {
"pagination": {
"total": 0
},
"items": []
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Alternatively, you can reset the whole cart using the resetCart
mutation.
mutation ResetCart {
resetCart {
...CartFragment
}
}
1
2
3
4
5
{
"data": {
"resetCart": {
"totalPrice": 0,
"totalPriceWithoutTax": 0,
"content": {
"pagination": {
"total": 0
},
"items": []
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Vouchers
To apply vouchers to a Cart, use the addCartVoucher
mutation.
mutation AddCartVoucher {
addCartVoucher (code: "R172KKIP7NAW") {
...CartFragment
}
}
1
2
3
4
5
6
{
"data": {
"addCartVoucher": {
"totalPrice": 1.75,
"totalPriceWithoutTax": 1.75,
"vouchers": [
{
"name": "Welcome Voucher",
"code": "R172KKIP7NAW",
"reductionAmount": 0,
"reductionPercent": 50,
"everyRecurringPayments": false
}
],
"content": {
"pagination": {
"total": 1
},
"items": [
{
"accessMode": {
"id": "2",
"priceFormat": "€3.50",
"type": "RENT",
"mode": "STREAMING",
"quality": "ALL",
"duration": 31
},
"product": {
"id": "1",
"name": "The line",
"type": "TVOD"
}
}
]
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39