Skip to content

Commit f7932f1

Browse files
authored
docs: fix details on setting / updating customer ID in cart (#9689)
1 parent a1190b7 commit f7932f1

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

www/apps/resources/app/storefront-development/cart/create/page.mdx

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -117,24 +117,8 @@ This is necessary, as only products matching the cart's sales channel(s) can be
117117

118118
## Associate Customer with Cart
119119

120-
When creating the cart, you can associate the logged-in customer's ID with the cart by passing a `customer_id` request body parameter.
120+
When the cart is created for a logged-in customer, it's automatically associated with that customer.
121121

122-
For example:
123-
124-
export const customerHighlights = [
125-
["5", "customer.id", "Assuming you have the customer object."]
126-
]
122+
If the customer is a guest, then later logs in, you can set their ID on the cart by updating it.
127123

128-
```ts highlights={customerHighlights}
129-
fetch(`http://localhost:9000/store/carts`, {
130-
// ...
131-
body: JSON.stringify({
132-
// ...
133-
customer_id: customer.id,
134-
}),
135-
})
136-
.then((res) => res.json())
137-
.then(({ cart }) => {
138-
localStorage.setItem("cart_id", cart.id)
139-
})
140-
```
124+
Refer to [this documentation](../update/page.mdx#update-carts-customer) to learn how to set the customer of a cart.

www/apps/resources/app/storefront-development/cart/update/page.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@ The Update Cart API route accepts a `region_id` request body parameter, whose va
5353

5454
If a guest customer logs in, you must update the cart to be associated with the logged-in customer.
5555

56+
<Note>
57+
58+
You can't change the `customer_id` if the cart was associated with a customer previously.
59+
60+
</Note>
61+
5662
For example:
5763

5864
export const updateCustomerHighlights = [

www/apps/resources/generated/edit-dates.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ export const generatedEditDates = {
152152
"app/service-factory-reference/tips/filtering/page.mdx": "2024-07-31T17:01:33+03:00",
153153
"app/service-factory-reference/page.mdx": "2024-07-26T14:40:56+00:00",
154154
"app/storefront-development/cart/context/page.mdx": "2024-09-11T10:08:05.194Z",
155-
"app/storefront-development/cart/create/page.mdx": "2024-09-11T10:08:05.195Z",
155+
"app/storefront-development/cart/create/page.mdx": "2024-10-21T07:40:27.947Z",
156156
"app/storefront-development/cart/manage-items/page.mdx": "2024-09-11T10:10:54.932Z",
157157
"app/storefront-development/cart/retrieve/page.mdx": "2024-09-11T10:12:55.828Z",
158-
"app/storefront-development/cart/update/page.mdx": "2024-09-11T10:12:47.704Z",
158+
"app/storefront-development/cart/update/page.mdx": "2024-10-21T07:41:21.046Z",
159159
"app/storefront-development/cart/page.mdx": "2024-06-11T11:56:37+03:00",
160160
"app/storefront-development/checkout/address/page.mdx": "2024-09-11T09:40:02.899Z",
161161
"app/storefront-development/checkout/complete-cart/page.mdx": "2024-09-11T09:40:48.531Z",

0 commit comments

Comments
 (0)