@wtree/payload-ecommerce-coupon 3.77.7 → 3.77.8
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/client/hooks.d.ts +1 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/index.d.ts +8 -8
- package/dist/client/index.d.ts.map +1 -1
- package/dist/collections/createCouponsCollection.d.ts +2 -2
- package/dist/collections/createCouponsCollection.d.ts.map +1 -1
- package/dist/collections/createReferralCodesCollection.d.ts +2 -2
- package/dist/collections/createReferralCodesCollection.d.ts.map +1 -1
- package/dist/collections/createReferralProgramsCollection.d.ts +2 -2
- package/dist/collections/createReferralProgramsCollection.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/CommissionBreakdown.d.ts +2 -2
- package/dist/components/PartnerDashboard/CommissionBreakdown.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/EarningsSummary.d.ts +2 -2
- package/dist/components/PartnerDashboard/EarningsSummary.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/ProgramOverview.d.ts +3 -3
- package/dist/components/PartnerDashboard/ProgramOverview.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/RecentReferrals.d.ts +3 -3
- package/dist/components/PartnerDashboard/RecentReferrals.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/ReferralCodes.d.ts +3 -3
- package/dist/components/PartnerDashboard/ReferralCodes.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/ReferralPerformance.d.ts +2 -2
- package/dist/components/PartnerDashboard/ReferralPerformance.d.ts.map +1 -1
- package/dist/components/PartnerDashboard/index.d.ts +1 -1
- package/dist/components/PartnerDashboard/index.d.ts.map +1 -1
- package/dist/endpoints/applyCoupon.d.ts +2 -2
- package/dist/endpoints/applyCoupon.d.ts.map +1 -1
- package/dist/endpoints/partnerStats.d.ts +2 -2
- package/dist/endpoints/partnerStats.d.ts.map +1 -1
- package/dist/endpoints/validateCoupon.d.ts +2 -2
- package/dist/endpoints/validateCoupon.d.ts.map +1 -1
- package/dist/hooks/recalculateCart.d.ts +2 -2
- package/dist/hooks/recalculateCart.d.ts.map +1 -1
- package/dist/index.d.ts +17 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +58 -67
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -67
- package/dist/index.mjs.map +1 -1
- package/dist/plugin.d.ts +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/types.d.ts +4 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/calculateValues.d.ts +2 -2
- package/dist/utilities/calculateValues.d.ts.map +1 -1
- package/dist/utilities/getCartTotalWithDiscounts.d.ts.map +1 -1
- package/dist/utilities/migrateReferralRulesV2.d.ts.map +1 -1
- package/dist/utilities/pricing.d.ts.map +1 -1
- package/dist/utilities/pushTypeScriptProperties.d.ts +1 -1
- package/dist/utilities/pushTypeScriptProperties.d.ts.map +1 -1
- package/dist/utilities/recordCouponUsageForOrder.d.ts +2 -2
- package/dist/utilities/recordCouponUsageForOrder.d.ts.map +1 -1
- package/dist/utilities/sanitizePluginConfig.d.ts +1 -1
- package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -1
- package/dist/utilities/userRoles.d.ts +3 -3
- package/dist/utilities/userRoles.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/client/hooks.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/client/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/client/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE3F,KAAK,aAAa,GACd,MAAM,GACN;IACE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAoCN;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,eAAe,EACxB,cAAc,CAAC,EAAE,aAAa,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAyD9B;AAED;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,aAAa,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAuD9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;GAGG;AACH,wBAAsB,eAAe,CACnC,cAAc,CAAC,EAAE,aAAa,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CA4B/B"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { PartnerDashboard } from
|
|
2
|
-
export { EarningsSummary } from
|
|
3
|
-
export { RecentReferrals } from
|
|
4
|
-
export { ReferralCodes } from
|
|
5
|
-
export { ReferralPerformance } from
|
|
6
|
-
export { ProgramOverview } from
|
|
7
|
-
export { CommissionBreakdown } from
|
|
8
|
-
export { useCouponCode, usePartnerStats, validateCouponCode } from
|
|
1
|
+
export { PartnerDashboard } from "../components/PartnerDashboard";
|
|
2
|
+
export { EarningsSummary } from "../components/PartnerDashboard/EarningsSummary";
|
|
3
|
+
export { RecentReferrals } from "../components/PartnerDashboard/RecentReferrals";
|
|
4
|
+
export { ReferralCodes } from "../components/PartnerDashboard/ReferralCodes";
|
|
5
|
+
export { ReferralPerformance } from "../components/PartnerDashboard/ReferralPerformance";
|
|
6
|
+
export { ProgramOverview } from "../components/PartnerDashboard/ProgramOverview";
|
|
7
|
+
export { CommissionBreakdown } from "../components/PartnerDashboard/CommissionBreakdown";
|
|
8
|
+
export { useCouponCode, usePartnerStats, validateCouponCode } from "./hooks";
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAC;AAC7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { CollectionConfig } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
export declare const createCouponsCollection: (pluginConfig: SanitizedCouponPluginOptions) => CollectionConfig;
|
|
4
4
|
//# sourceMappingURL=createCouponsCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCouponsCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createCouponsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"createCouponsCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createCouponsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAE7D,eAAO,MAAM,uBAAuB,GAClC,cAAc,4BAA4B,KACzC,gBAmKF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { CollectionConfig } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
export declare const createReferralCodesCollection: (pluginConfig: SanitizedCouponPluginOptions) => CollectionConfig;
|
|
4
4
|
//# sourceMappingURL=createReferralCodesCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReferralCodesCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createReferralCodesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"createReferralCodesCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createReferralCodesCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAM7D,eAAO,MAAM,6BAA6B,GACxC,cAAc,4BAA4B,KACzC,gBA+PF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionConfig } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { CollectionConfig } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
export declare const createReferralProgramsCollection: (pluginConfig: SanitizedCouponPluginOptions) => CollectionConfig;
|
|
4
4
|
//# sourceMappingURL=createReferralProgramsCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createReferralProgramsCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createReferralProgramsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"createReferralProgramsCollection.d.ts","sourceRoot":"","sources":["../../src/collections/createReferralProgramsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AA0B7D,eAAO,MAAM,gCAAgC,GAC3C,cAAc,4BAA4B,KACzC,gBA8YF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommissionBreakdown.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/CommissionBreakdown.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"CommissionBreakdown.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/CommissionBreakdown.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAeF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA0FlE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EarningsSummary.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/EarningsSummary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"EarningsSummary.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/EarningsSummary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,YAAY,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAUF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA4B1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import type { PartnerDashboardData } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PartnerDashboardData } from "../../types";
|
|
3
3
|
export type ProgramOverviewProps = {
|
|
4
|
-
program: PartnerDashboardData[
|
|
4
|
+
program: PartnerDashboardData["program"];
|
|
5
5
|
};
|
|
6
6
|
export declare const ProgramOverview: React.FC<ProgramOverviewProps>;
|
|
7
7
|
export default ProgramOverview;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProgramOverview.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ProgramOverview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"ProgramOverview.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ProgramOverview.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;CAC1C,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAmC1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import type { PartnerStats } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PartnerStats } from "../../types";
|
|
3
3
|
export type RecentReferralsProps = {
|
|
4
|
-
referrals: PartnerStats[
|
|
4
|
+
referrals: PartnerStats["recentReferrals"];
|
|
5
5
|
currency: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const RecentReferrals: React.FC<RecentReferralsProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecentReferrals.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/RecentReferrals.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"RecentReferrals.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/RecentReferrals.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAkBF,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoC1D,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import type { PartnerDashboardData } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { PartnerDashboardData } from "../../types";
|
|
3
3
|
export type ReferralCodesProps = {
|
|
4
|
-
codes: PartnerDashboardData[
|
|
4
|
+
codes: PartnerDashboardData["referralCodes"];
|
|
5
5
|
currency: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const ReferralCodes: React.FC<ReferralCodesProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferralCodes.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ReferralCodes.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"ReferralCodes.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ReferralCodes.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IAC7C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAUF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA+DtD,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReferralPerformance.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ReferralPerformance.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"ReferralPerformance.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ReferralPerformance.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,YAAY,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6ClE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAWnD,MAAM,MAAM,qBAAqB,GAAG;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CA2H5D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Endpoint, PayloadHandler } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { Endpoint, PayloadHandler } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
type Args = {
|
|
4
4
|
pluginConfig: SanitizedCouponPluginOptions;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"applyCoupon.d.ts","sourceRoot":"","sources":["../../src/endpoints/applyCoupon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"applyCoupon.d.ts","sourceRoot":"","sources":["../../src/endpoints/applyCoupon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAQ7D,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AA4EF,eAAO,MAAM,kBAAkB,GAC5B,kBAAkB,IAAI,KAAG,cA8GzB,CAAC;AAsQJ,eAAO,MAAM,mBAAmB,GAAI,kBAAkB,IAAI,KAAG,QAI3D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Endpoint, PayloadHandler } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { Endpoint, PayloadHandler } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
type Args = {
|
|
4
4
|
pluginConfig: SanitizedCouponPluginOptions;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"partnerStats.d.ts","sourceRoot":"","sources":["../../src/endpoints/partnerStats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"partnerStats.d.ts","sourceRoot":"","sources":["../../src/endpoints/partnerStats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,KAAK,EAAsC,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAGjG,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAgCF,eAAO,MAAM,mBAAmB,GAC7B,kBAAkB,IAAI,KAAG,cA0MzB,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,IAAI,KAAG,QAI5D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Endpoint, PayloadHandler } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { Endpoint, PayloadHandler } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
type Args = {
|
|
4
4
|
pluginConfig: SanitizedCouponPluginOptions;
|
|
5
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateCoupon.d.ts","sourceRoot":"","sources":["../../src/endpoints/validateCoupon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"validateCoupon.d.ts","sourceRoot":"","sources":["../../src/endpoints/validateCoupon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAO7D,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAC;CAC5C,CAAC;AAmEF,eAAO,MAAM,qBAAqB,GAC/B,kBAAkB,IAAI,KAAG,cA0DzB,CAAC;AAwOJ,eAAO,MAAM,sBAAsB,GAAI,kBAAkB,IAAI,KAAG,QAI9D,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CollectionBeforeChangeHook } from
|
|
2
|
-
import type { SanitizedCouponPluginOptions } from
|
|
1
|
+
import type { CollectionBeforeChangeHook } from "payload";
|
|
2
|
+
import type { SanitizedCouponPluginOptions } from "../types";
|
|
3
3
|
export declare const recalculateCartHook: (pluginConfig: SanitizedCouponPluginOptions) => CollectionBeforeChangeHook;
|
|
4
4
|
//# sourceMappingURL=recalculateCart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recalculateCart.d.ts","sourceRoot":"","sources":["../../src/hooks/recalculateCart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"recalculateCart.d.ts","sourceRoot":"","sources":["../../src/hooks/recalculateCart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AA6C7D,eAAO,MAAM,mBAAmB,GAC7B,cAAc,4BAA4B,KAAG,0BA4Q7C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { createCouponsCollection } from
|
|
2
|
-
import { createReferralCodesCollection } from
|
|
3
|
-
import { createReferralProgramsCollection } from
|
|
4
|
-
import { payloadEcommerceCouponPlugin } from
|
|
5
|
-
export { useCouponCode, usePartnerStats, validateCouponCode } from
|
|
6
|
-
export { PartnerDashboard } from
|
|
7
|
-
export { EarningsSummary } from
|
|
8
|
-
export { RecentReferrals } from
|
|
9
|
-
export { ReferralCodes } from
|
|
10
|
-
export { ReferralPerformance } from
|
|
11
|
-
export { ProgramOverview } from
|
|
12
|
-
export { CommissionBreakdown } from
|
|
13
|
-
export { calculateCommissionAndDiscount, getProgramMinimumOrderAmount, } from
|
|
14
|
-
export { getCartTotalWithDiscounts } from
|
|
15
|
-
export { recordCouponUsageForOrder } from
|
|
1
|
+
import { createCouponsCollection } from "./collections/createCouponsCollection";
|
|
2
|
+
import { createReferralCodesCollection } from "./collections/createReferralCodesCollection";
|
|
3
|
+
import { createReferralProgramsCollection } from "./collections/createReferralProgramsCollection";
|
|
4
|
+
import { payloadEcommerceCouponPlugin } from "./plugin";
|
|
5
|
+
export { useCouponCode, usePartnerStats, validateCouponCode } from "./client/hooks";
|
|
6
|
+
export { PartnerDashboard } from "./components/PartnerDashboard";
|
|
7
|
+
export { EarningsSummary } from "./components/PartnerDashboard/EarningsSummary";
|
|
8
|
+
export { RecentReferrals } from "./components/PartnerDashboard/RecentReferrals";
|
|
9
|
+
export { ReferralCodes } from "./components/PartnerDashboard/ReferralCodes";
|
|
10
|
+
export { ReferralPerformance } from "./components/PartnerDashboard/ReferralPerformance";
|
|
11
|
+
export { ProgramOverview } from "./components/PartnerDashboard/ProgramOverview";
|
|
12
|
+
export { CommissionBreakdown } from "./components/PartnerDashboard/CommissionBreakdown";
|
|
13
|
+
export { calculateCommissionAndDiscount, getProgramMinimumOrderAmount, } from "./utilities/calculateValues";
|
|
14
|
+
export { getCartTotalWithDiscounts } from "./utilities/getCartTotalWithDiscounts";
|
|
15
|
+
export { recordCouponUsageForOrder } from "./utilities/recordCouponUsageForOrder";
|
|
16
16
|
export { createCouponsCollection, createReferralCodesCollection, createReferralProgramsCollection, payloadEcommerceCouponPlugin as payloadEcommerceCoupon, };
|
|
17
|
-
export type { AdminGroupConfig, ApplyCouponHook, ApplyCouponResponse, CouponPluginAccess, CouponPluginCollections, CouponPluginOptions, CouponPluginPolicies, OrderIntegrationConfig, PartnerDashboardConfig, PartnerDashboardData, PartnerStats, PartnerStatsPolicyContext, PluginIntegrationCollections, PluginIntegrationConfig, PluginIntegrationFields, PluginIntegrationResolvers, PolicyContext, RecordOrderUsagePolicyContext, ReferralProgramConfig, RoleConfig, } from
|
|
18
|
-
export type { CartLike } from
|
|
17
|
+
export type { AdminGroupConfig, ApplyCouponHook, ApplyCouponResponse, CouponPluginAccess, CouponPluginCollections, CouponPluginOptions, CouponPluginPolicies, OrderIntegrationConfig, PartnerDashboardConfig, PartnerDashboardData, PartnerStats, PartnerStatsPolicyContext, PluginIntegrationCollections, PluginIntegrationConfig, PluginIntegrationFields, PluginIntegrationResolvers, PolicyContext, RecordOrderUsagePolicyContext, ReferralProgramConfig, RoleConfig, } from "./types";
|
|
18
|
+
export type { CartLike } from "./utilities/getCartTotalWithDiscounts";
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAC5F,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAC;AAClG,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AACxF,OAAO,EAAE,eAAe,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAExF,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,gCAAgC,EAChC,4BAA4B,IAAI,sBAAsB,GACvD,CAAC;AAEF,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,uBAAuB,EACvB,0BAA0B,EAC1B,aAAa,EACb,6BAA6B,EAC7B,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -430,15 +430,15 @@ function toCents(value) {
|
|
|
430
430
|
return Math.round(value * 100);
|
|
431
431
|
}
|
|
432
432
|
const createReferralProgramsCollection = (pluginConfig) => {
|
|
433
|
-
const { collections, access,
|
|
433
|
+
const { collections, access, adminGroups, referralConfig, integration } = pluginConfig;
|
|
434
434
|
const allowedTotalCommissionTypes = referralConfig.allowedTotalCommissionTypes;
|
|
435
435
|
const relationSlugs = integration.collections;
|
|
436
436
|
return {
|
|
437
437
|
slug: collections.referralProgramsSlug,
|
|
438
438
|
admin: {
|
|
439
|
-
useAsTitle: "
|
|
439
|
+
useAsTitle: "id",
|
|
440
440
|
defaultColumns: [
|
|
441
|
-
"
|
|
441
|
+
"id",
|
|
442
442
|
"commissionRules",
|
|
443
443
|
"isActive"
|
|
444
444
|
],
|
|
@@ -452,18 +452,22 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
452
452
|
},
|
|
453
453
|
hooks: { beforeChange: [({ data }) => {
|
|
454
454
|
if (!data.commissionRules || !Array.isArray(data.commissionRules) || data.commissionRules.length === 0) throw new Error("At least one commission rule is required");
|
|
455
|
+
const maxAmount = toNumber(data.maxAmount);
|
|
456
|
+
if (maxAmount != null && maxAmount < 0) throw new Error("Max Amount must be a non-negative number");
|
|
457
|
+
const minOrderAmount = toNumber(data.minOrderAmount);
|
|
458
|
+
if (minOrderAmount != null && minOrderAmount < 0) throw new Error("Minimum Order Amount must be a non-negative number");
|
|
459
|
+
data.maxAmount = maxAmount ?? null;
|
|
460
|
+
data.minOrderAmount = minOrderAmount ?? null;
|
|
455
461
|
data.commissionRules = data.commissionRules.map((rule, index) => {
|
|
456
462
|
const r = rule;
|
|
457
463
|
if (!r.totalCommission) throw new Error(`Commission rule ${index + 1}: Total Commission is required`);
|
|
458
464
|
if (!r.totalCommission.type || !allowedTotalCommissionTypes.includes(r.totalCommission.type)) throw new Error(`Commission rule ${index + 1}: Total Commission type must be one of ${allowedTotalCommissionTypes.join(", ")}`);
|
|
459
465
|
const type = r.totalCommission.type;
|
|
460
466
|
const totalValue = toNumber(r.totalCommission.value);
|
|
461
|
-
const maxAmount = toNumber(r.totalCommission.maxAmount);
|
|
462
467
|
if (type === "percentage") {
|
|
463
468
|
if (totalValue == null || totalValue < 0) throw new Error(`Commission rule ${index + 1}: Total Commission value must be a non-negative number`);
|
|
464
469
|
if (totalValue > 100) throw new Error(`Commission rule ${index + 1}: Percentage Total Commission cannot exceed 100`);
|
|
465
470
|
}
|
|
466
|
-
if (maxAmount != null && maxAmount < 0) throw new Error(`Commission rule ${index + 1}: Max Amount must be a non-negative number`);
|
|
467
471
|
const appliesTo = r.appliesTo ?? "all";
|
|
468
472
|
if (appliesTo === "products" && (!r.products || r.products.length === 0)) throw new Error(`Commission rule ${index + 1}: At least one product is required`);
|
|
469
473
|
if ((appliesTo === "segments" || appliesTo === "categories") && (!r.categories || r.categories.length === 0) && (!r.tags || r.tags.length === 0)) throw new Error(`Commission rule ${index + 1}: At least one category or tag is required`);
|
|
@@ -507,40 +511,42 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
507
511
|
customerAmount = null;
|
|
508
512
|
} else throw new Error(`Commission rule ${index + 1}: For fixed commissions, both partner and customer values must be provided`);
|
|
509
513
|
}
|
|
510
|
-
const minOrderAmount = toNumber(r.minOrderAmount);
|
|
511
|
-
if (minOrderAmount != null && minOrderAmount < 0) throw new Error(`Commission rule ${index + 1}: Minimum Order Amount must be a non-negative number`);
|
|
512
514
|
return {
|
|
513
515
|
...rule,
|
|
514
516
|
appliesTo: appliesTo === "categories" ? "segments" : appliesTo,
|
|
515
517
|
totalCommission: {
|
|
516
518
|
type,
|
|
517
|
-
value: type === "percentage" ? totalValue : null
|
|
518
|
-
maxAmount: maxAmount ?? null
|
|
519
|
+
value: type === "percentage" ? totalValue : null
|
|
519
520
|
},
|
|
520
521
|
partnerPercent,
|
|
521
522
|
customerPercent,
|
|
522
523
|
partnerAmount,
|
|
523
524
|
customerAmount,
|
|
524
525
|
partnerSplit,
|
|
525
|
-
customerSplit
|
|
526
|
-
minOrderAmount: minOrderAmount ?? null
|
|
526
|
+
customerSplit
|
|
527
527
|
};
|
|
528
528
|
});
|
|
529
529
|
return data;
|
|
530
530
|
}] },
|
|
531
531
|
fields: [
|
|
532
|
-
{
|
|
533
|
-
name: "name",
|
|
534
|
-
type: "text",
|
|
535
|
-
required: true,
|
|
536
|
-
admin: { description: "Name of the referral program for admin reference" }
|
|
537
|
-
},
|
|
538
532
|
{
|
|
539
533
|
name: "isActive",
|
|
540
534
|
type: "checkbox",
|
|
541
535
|
defaultValue: true,
|
|
542
536
|
admin: { description: "Whether this referral program is currently active" }
|
|
543
537
|
},
|
|
538
|
+
{
|
|
539
|
+
name: "maxAmount",
|
|
540
|
+
type: "number",
|
|
541
|
+
min: 0,
|
|
542
|
+
admin: { description: "Maximum commission cap per item. Leave empty for no cap." }
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
name: "minOrderAmount",
|
|
546
|
+
type: "number",
|
|
547
|
+
min: 0,
|
|
548
|
+
admin: { description: "Minimum cart subtotal required for this program. Leave empty for no minimum." }
|
|
549
|
+
},
|
|
544
550
|
{
|
|
545
551
|
name: "commissionRules",
|
|
546
552
|
type: "array",
|
|
@@ -548,12 +554,6 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
548
554
|
minRows: 1,
|
|
549
555
|
admin: { description: "Rules for referral commission and customer discount distribution." },
|
|
550
556
|
fields: [
|
|
551
|
-
{
|
|
552
|
-
name: "name",
|
|
553
|
-
type: "text",
|
|
554
|
-
required: false,
|
|
555
|
-
admin: { description: "Optional rule label for admin clarity" }
|
|
556
|
-
},
|
|
557
557
|
{
|
|
558
558
|
name: "appliesTo",
|
|
559
559
|
type: "select",
|
|
@@ -608,34 +608,25 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
608
608
|
name: "totalCommission",
|
|
609
609
|
type: "group",
|
|
610
610
|
admin: { description: "Total commission pool configuration" },
|
|
611
|
-
fields: [
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
condition: ({ siblingData }) => siblingData?.type === "percentage",
|
|
629
|
-
description: "Total commission percentage for this rule (0-100). Partner/Customer percentages split this 100-based bucket."
|
|
630
|
-
}
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
name: "maxAmount",
|
|
634
|
-
type: "number",
|
|
635
|
-
min: 0,
|
|
636
|
-
admin: { description: `Max commission cap per item in ${defaultCurrency}` }
|
|
611
|
+
fields: [{
|
|
612
|
+
name: "type",
|
|
613
|
+
type: "select",
|
|
614
|
+
required: true,
|
|
615
|
+
options: allowedTotalCommissionTypes.map((value) => ({
|
|
616
|
+
label: value === "fixed" ? "Fixed Amount" : "Percentage of Order",
|
|
617
|
+
value
|
|
618
|
+
})),
|
|
619
|
+
defaultValue: allowedTotalCommissionTypes.includes("fixed") ? "fixed" : "percentage"
|
|
620
|
+
}, {
|
|
621
|
+
name: "value",
|
|
622
|
+
type: "number",
|
|
623
|
+
min: 0,
|
|
624
|
+
max: 100,
|
|
625
|
+
admin: {
|
|
626
|
+
condition: (_, siblingData) => siblingData?.type === "percentage",
|
|
627
|
+
description: "Total commission percentage for this rule (0-100). Partner/Customer percentages split this 100-based bucket."
|
|
637
628
|
}
|
|
638
|
-
]
|
|
629
|
+
}]
|
|
639
630
|
},
|
|
640
631
|
{
|
|
641
632
|
name: "partnerPercent",
|
|
@@ -643,7 +634,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
643
634
|
min: 0,
|
|
644
635
|
max: 100,
|
|
645
636
|
admin: {
|
|
646
|
-
condition: (
|
|
637
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "percentage",
|
|
647
638
|
description: "Partner share in percent (0-100). Customer share is auto-calculated as 100 - Partner."
|
|
648
639
|
}
|
|
649
640
|
},
|
|
@@ -654,7 +645,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
654
645
|
max: 100,
|
|
655
646
|
admin: {
|
|
656
647
|
readOnly: true,
|
|
657
|
-
condition: (
|
|
648
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "percentage",
|
|
658
649
|
description: "Auto-calculated customer share percentage."
|
|
659
650
|
},
|
|
660
651
|
hooks: { beforeValidate: [({ siblingData }) => {
|
|
@@ -670,8 +661,8 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
670
661
|
type: "number",
|
|
671
662
|
min: 0,
|
|
672
663
|
admin: {
|
|
673
|
-
condition: (
|
|
674
|
-
description:
|
|
664
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "fixed",
|
|
665
|
+
description: "Fixed partner commission amount per item."
|
|
675
666
|
}
|
|
676
667
|
},
|
|
677
668
|
{
|
|
@@ -679,8 +670,8 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
679
670
|
type: "number",
|
|
680
671
|
min: 0,
|
|
681
672
|
admin: {
|
|
682
|
-
condition: (
|
|
683
|
-
description:
|
|
673
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "fixed",
|
|
674
|
+
description: "Fixed customer discount amount per item."
|
|
684
675
|
}
|
|
685
676
|
},
|
|
686
677
|
{
|
|
@@ -700,12 +691,6 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
700
691
|
hidden: true,
|
|
701
692
|
description: "Canonical storage field. Percentage mode: percent. Fixed mode: amount in cents."
|
|
702
693
|
}
|
|
703
|
-
},
|
|
704
|
-
{
|
|
705
|
-
name: "minOrderAmount",
|
|
706
|
-
type: "number",
|
|
707
|
-
min: 0,
|
|
708
|
-
admin: { description: `Minimum cart subtotal required for this rule in ${defaultCurrency}. Leave empty for no minimum.` }
|
|
709
694
|
}
|
|
710
695
|
]
|
|
711
696
|
}
|
|
@@ -786,7 +771,7 @@ function getRuleSplits(rule) {
|
|
|
786
771
|
customerSplit: typeof rule.customerSplit === "number" ? rule.customerSplit : typeof rule.refereeSplit === "number" ? rule.refereeSplit : 100 - partnerRaw
|
|
787
772
|
};
|
|
788
773
|
}
|
|
789
|
-
function calculateItemRewardByRule({ rule, itemTotal, quantity, allowedTotalCommissionTypes }) {
|
|
774
|
+
function calculateItemRewardByRule({ rule, itemTotal, quantity, maxAmount, allowedTotalCommissionTypes }) {
|
|
790
775
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
791
776
|
if (rule.totalCommission) {
|
|
792
777
|
if (!allowedTypes.has(rule.totalCommission.type)) return null;
|
|
@@ -804,8 +789,9 @@ function calculateItemRewardByRule({ rule, itemTotal, quantity, allowedTotalComm
|
|
|
804
789
|
let totalPot = 0;
|
|
805
790
|
if (rule.totalCommission.type === "percentage") totalPot = itemTotal * rule.totalCommission.value / 100;
|
|
806
791
|
else totalPot = rule.totalCommission.value * quantity;
|
|
807
|
-
|
|
808
|
-
|
|
792
|
+
const resolvedMaxAmount = typeof maxAmount === "number" && Number.isFinite(maxAmount) ? maxAmount : typeof rule.totalCommission.maxAmount === "number" && Number.isFinite(rule.totalCommission.maxAmount) ? rule.totalCommission.maxAmount : null;
|
|
793
|
+
if (resolvedMaxAmount != null) {
|
|
794
|
+
const maxPotForLine = resolvedMaxAmount * quantity;
|
|
809
795
|
if (totalPot > maxPotForLine) totalPot = maxPotForLine;
|
|
810
796
|
}
|
|
811
797
|
return {
|
|
@@ -837,11 +823,12 @@ function getItemCategoryIds(item) {
|
|
|
837
823
|
function getItemTagIds(item) {
|
|
838
824
|
return Array.isArray(item?.product?.tags) ? normalizeIds(item.product.tags) : [];
|
|
839
825
|
}
|
|
840
|
-
function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, allowedTotalCommissionTypes }) {
|
|
826
|
+
function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, minOrderAmount, maxAmount, allowedTotalCommissionTypes }) {
|
|
841
827
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
842
828
|
const eligibleRules = rules.filter((rule) => {
|
|
843
829
|
if (!(rule?.totalCommission?.type ? allowedTypes.has(rule.totalCommission.type) : true)) return false;
|
|
844
|
-
|
|
830
|
+
const resolvedMinOrderAmount = typeof minOrderAmount === "number" && Number.isFinite(minOrderAmount) ? minOrderAmount : typeof rule?.minOrderAmount === "number" && Number.isFinite(rule.minOrderAmount) ? rule.minOrderAmount : null;
|
|
831
|
+
if (resolvedMinOrderAmount != null) return cartTotal >= resolvedMinOrderAmount;
|
|
845
832
|
return true;
|
|
846
833
|
});
|
|
847
834
|
const productId = relationId$5(item.product);
|
|
@@ -866,6 +853,7 @@ function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, al
|
|
|
866
853
|
rule,
|
|
867
854
|
itemTotal,
|
|
868
855
|
quantity,
|
|
856
|
+
maxAmount,
|
|
869
857
|
allowedTotalCommissionTypes
|
|
870
858
|
});
|
|
871
859
|
if (!reward) continue;
|
|
@@ -894,6 +882,7 @@ function getProgramMinimumOrderAmount({ program, allowedTotalCommissionTypes })
|
|
|
894
882
|
const rules = Array.isArray(program?.commissionRules) ? program.commissionRules : [];
|
|
895
883
|
if (!rules.length) return null;
|
|
896
884
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
885
|
+
if (typeof program?.minOrderAmount === "number" && Number.isFinite(program.minOrderAmount)) return program.minOrderAmount;
|
|
897
886
|
const minValues = rules.filter((rule) => {
|
|
898
887
|
if (rule?.totalCommission?.type) return allowedTypes.has(rule.totalCommission.type);
|
|
899
888
|
return true;
|
|
@@ -928,6 +917,8 @@ function calculateCommissionAndDiscount({ cartItems, program, currencyCode = "AE
|
|
|
928
917
|
itemTotal,
|
|
929
918
|
quantity,
|
|
930
919
|
cartTotal,
|
|
920
|
+
minOrderAmount: typeof program?.minOrderAmount === "number" && Number.isFinite(program.minOrderAmount) ? program.minOrderAmount : null,
|
|
921
|
+
maxAmount: typeof program?.maxAmount === "number" && Number.isFinite(program.maxAmount) ? program.maxAmount : null,
|
|
931
922
|
allowedTotalCommissionTypes
|
|
932
923
|
});
|
|
933
924
|
if (!bestMatch) continue;
|