feeef 0.12.5 → 0.12.6
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/build/index.js
CHANGED
|
@@ -3123,21 +3123,30 @@ function shouldSuppressPixelEvents(order) {
|
|
|
3123
3123
|
}
|
|
3124
3124
|
|
|
3125
3125
|
// src/core/entities/product_offer_policy.ts
|
|
3126
|
+
function readForceOffer(product) {
|
|
3127
|
+
return product.forceOffer === true || product.force_offer === true;
|
|
3128
|
+
}
|
|
3129
|
+
function readDefaultOfferCode(product) {
|
|
3130
|
+
const code = product.defaultOfferCode ?? product.default_offer_code;
|
|
3131
|
+
if (typeof code !== "string") return null;
|
|
3132
|
+
const trimmed = code.trim();
|
|
3133
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
3134
|
+
}
|
|
3126
3135
|
function syncDefaultOfferCode(offers, defaultOfferCode) {
|
|
3127
3136
|
if (!defaultOfferCode || !offers?.length) return null;
|
|
3128
3137
|
return offers.some((o) => o.code === defaultOfferCode) ? defaultOfferCode : null;
|
|
3129
3138
|
}
|
|
3130
3139
|
function resolveInitialProductOffer(product) {
|
|
3131
|
-
const code = syncDefaultOfferCode(product.offers, product
|
|
3140
|
+
const code = syncDefaultOfferCode(product.offers, readDefaultOfferCode(product));
|
|
3132
3141
|
if (!code || !product.offers?.length) return void 0;
|
|
3133
3142
|
return product.offers.find((o) => o.code === code);
|
|
3134
3143
|
}
|
|
3135
3144
|
function isProductOfferRequired(product) {
|
|
3136
|
-
return product
|
|
3145
|
+
return readForceOffer(product);
|
|
3137
3146
|
}
|
|
3138
3147
|
function isProductOfferLocked(product) {
|
|
3139
|
-
if (product
|
|
3140
|
-
return syncDefaultOfferCode(product.offers, product
|
|
3148
|
+
if (!readForceOffer(product)) return false;
|
|
3149
|
+
return syncDefaultOfferCode(product.offers, readDefaultOfferCode(product)) !== null;
|
|
3141
3150
|
}
|
|
3142
3151
|
function resolveForcedProductOffer(product) {
|
|
3143
3152
|
if (!isProductOfferLocked(product)) return void 0;
|