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 authored and GitHub committed 2022-10-13 12:59:08 +03:00
1 parent 4013c0c5da
commit 60cd94fd60
1 file changed
+12
+12
View File
@@ -1,3 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# How to Add Cart Functionality # 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. 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 cart’s data: You can use the following snippet to update any of the cart’s data:
<Tabs groupId="request-type">
<TabItem value="client" label="Medusa JS Client" default>
```jsx ```jsx
medusa.carts.update(cartId, { medusa.carts.update(cartId, {
region_id region_id
@@ -175,6 +181,9 @@ medusa.carts.update(cartId, {
.then(({ cart }) => setCart(cart)); .then(({ cart }) => setCart(cart));
``` ```
</TabItem>
<TabItem value="fetch" label="Fetch API">
```jsx ```jsx
fetch(`<SERVER_URL>/store/carts/${cartId}`, { fetch(`<SERVER_URL>/store/carts/${cartId}`, {
method: 'POST', method: 'POST',
@@ -189,6 +198,9 @@ fetch(`<SERVER_URL>/store/carts/${cartId}`, {
.then(({ cart }) => setCart(cart)); .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. 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. It returns the updated cart.