@shoppexio/storefront 0.3.0 → 0.3.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/CHANGELOG.md +5 -0
- package/README.md +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ const result = await shoppex.validateCoupon('SAVE10', {
|
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Calling `validateCoupon(code)` without options validates against the current SDK cart. Affiliate/referral codes are separate and should use `validateAffiliateCode` or `applyAffiliateCode`.
|
|
45
|
+
Calling `validateCoupon(code)` without options validates against the current SDK cart. Affiliate/referral codes are separate and should use `validateAffiliateCode` or `applyAffiliateCode`. If `program_enabled` is false in an affiliate validation response, the shop-level affiliate program is disabled even if individual links exist.
|
|
46
46
|
|
|
47
47
|
## Not this package
|
|
48
48
|
|
package/dist/index.cjs
CHANGED
|
@@ -8732,12 +8732,13 @@ function mapApiResponse(apiResponse) {
|
|
|
8732
8732
|
if (apiResponse.status >= 200 && apiResponse.status < 300) {
|
|
8733
8733
|
return {
|
|
8734
8734
|
success: true,
|
|
8735
|
-
data: apiResponse.data
|
|
8735
|
+
data: apiResponse.data,
|
|
8736
|
+
...apiResponse.message ? { message: apiResponse.message } : {}
|
|
8736
8737
|
};
|
|
8737
8738
|
}
|
|
8738
8739
|
return {
|
|
8739
8740
|
success: false,
|
|
8740
|
-
message: apiResponse.error ?? `Request failed with status ${apiResponse.status}`
|
|
8741
|
+
message: apiResponse.error ?? apiResponse.message ?? `Request failed with status ${apiResponse.status}`
|
|
8741
8742
|
};
|
|
8742
8743
|
}
|
|
8743
8744
|
async function get(endpoint, options) {
|
|
@@ -9499,21 +9500,24 @@ async function validateAffiliateCode(code) {
|
|
|
9499
9500
|
return response;
|
|
9500
9501
|
}
|
|
9501
9502
|
if (!response.data?.valid || !response.data.affiliate_code) {
|
|
9503
|
+
const programDisabled = response.data?.program_enabled === false;
|
|
9502
9504
|
return {
|
|
9503
9505
|
success: false,
|
|
9504
9506
|
data: {
|
|
9505
9507
|
valid: false,
|
|
9508
|
+
...response.data?.program_enabled !== void 0 ? { program_enabled: response.data.program_enabled } : {},
|
|
9506
9509
|
affiliate_code: null,
|
|
9507
9510
|
discount_active: false,
|
|
9508
9511
|
discount_percent: 0
|
|
9509
9512
|
},
|
|
9510
|
-
message: "Invalid affiliate code."
|
|
9513
|
+
message: response.message ?? (programDisabled ? "Affiliate program is disabled for this shop." : "Invalid affiliate code.")
|
|
9511
9514
|
};
|
|
9512
9515
|
}
|
|
9513
9516
|
return {
|
|
9514
9517
|
success: true,
|
|
9515
9518
|
data: {
|
|
9516
9519
|
valid: true,
|
|
9520
|
+
...response.data.program_enabled !== void 0 ? { program_enabled: response.data.program_enabled } : {},
|
|
9517
9521
|
affiliate_code: normalizeAffiliateCode(response.data.affiliate_code),
|
|
9518
9522
|
discount_active: Boolean(response.data.discount_active),
|
|
9519
9523
|
discount_percent: Number(response.data.discount_percent ?? 0)
|