# Cart

> How a cart is rendered by the API: its products, totals, tax rates and checkout page.

- Source: `api/models/Cart.php` <https://github.com/wagnerwagner/merx/blob/2.0.0-alpha.11/api/models/Cart.php>

## Fields

Available in the Cart model, can be fetched with the `select` parameter.

| Name | Return type |
| --- | --- |
| products | `null\|array` |
| shippings | `null\|array` |
| quantity | `int` |
| taxRates | `array` |
| total | `null\|Wagnerwagner\Merx\Price` |
| isFromPrice | `bool` |
| isOrderable | `bool` |
| checkout | `null\|Kirby\Cms\Page` |

## Views

Available in the Cart model, can be fetched with the `view` parameter.

| Name | Fields |
| --- | --- |
| compact | `quantity` |
| default | `products, total<price, priceRaw, priceNet, priceNetRaw>, taxRates, quantity, shippings, isFromPrice, isOrderable, checkout<title, url>` |

## Type

`Wagnerwagner\Merx\Cart`

## Examples

The Cart model of an example cart, in each of its views.

```json title="GET /api/shop/cart"
{
    "checkout": {
        "title": "Checkout",
        "url": "https://shop.test/checkout"
    },
    "isFromPrice": false,
    "isOrderable": true,
    "products": {
        "items": [
            {
                "data": {
                    "size": "42"
                },
                "key": "products/nice-shoes",
                "page": {
                    "template": "product",
                    "url": "https://shop.test/products/nice-shoes",
                    "uuid": "page://Yk4fR7tNq2Lm9VxC"
                },
                "price": {
                    "price": "€89.90",
                    "priceIncludingTax": true,
                    "priceNet": "€75.55",
                    "priceNetRaw": 75.5499999999999971578290569595992565155029296875,
                    "priceRaw": 89.900000000000005684341886080801486968994140625,
                    "tax": {
                        "price": "€14.35",
                        "priceRaw": 14.3499999999999996447286321199499070644378662109375,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "quantity": 1,
                "thumb": null,
                "title": "Nice Shoes",
                "total": {
                    "price": "€89.90",
                    "priceIncludingTax": true,
                    "priceNet": "€75.55",
                    "priceNetRaw": 75.5499999999999971578290569595992565155029296875,
                    "priceRaw": 89.900000000000005684341886080801486968994140625,
                    "tax": {
                        "price": "€14.35",
                        "priceRaw": 14.3499999999999996447286321199499070644378662109375,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "type": "product",
                "url": "https://shop.test/products/nice-shoes"
            },
            {
                "data": null,
                "key": "products/cozy-socks",
                "page": {
                    "template": "product",
                    "url": "https://shop.test/products/cozy-socks",
                    "uuid": "page://bP3wZs8HdE6uJa1Q"
                },
                "price": {
                    "price": "€12.50",
                    "priceIncludingTax": true,
                    "priceNet": "€10.50",
                    "priceNetRaw": 10.5,
                    "priceRaw": 12.5,
                    "tax": {
                        "price": "€2.00",
                        "priceRaw": 2,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "quantity": 2,
                "thumb": null,
                "title": "Cozy Socks",
                "total": {
                    "price": "€25.00",
                    "priceIncludingTax": true,
                    "priceNet": "€21.01",
                    "priceNetRaw": 21.010000000000001563194018672220408916473388671875,
                    "priceRaw": 25,
                    "tax": {
                        "price": "€3.99",
                        "priceRaw": 3.9900000000000002131628207280300557613372802734375,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "type": "product",
                "url": "https://shop.test/products/cozy-socks"
            }
        ],
        "total": {
            "price": "€114.90",
            "priceIncludingTax": true,
            "priceNet": "€96.55",
            "priceNetRaw": 96.5499999999999971578290569595992565155029296875,
            "priceRaw": 114.900000000000005684341886080801486968994140625,
            "tax": {
                "price": "€18.34",
                "priceRaw": 18.339999999999999857891452847979962825775146484375,
                "rate": "19%",
                "rateRaw": 0.190000000000000002220446049250313080847263336181640625
            }
        }
    },
    "quantity": 3,
    "shippings": {
        "items": [
            {
                "data": null,
                "key": "shipping",
                "page": null,
                "price": {
                    "price": "€4.90",
                    "priceIncludingTax": null,
                    "priceNet": "€4.12",
                    "priceNetRaw": 4.12000000000000010658141036401502788066864013671875,
                    "priceRaw": 4.9000000000000003552713678800500929355621337890625,
                    "tax": {
                        "price": "€0.78",
                        "priceRaw": 0.7800000000000000266453525910037569701671600341796875,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "quantity": 1,
                "thumb": null,
                "title": "Shipping",
                "total": {
                    "price": "€4.90",
                    "priceIncludingTax": null,
                    "priceNet": "€4.12",
                    "priceNetRaw": 4.12000000000000010658141036401502788066864013671875,
                    "priceRaw": 4.9000000000000003552713678800500929355621337890625,
                    "tax": {
                        "price": "€0.78",
                        "priceRaw": 0.7800000000000000266453525910037569701671600341796875,
                        "rate": "19%",
                        "rateRaw": 0.190000000000000002220446049250313080847263336181640625
                    }
                },
                "type": "shipping",
                "url": null
            }
        ],
        "total": {
            "price": "€4.90",
            "priceIncludingTax": null,
            "priceNet": "€4.12",
            "priceNetRaw": 4.12000000000000010658141036401502788066864013671875,
            "priceRaw": 4.9000000000000003552713678800500929355621337890625,
            "tax": {
                "price": "€0.78",
                "priceRaw": 0.7800000000000000266453525910037569701671600341796875,
                "rate": "19%",
                "rateRaw": 0.190000000000000002220446049250313080847263336181640625
            }
        }
    },
    "taxRates": [
        {
            "price": "€19.12",
            "priceRaw": 19.120000000000000994759830064140260219573974609375,
            "rate": "19%",
            "rateRaw": 0.190000000000000002220446049250313080847263336181640625
        }
    ],
    "total": {
        "price": "€119.80",
        "priceNet": "€100.67",
        "priceNetRaw": 100.6700000000000017053025658242404460906982421875,
        "priceRaw": 119.7999999999999971578290569595992565155029296875
    }
}
```

```json title="GET /api/shop/cart?view=compact"
{
    "quantity": 3
}
```
