@shoppexio/storefront 1.0.79 → 1.0.80

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.js CHANGED
@@ -4121,8 +4121,7 @@ async function captureAffiliateFromUrl(param = "ref") {
4121
4121
  if (!code) return null;
4122
4122
  const held = getStoredAffiliate();
4123
4123
  const holdsOtherCode = held !== null && held.code !== code;
4124
- const mayHoldFirstClick = holdsOtherCode && held.mode === "FIRST_CLICK";
4125
- if (!mayHoldFirstClick) {
4124
+ if (!holdsOtherCode) {
4126
4125
  setAffiliateCode(code, held?.windowDays ?? DEFAULT_TTL_DAYS, held?.mode);
4127
4126
  }
4128
4127
  if (isInitialized()) {
@@ -4145,14 +4144,12 @@ async function captureAffiliateFromUrl(param = "ref") {
4145
4144
  const heldMode = res.success && res.data?.held_attribution_mode ? normalizeMode(res.data.held_attribution_mode) : null;
4146
4145
  const holdsFirstClick = holdsOtherCode && (heldMode ?? held?.mode) === "FIRST_CLICK";
4147
4146
  if (holdsFirstClick && held) {
4148
- if (!mayHoldFirstClick) {
4149
- restoreStoredAffiliate({
4150
- code: held.code,
4151
- expiresAt: held.expiresAt,
4152
- windowDays: held.windowDays,
4153
- mode: heldMode ?? "FIRST_CLICK"
4154
- });
4155
- }
4147
+ restoreStoredAffiliate({
4148
+ code: held.code,
4149
+ expiresAt: held.expiresAt,
4150
+ windowDays: held.windowDays,
4151
+ mode: heldMode ?? held.mode
4152
+ });
4156
4153
  return held.code;
4157
4154
  }
4158
4155
  if (res.success && res.data?.accepted && res.data.affiliate_code) {
@@ -4160,15 +4157,16 @@ async function captureAffiliateFromUrl(param = "ref") {
4160
4157
  return res.data.affiliate_code;
4161
4158
  }
4162
4159
  if (res.success && res.data && res.data.accepted === false) {
4160
+ if (holdsOtherCode) return held.code;
4163
4161
  clearAffiliateCode();
4164
4162
  return null;
4165
4163
  }
4166
- return mayHoldFirstClick ? held.code : code;
4164
+ return holdsOtherCode ? held.code : code;
4167
4165
  } catch {
4168
- return mayHoldFirstClick ? held.code : code;
4166
+ return holdsOtherCode ? held.code : code;
4169
4167
  }
4170
4168
  }
4171
- return mayHoldFirstClick ? held.code : code;
4169
+ return holdsOtherCode ? held.code : code;
4172
4170
  }
4173
4171
 
4174
4172
  // ../sdk/src/utils/cart-line-id.ts