@lime-bundles/widget 4.6.0 → 4.6.1
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/dist/index.cjs +14 -4
- package/dist/index.js +14 -4
- package/dist/lime-bundle.global.js +13 -13
- package/dist/lime-bundle.global.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,8 @@ function intlFormatMoney(currencyCode) {
|
|
|
43
43
|
}
|
|
44
44
|
var BUNDLE_GID_ATTRIBUTE = "_lime_bundle_gid";
|
|
45
45
|
var BUNDLE_TYPE_ATTRIBUTE = "_lime_bundle_type";
|
|
46
|
+
var BUNDLE_ROLE_ATTRIBUTE = "_lime_bundle_role";
|
|
47
|
+
var BUNDLE_ROLE_GET = "get";
|
|
46
48
|
function bundleLineAttributes(bundleGid, bundleType) {
|
|
47
49
|
return [
|
|
48
50
|
{ key: BUNDLE_GID_ATTRIBUTE, value: bundleGid },
|
|
@@ -3170,7 +3172,8 @@ function buildBogoCartItems(sides, percent, buyQty, getQty) {
|
|
|
3170
3172
|
{
|
|
3171
3173
|
variantId: Number(sides[1].selectedVariantId),
|
|
3172
3174
|
quantity: getQty,
|
|
3173
|
-
priceCents: getPriceCents
|
|
3175
|
+
priceCents: getPriceCents,
|
|
3176
|
+
attributes: [{ key: BUNDLE_ROLE_ATTRIBUTE, value: BUNDLE_ROLE_GET }]
|
|
3174
3177
|
}
|
|
3175
3178
|
];
|
|
3176
3179
|
}
|
|
@@ -3195,18 +3198,20 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3195
3198
|
productQuantities: bundle.productQuantities,
|
|
3196
3199
|
variantQuantities: bundle.variantQuantities
|
|
3197
3200
|
};
|
|
3201
|
+
const buyAllowed = bundle.buyVariantIds?.length ? bundle.buyVariantIds : null;
|
|
3202
|
+
const getAllowed = bundle.getVariantIds?.length ? bundle.getVariantIds : null;
|
|
3198
3203
|
const sides = [
|
|
3199
3204
|
{
|
|
3200
3205
|
...adaptProduct(buyProduct, bundle.id, {
|
|
3201
3206
|
quantities,
|
|
3202
|
-
allowedVariantIds:
|
|
3207
|
+
allowedVariantIds: buyAllowed
|
|
3203
3208
|
}),
|
|
3204
3209
|
role: "buy"
|
|
3205
3210
|
},
|
|
3206
3211
|
{
|
|
3207
3212
|
...adaptProduct(getProduct, bundle.id, {
|
|
3208
3213
|
quantities,
|
|
3209
|
-
allowedVariantIds:
|
|
3214
|
+
allowedVariantIds: getAllowed
|
|
3210
3215
|
}),
|
|
3211
3216
|
role: "get"
|
|
3212
3217
|
}
|
|
@@ -3268,7 +3273,12 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3268
3273
|
buildBogoCartItems(sides, percent, buyQty, getQty).map((item) => ({
|
|
3269
3274
|
merchandiseId: "gid://shopify/ProductVariant/" + item.variantId,
|
|
3270
3275
|
quantity: item.quantity,
|
|
3271
|
-
|
|
3276
|
+
// Per-line extras (the reward marker) on top of the attribution
|
|
3277
|
+
// every line carries.
|
|
3278
|
+
attributes: [
|
|
3279
|
+
...bundleLineAttributes(bundle.id, bundle.bundleType),
|
|
3280
|
+
...item.attributes ?? []
|
|
3281
|
+
]
|
|
3272
3282
|
}))
|
|
3273
3283
|
);
|
|
3274
3284
|
});
|
package/dist/index.js
CHANGED
|
@@ -37,6 +37,8 @@ function intlFormatMoney(currencyCode) {
|
|
|
37
37
|
}
|
|
38
38
|
var BUNDLE_GID_ATTRIBUTE = "_lime_bundle_gid";
|
|
39
39
|
var BUNDLE_TYPE_ATTRIBUTE = "_lime_bundle_type";
|
|
40
|
+
var BUNDLE_ROLE_ATTRIBUTE = "_lime_bundle_role";
|
|
41
|
+
var BUNDLE_ROLE_GET = "get";
|
|
40
42
|
function bundleLineAttributes(bundleGid, bundleType) {
|
|
41
43
|
return [
|
|
42
44
|
{ key: BUNDLE_GID_ATTRIBUTE, value: bundleGid },
|
|
@@ -3176,7 +3178,8 @@ function buildBogoCartItems(sides, percent, buyQty, getQty) {
|
|
|
3176
3178
|
{
|
|
3177
3179
|
variantId: Number(sides[1].selectedVariantId),
|
|
3178
3180
|
quantity: getQty,
|
|
3179
|
-
priceCents: getPriceCents
|
|
3181
|
+
priceCents: getPriceCents,
|
|
3182
|
+
attributes: [{ key: BUNDLE_ROLE_ATTRIBUTE, value: BUNDLE_ROLE_GET }]
|
|
3180
3183
|
}
|
|
3181
3184
|
];
|
|
3182
3185
|
}
|
|
@@ -3201,18 +3204,20 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3201
3204
|
productQuantities: bundle.productQuantities,
|
|
3202
3205
|
variantQuantities: bundle.variantQuantities
|
|
3203
3206
|
};
|
|
3207
|
+
const buyAllowed = bundle.buyVariantIds?.length ? bundle.buyVariantIds : null;
|
|
3208
|
+
const getAllowed = bundle.getVariantIds?.length ? bundle.getVariantIds : null;
|
|
3204
3209
|
const sides = [
|
|
3205
3210
|
{
|
|
3206
3211
|
...adaptProduct(buyProduct, bundle.id, {
|
|
3207
3212
|
quantities,
|
|
3208
|
-
allowedVariantIds:
|
|
3213
|
+
allowedVariantIds: buyAllowed
|
|
3209
3214
|
}),
|
|
3210
3215
|
role: "buy"
|
|
3211
3216
|
},
|
|
3212
3217
|
{
|
|
3213
3218
|
...adaptProduct(getProduct, bundle.id, {
|
|
3214
3219
|
quantities,
|
|
3215
|
-
allowedVariantIds:
|
|
3220
|
+
allowedVariantIds: getAllowed
|
|
3216
3221
|
}),
|
|
3217
3222
|
role: "get"
|
|
3218
3223
|
}
|
|
@@ -3274,7 +3279,12 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3274
3279
|
buildBogoCartItems(sides, percent, buyQty, getQty).map((item) => ({
|
|
3275
3280
|
merchandiseId: "gid://shopify/ProductVariant/" + item.variantId,
|
|
3276
3281
|
quantity: item.quantity,
|
|
3277
|
-
|
|
3282
|
+
// Per-line extras (the reward marker) on top of the attribution
|
|
3283
|
+
// every line carries.
|
|
3284
|
+
attributes: [
|
|
3285
|
+
...bundleLineAttributes(bundle.id, bundle.bundleType),
|
|
3286
|
+
...item.attributes ?? []
|
|
3287
|
+
]
|
|
3278
3288
|
}))
|
|
3279
3289
|
);
|
|
3280
3290
|
});
|