@betterstore/react 0.1.9 → 0.1.10
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/CHANGELOG.md +6 -0
- package/dist/index.cjs.js +7 -1
- package/dist/index.mjs +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -207,7 +207,13 @@ const useCart = zustand.create()(persist((set, get) => ({
|
|
|
207
207
|
addItem: (product, additionalParams) => set((state) => {
|
|
208
208
|
var _a, _b;
|
|
209
209
|
const productId = typeof product === "string" ? product : product === null || product === void 0 ? void 0 : product.id;
|
|
210
|
-
const formattedNewItem =
|
|
210
|
+
const formattedNewItem = {
|
|
211
|
+
productId: productId,
|
|
212
|
+
product: typeof product !== "string" ? product : undefined,
|
|
213
|
+
quantity: (_a = additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.quantity) !== null && _a !== void 0 ? _a : 1,
|
|
214
|
+
variantOptions: (_b = additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.variantOptions) !== null && _b !== void 0 ? _b : [],
|
|
215
|
+
metadata: additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.metadata,
|
|
216
|
+
};
|
|
211
217
|
const id = generateLineItemId(formattedNewItem);
|
|
212
218
|
const existingItemIndex = state.lineItems.findIndex((item) => item.id === id);
|
|
213
219
|
if (existingItemIndex !== -1) {
|
package/dist/index.mjs
CHANGED
|
@@ -205,7 +205,13 @@ const useCart = create()(persist((set, get) => ({
|
|
|
205
205
|
addItem: (product, additionalParams) => set((state) => {
|
|
206
206
|
var _a, _b;
|
|
207
207
|
const productId = typeof product === "string" ? product : product === null || product === void 0 ? void 0 : product.id;
|
|
208
|
-
const formattedNewItem =
|
|
208
|
+
const formattedNewItem = {
|
|
209
|
+
productId: productId,
|
|
210
|
+
product: typeof product !== "string" ? product : undefined,
|
|
211
|
+
quantity: (_a = additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.quantity) !== null && _a !== void 0 ? _a : 1,
|
|
212
|
+
variantOptions: (_b = additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.variantOptions) !== null && _b !== void 0 ? _b : [],
|
|
213
|
+
metadata: additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.metadata,
|
|
214
|
+
};
|
|
209
215
|
const id = generateLineItemId(formattedNewItem);
|
|
210
216
|
const existingItemIndex = state.lineItems.findIndex((item) => item.id === id);
|
|
211
217
|
if (existingItemIndex !== -1) {
|