@redotech/redo-hydrogen 1.4.1 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redotech/redo-hydrogen",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "Utilities to enable and disable Redo coverage on Hydrogen stores",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -17,10 +17,10 @@
17
17
  "url": "https://github.com/redoapp/redo-hydrogen/issues"
18
18
  },
19
19
  "peerDependencies": {
20
- "@remix-run/react": "^2.15.2",
21
- "@shopify/hydrogen": "^2024.10.1",
20
+ "@remix-run/react": "^2.8.0",
21
+ "@shopify/hydrogen": ">=2024.3.1",
22
22
  "@shopify/hydrogen-react": ">=2024.3.1",
23
- "react-dom": "~18.3.1"
23
+ "react-dom": "^18.3.1"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@rollup/plugin-commonjs": "^28.0.2",
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([redoCartAttribute]);
239
+ cart.cartAttributesUpdate(updatedAttributes);
229
240
  await waitCartIdle();
230
241
  } else {
231
242
  await fetcher.submit(