docs: fix details on setting / updating customer ID in cart (#9689)

This commit is contained in:
Shahed Nasser
2024-10-22 20:40:39 +03:00
committed by GitHub
parent a1190b7208
commit f7932f11ed
3 changed files with 11 additions and 21 deletions
@@ -117,24 +117,8 @@ This is necessary, as only products matching the cart's sales channel(s) can be
## Associate Customer with Cart
When creating the cart, you can associate the logged-in customer's ID with the cart by passing a `customer_id` request body parameter.
When the cart is created for a logged-in customer, it's automatically associated with that customer.
For example:
If the customer is a guest, then later logs in, you can set their ID on the cart by updating it.
export const customerHighlights = [
["5", "customer.id", "Assuming you have the customer object."]
]
```ts highlights={customerHighlights}
fetch(`http://localhost:9000/store/carts`, {
// ...
body: JSON.stringify({
// ...
customer_id: customer.id,
}),
})
.then((res) => res.json())
.then(({ cart }) => {
localStorage.setItem("cart_id", cart.id)
})
```
Refer to [this documentation](../update/page.mdx#update-carts-customer) to learn how to set the customer of a cart.