@wtree/payload-ecommerce-coupon 3.77.7 → 3.77.9
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 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +58 -60
- 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,gBAsZF,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,7 +430,7 @@ 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 {
|
|
@@ -438,6 +438,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
438
438
|
admin: {
|
|
439
439
|
useAsTitle: "name",
|
|
440
440
|
defaultColumns: [
|
|
441
|
+
"id",
|
|
441
442
|
"name",
|
|
442
443
|
"commissionRules",
|
|
443
444
|
"isActive"
|
|
@@ -452,18 +453,22 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
452
453
|
},
|
|
453
454
|
hooks: { beforeChange: [({ data }) => {
|
|
454
455
|
if (!data.commissionRules || !Array.isArray(data.commissionRules) || data.commissionRules.length === 0) throw new Error("At least one commission rule is required");
|
|
456
|
+
const maxAmount = toNumber(data.maxAmount);
|
|
457
|
+
if (maxAmount != null && maxAmount < 0) throw new Error("Max Amount must be a non-negative number");
|
|
458
|
+
const minOrderAmount = toNumber(data.minOrderAmount);
|
|
459
|
+
if (minOrderAmount != null && minOrderAmount < 0) throw new Error("Minimum Order Amount must be a non-negative number");
|
|
460
|
+
data.maxAmount = maxAmount ?? null;
|
|
461
|
+
data.minOrderAmount = minOrderAmount ?? null;
|
|
455
462
|
data.commissionRules = data.commissionRules.map((rule, index) => {
|
|
456
463
|
const r = rule;
|
|
457
464
|
if (!r.totalCommission) throw new Error(`Commission rule ${index + 1}: Total Commission is required`);
|
|
458
465
|
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
466
|
const type = r.totalCommission.type;
|
|
460
467
|
const totalValue = toNumber(r.totalCommission.value);
|
|
461
|
-
const maxAmount = toNumber(r.totalCommission.maxAmount);
|
|
462
468
|
if (type === "percentage") {
|
|
463
469
|
if (totalValue == null || totalValue < 0) throw new Error(`Commission rule ${index + 1}: Total Commission value must be a non-negative number`);
|
|
464
470
|
if (totalValue > 100) throw new Error(`Commission rule ${index + 1}: Percentage Total Commission cannot exceed 100`);
|
|
465
471
|
}
|
|
466
|
-
if (maxAmount != null && maxAmount < 0) throw new Error(`Commission rule ${index + 1}: Max Amount must be a non-negative number`);
|
|
467
472
|
const appliesTo = r.appliesTo ?? "all";
|
|
468
473
|
if (appliesTo === "products" && (!r.products || r.products.length === 0)) throw new Error(`Commission rule ${index + 1}: At least one product is required`);
|
|
469
474
|
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,23 +512,19 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
507
512
|
customerAmount = null;
|
|
508
513
|
} else throw new Error(`Commission rule ${index + 1}: For fixed commissions, both partner and customer values must be provided`);
|
|
509
514
|
}
|
|
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
515
|
return {
|
|
513
516
|
...rule,
|
|
514
517
|
appliesTo: appliesTo === "categories" ? "segments" : appliesTo,
|
|
515
518
|
totalCommission: {
|
|
516
519
|
type,
|
|
517
|
-
value: type === "percentage" ? totalValue : null
|
|
518
|
-
maxAmount: maxAmount ?? null
|
|
520
|
+
value: type === "percentage" ? totalValue : null
|
|
519
521
|
},
|
|
520
522
|
partnerPercent,
|
|
521
523
|
customerPercent,
|
|
522
524
|
partnerAmount,
|
|
523
525
|
customerAmount,
|
|
524
526
|
partnerSplit,
|
|
525
|
-
customerSplit
|
|
526
|
-
minOrderAmount: minOrderAmount ?? null
|
|
527
|
+
customerSplit
|
|
527
528
|
};
|
|
528
529
|
});
|
|
529
530
|
return data;
|
|
@@ -533,7 +534,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
533
534
|
name: "name",
|
|
534
535
|
type: "text",
|
|
535
536
|
required: true,
|
|
536
|
-
admin: { description: "Name of the referral program
|
|
537
|
+
admin: { description: "Name of the referral program" }
|
|
537
538
|
},
|
|
538
539
|
{
|
|
539
540
|
name: "isActive",
|
|
@@ -541,6 +542,18 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
541
542
|
defaultValue: true,
|
|
542
543
|
admin: { description: "Whether this referral program is currently active" }
|
|
543
544
|
},
|
|
545
|
+
{
|
|
546
|
+
name: "maxAmount",
|
|
547
|
+
type: "number",
|
|
548
|
+
min: 0,
|
|
549
|
+
admin: { description: "Maximum commission cap per item. Leave empty for no cap." }
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
name: "minOrderAmount",
|
|
553
|
+
type: "number",
|
|
554
|
+
min: 0,
|
|
555
|
+
admin: { description: "Minimum cart subtotal required for this program. Leave empty for no minimum." }
|
|
556
|
+
},
|
|
544
557
|
{
|
|
545
558
|
name: "commissionRules",
|
|
546
559
|
type: "array",
|
|
@@ -548,12 +561,6 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
548
561
|
minRows: 1,
|
|
549
562
|
admin: { description: "Rules for referral commission and customer discount distribution." },
|
|
550
563
|
fields: [
|
|
551
|
-
{
|
|
552
|
-
name: "name",
|
|
553
|
-
type: "text",
|
|
554
|
-
required: false,
|
|
555
|
-
admin: { description: "Optional rule label for admin clarity" }
|
|
556
|
-
},
|
|
557
564
|
{
|
|
558
565
|
name: "appliesTo",
|
|
559
566
|
type: "select",
|
|
@@ -608,34 +615,25 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
608
615
|
name: "totalCommission",
|
|
609
616
|
type: "group",
|
|
610
617
|
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}` }
|
|
618
|
+
fields: [{
|
|
619
|
+
name: "type",
|
|
620
|
+
type: "select",
|
|
621
|
+
required: true,
|
|
622
|
+
options: allowedTotalCommissionTypes.map((value) => ({
|
|
623
|
+
label: value === "fixed" ? "Fixed Amount" : "Percentage of Order",
|
|
624
|
+
value
|
|
625
|
+
})),
|
|
626
|
+
defaultValue: allowedTotalCommissionTypes.includes("fixed") ? "fixed" : "percentage"
|
|
627
|
+
}, {
|
|
628
|
+
name: "value",
|
|
629
|
+
type: "number",
|
|
630
|
+
min: 0,
|
|
631
|
+
max: 100,
|
|
632
|
+
admin: {
|
|
633
|
+
condition: (_, siblingData) => siblingData?.type === "percentage",
|
|
634
|
+
description: "Total commission percentage for this rule (0-100). Partner/Customer percentages split this 100-based bucket."
|
|
637
635
|
}
|
|
638
|
-
]
|
|
636
|
+
}]
|
|
639
637
|
},
|
|
640
638
|
{
|
|
641
639
|
name: "partnerPercent",
|
|
@@ -643,7 +641,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
643
641
|
min: 0,
|
|
644
642
|
max: 100,
|
|
645
643
|
admin: {
|
|
646
|
-
condition: (
|
|
644
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "percentage",
|
|
647
645
|
description: "Partner share in percent (0-100). Customer share is auto-calculated as 100 - Partner."
|
|
648
646
|
}
|
|
649
647
|
},
|
|
@@ -654,7 +652,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
654
652
|
max: 100,
|
|
655
653
|
admin: {
|
|
656
654
|
readOnly: true,
|
|
657
|
-
condition: (
|
|
655
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "percentage",
|
|
658
656
|
description: "Auto-calculated customer share percentage."
|
|
659
657
|
},
|
|
660
658
|
hooks: { beforeValidate: [({ siblingData }) => {
|
|
@@ -670,8 +668,8 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
670
668
|
type: "number",
|
|
671
669
|
min: 0,
|
|
672
670
|
admin: {
|
|
673
|
-
condition: (
|
|
674
|
-
description:
|
|
671
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "fixed",
|
|
672
|
+
description: "Fixed partner commission amount per item."
|
|
675
673
|
}
|
|
676
674
|
},
|
|
677
675
|
{
|
|
@@ -679,8 +677,8 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
679
677
|
type: "number",
|
|
680
678
|
min: 0,
|
|
681
679
|
admin: {
|
|
682
|
-
condition: (
|
|
683
|
-
description:
|
|
680
|
+
condition: (_, siblingData) => siblingData?.totalCommission?.type === "fixed",
|
|
681
|
+
description: "Fixed customer discount amount per item."
|
|
684
682
|
}
|
|
685
683
|
},
|
|
686
684
|
{
|
|
@@ -700,12 +698,6 @@ const createReferralProgramsCollection = (pluginConfig) => {
|
|
|
700
698
|
hidden: true,
|
|
701
699
|
description: "Canonical storage field. Percentage mode: percent. Fixed mode: amount in cents."
|
|
702
700
|
}
|
|
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
701
|
}
|
|
710
702
|
]
|
|
711
703
|
}
|
|
@@ -786,7 +778,7 @@ function getRuleSplits(rule) {
|
|
|
786
778
|
customerSplit: typeof rule.customerSplit === "number" ? rule.customerSplit : typeof rule.refereeSplit === "number" ? rule.refereeSplit : 100 - partnerRaw
|
|
787
779
|
};
|
|
788
780
|
}
|
|
789
|
-
function calculateItemRewardByRule({ rule, itemTotal, quantity, allowedTotalCommissionTypes }) {
|
|
781
|
+
function calculateItemRewardByRule({ rule, itemTotal, quantity, maxAmount, allowedTotalCommissionTypes }) {
|
|
790
782
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
791
783
|
if (rule.totalCommission) {
|
|
792
784
|
if (!allowedTypes.has(rule.totalCommission.type)) return null;
|
|
@@ -804,8 +796,9 @@ function calculateItemRewardByRule({ rule, itemTotal, quantity, allowedTotalComm
|
|
|
804
796
|
let totalPot = 0;
|
|
805
797
|
if (rule.totalCommission.type === "percentage") totalPot = itemTotal * rule.totalCommission.value / 100;
|
|
806
798
|
else totalPot = rule.totalCommission.value * quantity;
|
|
807
|
-
|
|
808
|
-
|
|
799
|
+
const resolvedMaxAmount = typeof maxAmount === "number" && Number.isFinite(maxAmount) ? maxAmount : typeof rule.totalCommission.maxAmount === "number" && Number.isFinite(rule.totalCommission.maxAmount) ? rule.totalCommission.maxAmount : null;
|
|
800
|
+
if (resolvedMaxAmount != null) {
|
|
801
|
+
const maxPotForLine = resolvedMaxAmount * quantity;
|
|
809
802
|
if (totalPot > maxPotForLine) totalPot = maxPotForLine;
|
|
810
803
|
}
|
|
811
804
|
return {
|
|
@@ -837,11 +830,12 @@ function getItemCategoryIds(item) {
|
|
|
837
830
|
function getItemTagIds(item) {
|
|
838
831
|
return Array.isArray(item?.product?.tags) ? normalizeIds(item.product.tags) : [];
|
|
839
832
|
}
|
|
840
|
-
function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, allowedTotalCommissionTypes }) {
|
|
833
|
+
function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, minOrderAmount, maxAmount, allowedTotalCommissionTypes }) {
|
|
841
834
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
842
835
|
const eligibleRules = rules.filter((rule) => {
|
|
843
836
|
if (!(rule?.totalCommission?.type ? allowedTypes.has(rule.totalCommission.type) : true)) return false;
|
|
844
|
-
|
|
837
|
+
const resolvedMinOrderAmount = typeof minOrderAmount === "number" && Number.isFinite(minOrderAmount) ? minOrderAmount : typeof rule?.minOrderAmount === "number" && Number.isFinite(rule.minOrderAmount) ? rule.minOrderAmount : null;
|
|
838
|
+
if (resolvedMinOrderAmount != null) return cartTotal >= resolvedMinOrderAmount;
|
|
845
839
|
return true;
|
|
846
840
|
});
|
|
847
841
|
const productId = relationId$5(item.product);
|
|
@@ -866,6 +860,7 @@ function selectBestRuleForItem({ rules, item, itemTotal, quantity, cartTotal, al
|
|
|
866
860
|
rule,
|
|
867
861
|
itemTotal,
|
|
868
862
|
quantity,
|
|
863
|
+
maxAmount,
|
|
869
864
|
allowedTotalCommissionTypes
|
|
870
865
|
});
|
|
871
866
|
if (!reward) continue;
|
|
@@ -894,6 +889,7 @@ function getProgramMinimumOrderAmount({ program, allowedTotalCommissionTypes })
|
|
|
894
889
|
const rules = Array.isArray(program?.commissionRules) ? program.commissionRules : [];
|
|
895
890
|
if (!rules.length) return null;
|
|
896
891
|
const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
|
|
892
|
+
if (typeof program?.minOrderAmount === "number" && Number.isFinite(program.minOrderAmount)) return program.minOrderAmount;
|
|
897
893
|
const minValues = rules.filter((rule) => {
|
|
898
894
|
if (rule?.totalCommission?.type) return allowedTypes.has(rule.totalCommission.type);
|
|
899
895
|
return true;
|
|
@@ -928,6 +924,8 @@ function calculateCommissionAndDiscount({ cartItems, program, currencyCode = "AE
|
|
|
928
924
|
itemTotal,
|
|
929
925
|
quantity,
|
|
930
926
|
cartTotal,
|
|
927
|
+
minOrderAmount: typeof program?.minOrderAmount === "number" && Number.isFinite(program.minOrderAmount) ? program.minOrderAmount : null,
|
|
928
|
+
maxAmount: typeof program?.maxAmount === "number" && Number.isFinite(program.maxAmount) ? program.maxAmount : null,
|
|
931
929
|
allowedTotalCommissionTypes
|
|
932
930
|
});
|
|
933
931
|
if (!bestMatch) continue;
|