docs: added missing import for add cart functionality documentation (#2425)

* Add missing import for add cart functionality file

* Added the Tab section to the Update Cart section

* Removed unnecessary spaces
This commit is contained in:
Zainab Lawal
2022-10-13 12:59:08 +03:00
committed by GitHub
parent 4013c0c5da
commit 60cd94fd60

View File

@@ -1,3 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# How to Add Cart Functionality
This document guides you through how you can add cart-related functionalities to your storefront. That includes creating and updating a cart and managing items in the cart.
@@ -168,6 +171,9 @@ A cart has different data associated with it including the region, email, addres
You can use the following snippet to update any of the carts data:
<Tabs groupId="request-type">
<TabItem value="client" label="Medusa JS Client" default>
```jsx
medusa.carts.update(cartId, {
region_id
@@ -175,6 +181,9 @@ medusa.carts.update(cartId, {
.then(({ cart }) => setCart(cart));
```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}`, {
method: 'POST',
@@ -189,6 +198,9 @@ fetch(`<SERVER_URL>/store/carts/${cartId}`, {
.then(({ cart }) => setCart(cart));
```
</TabItem>
</Tabs>
This request accepts the ID of the cart as a path parameter. In its body, you can pass any data you want to update in the cart such as the region.
It returns the updated cart.