@redotech/redo-hydrogen 1.4.2 → 1.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/CODEOWNERS +1 -0
- package/CHANGELOG.md +4 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/cart.ts +15 -4
package/package.json
CHANGED
package/src/utils/cart.ts
CHANGED
|
@@ -215,17 +215,28 @@ const setCartRedoEnabledAttribute = async ({
|
|
|
215
215
|
value: enabled.toString()
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
const existingAttributes = cart?.attributes || [];
|
|
219
|
+
|
|
220
|
+
const existingAttributesMap = new Map(
|
|
221
|
+
existingAttributes.map(attr => [attr.key, attr.value])
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
existingAttributesMap.set(redoCartAttribute.key, redoCartAttribute.value);
|
|
225
|
+
|
|
226
|
+
const updatedAttributes = Array.from(existingAttributesMap.entries()).map(([key, value]) => ({
|
|
227
|
+
key,
|
|
228
|
+
value: value ?? ""
|
|
229
|
+
}));
|
|
230
|
+
|
|
218
231
|
const formInput = {
|
|
219
232
|
action: CartForm.ACTIONS.AttributesUpdateInput,
|
|
220
233
|
inputs: {
|
|
221
|
-
attributes:
|
|
222
|
-
redoCartAttribute
|
|
223
|
-
]
|
|
234
|
+
attributes: updatedAttributes
|
|
224
235
|
}
|
|
225
236
|
}
|
|
226
237
|
|
|
227
238
|
if(cart && isCartWithActionsDocs(cart)) {
|
|
228
|
-
cart.cartAttributesUpdate(
|
|
239
|
+
cart.cartAttributesUpdate(updatedAttributes);
|
|
229
240
|
await waitCartIdle();
|
|
230
241
|
} else {
|
|
231
242
|
await fetcher.submit(
|