docs: fix details on setting / updating customer ID in cart (#9689)
This commit is contained in:
@@ -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.
|
||||
@@ -53,6 +53,12 @@ The Update Cart API route accepts a `region_id` request body parameter, whose va
|
||||
|
||||
If a guest customer logs in, you must update the cart to be associated with the logged-in customer.
|
||||
|
||||
<Note>
|
||||
|
||||
You can't change the `customer_id` if the cart was associated with a customer previously.
|
||||
|
||||
</Note>
|
||||
|
||||
For example:
|
||||
|
||||
export const updateCustomerHighlights = [
|
||||
|
||||
@@ -152,10 +152,10 @@ export const generatedEditDates = {
|
||||
"app/service-factory-reference/tips/filtering/page.mdx": "2024-07-31T17:01:33+03:00",
|
||||
"app/service-factory-reference/page.mdx": "2024-07-26T14:40:56+00:00",
|
||||
"app/storefront-development/cart/context/page.mdx": "2024-09-11T10:08:05.194Z",
|
||||
"app/storefront-development/cart/create/page.mdx": "2024-09-11T10:08:05.195Z",
|
||||
"app/storefront-development/cart/create/page.mdx": "2024-10-21T07:40:27.947Z",
|
||||
"app/storefront-development/cart/manage-items/page.mdx": "2024-09-11T10:10:54.932Z",
|
||||
"app/storefront-development/cart/retrieve/page.mdx": "2024-09-11T10:12:55.828Z",
|
||||
"app/storefront-development/cart/update/page.mdx": "2024-09-11T10:12:47.704Z",
|
||||
"app/storefront-development/cart/update/page.mdx": "2024-10-21T07:41:21.046Z",
|
||||
"app/storefront-development/cart/page.mdx": "2024-06-11T11:56:37+03:00",
|
||||
"app/storefront-development/checkout/address/page.mdx": "2024-09-11T09:40:02.899Z",
|
||||
"app/storefront-development/checkout/complete-cart/page.mdx": "2024-09-11T09:40:48.531Z",
|
||||
|
||||
Reference in New Issue
Block a user