@wtree/payload-ecommerce-coupon 3.77.3 → 3.77.5

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.
Files changed (52) hide show
  1. package/dist/client/hooks.d.ts +1 -1
  2. package/dist/client/hooks.d.ts.map +1 -1
  3. package/dist/client/index.d.ts +6 -6
  4. package/dist/client/index.d.ts.map +1 -1
  5. package/dist/collections/createCouponsCollection.d.ts +2 -2
  6. package/dist/collections/createCouponsCollection.d.ts.map +1 -1
  7. package/dist/collections/createReferralCodesCollection.d.ts +2 -2
  8. package/dist/collections/createReferralCodesCollection.d.ts.map +1 -1
  9. package/dist/collections/createReferralProgramsCollection.d.ts +2 -2
  10. package/dist/collections/createReferralProgramsCollection.d.ts.map +1 -1
  11. package/dist/components/PartnerDashboard/EarningsSummary.d.ts +2 -2
  12. package/dist/components/PartnerDashboard/EarningsSummary.d.ts.map +1 -1
  13. package/dist/components/PartnerDashboard/RecentReferrals.d.ts +3 -3
  14. package/dist/components/PartnerDashboard/RecentReferrals.d.ts.map +1 -1
  15. package/dist/components/PartnerDashboard/ReferralCodes.d.ts +3 -3
  16. package/dist/components/PartnerDashboard/ReferralCodes.d.ts.map +1 -1
  17. package/dist/components/PartnerDashboard/ReferralPerformance.d.ts +2 -2
  18. package/dist/components/PartnerDashboard/ReferralPerformance.d.ts.map +1 -1
  19. package/dist/components/PartnerDashboard/index.d.ts +2 -2
  20. package/dist/components/PartnerDashboard/index.d.ts.map +1 -1
  21. package/dist/endpoints/applyCoupon.d.ts +2 -2
  22. package/dist/endpoints/applyCoupon.d.ts.map +1 -1
  23. package/dist/endpoints/partnerStats.d.ts +2 -2
  24. package/dist/endpoints/partnerStats.d.ts.map +1 -1
  25. package/dist/endpoints/validateCoupon.d.ts +2 -2
  26. package/dist/endpoints/validateCoupon.d.ts.map +1 -1
  27. package/dist/hooks/recalculateCart.d.ts +2 -2
  28. package/dist/hooks/recalculateCart.d.ts.map +1 -1
  29. package/dist/index.d.ts +10 -10
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +38 -19
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +38 -19
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/plugin.d.ts +2 -2
  36. package/dist/plugin.d.ts.map +1 -1
  37. package/dist/types.d.ts +4 -4
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/utilities/calculateValues.d.ts +2 -2
  40. package/dist/utilities/calculateValues.d.ts.map +1 -1
  41. package/dist/utilities/getCartTotalWithDiscounts.d.ts.map +1 -1
  42. package/dist/utilities/migrateReferralRulesV2.d.ts.map +1 -1
  43. package/dist/utilities/pricing.d.ts.map +1 -1
  44. package/dist/utilities/pushTypeScriptProperties.d.ts +1 -1
  45. package/dist/utilities/pushTypeScriptProperties.d.ts.map +1 -1
  46. package/dist/utilities/recordCouponUsageForOrder.d.ts +2 -2
  47. package/dist/utilities/recordCouponUsageForOrder.d.ts.map +1 -1
  48. package/dist/utilities/sanitizePluginConfig.d.ts +1 -1
  49. package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -1
  50. package/dist/utilities/userRoles.d.ts +3 -3
  51. package/dist/utilities/userRoles.d.ts.map +1 -1
  52. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import type { ApplyCouponHook, ApplyCouponResponse, PartnerDashboardData } from '../types';
1
+ import type { ApplyCouponHook, ApplyCouponResponse, PartnerDashboardData } from "../types";
2
2
  /**
3
3
  * Apply a coupon code to a cart
4
4
  * @param options - Coupon code, cart ID, and customer email
@@ -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,CAAA;AAE1F;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsD1F;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CAqD9B;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,oBAAoB,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,WAAW,GAAE,MAAuC,GACnD,OAAO,CAAC,oBAAoB,CAAC,CA0B/B"}
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;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAsD1F;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,MAAM,EACZ,SAAS,CAAC,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,mBAAmB,CAAC,CAqD9B;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;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,WAAW,GAAE,MAAuC,GACnD,OAAO,CAAC,oBAAoB,CAAC,CA0B/B"}
@@ -1,7 +1,7 @@
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 { useCouponCode, usePartnerStats, validateCouponCode } from './hooks';
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 { useCouponCode, usePartnerStats, validateCouponCode } from "./hooks";
7
7
  //# 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,CAAA;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAA;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,8CAA8C,CAAA;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AACxF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA"}
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,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AAE/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAE5D,eAAO,MAAM,uBAAuB,GAClC,cAAc,4BAA4B,KACzC,gBAyIF,CAAA"}
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,gBAyIF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AAE/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAG5D,eAAO,MAAM,6BAA6B,GACxC,cAAc,4BAA4B,KACzC,gBA0LF,CAAA"}
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;AAG7D,eAAO,MAAM,6BAA6B,GACxC,cAAc,4BAA4B,KACzC,gBA0LF,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionConfig } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AAE/C,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAyB5D,eAAO,MAAM,gCAAgC,GAC3C,cAAc,4BAA4B,KACzC,gBAiRF,CAAA"}
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;AAwC7D,eAAO,MAAM,gCAAgC,GAC3C,cAAc,4BAA4B,KACzC,gBAsTF,CAAC"}
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import type { PartnerStats } from '../../types';
1
+ import React from "react";
2
+ import type { PartnerStats } from "../../types";
3
3
  export type EarningsSummaryProps = {
4
4
  stats: PartnerStats;
5
5
  currency: string;
@@ -1 +1 @@
1
- {"version":3,"file":"EarningsSummary.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/EarningsSummary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,YAAY,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAUD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CA4B1D,CAAA;AAED,eAAe,eAAe,CAAA"}
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 'react';
2
- import type { PartnerStats } from '../../types';
1
+ import React from "react";
2
+ import type { PartnerStats } from "../../types";
3
3
  export type RecentReferralsProps = {
4
- referrals: PartnerStats['recentReferrals'];
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,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,YAAY,CAAC,iBAAiB,CAAC,CAAA;IAC1C,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAkBD,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoC1D,CAAA;AAED,eAAe,eAAe,CAAA"}
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 'react';
2
- import type { PartnerDashboardData } from '../../types';
1
+ import React from "react";
2
+ import type { PartnerDashboardData } from "../../types";
3
3
  export type ReferralCodesProps = {
4
- codes: PartnerDashboardData['referralCodes'];
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,CAAA;AAEvC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAA;IAC5C,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAUD,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA+DtD,CAAA;AAED,eAAe,aAAa,CAAA"}
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,5 +1,5 @@
1
- import React from 'react';
2
- import type { PartnerStats } from '../../types';
1
+ import React from "react";
2
+ import type { PartnerStats } from "../../types";
3
3
  export type ReferralPerformanceProps = {
4
4
  stats: PartnerStats;
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ReferralPerformance.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/ReferralPerformance.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE,YAAY,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CA6ClE,CAAA;AAED,eAAe,mBAAmB,CAAA"}
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,5 +1,5 @@
1
- import React from 'react';
2
- import './styles.css';
1
+ import React from "react";
2
+ import "./styles.css";
3
3
  export type PartnerDashboardProps = {
4
4
  showEarningsSummary?: boolean;
5
5
  showReferralPerformance?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAA;AASlD,OAAO,cAAc,CAAA;AAErB,MAAM,MAAM,qBAAqB,GAAG;IAClC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,uBAAuB,CAAC,EAAE,OAAO,CAAA;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqH5D,CAAA;AAED,eAAe,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/PartnerDashboard/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,OAAO,cAAc,CAAC;AAEtB,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,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAqH5D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Endpoint, PayloadHandler } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AACvD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAQ5D,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAA;CAC3C,CAAA;AAcD,eAAO,MAAM,kBAAkB,GAC5B,kBAAkB,IAAI,KAAG,cAyFzB,CAAA;AA4TH,eAAO,MAAM,mBAAmB,GAAI,kBAAkB,IAAI,KAAG,QAI3D,CAAA"}
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;AAcF,eAAO,MAAM,kBAAkB,GAC5B,kBAAkB,IAAI,KAAG,cAyFzB,CAAC;AA4TJ,eAAO,MAAM,mBAAmB,GAAI,kBAAkB,IAAI,KAAG,QAI3D,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Endpoint, PayloadHandler } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AAEvD,OAAO,KAAK,EAAsC,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAGhG,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,mBAAmB,GAC7B,kBAAkB,IAAI,KAAG,cA6KzB,CAAA;AAEH,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,IAAI,KAAG,QAI5D,CAAA"}
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;AAEF,eAAO,MAAM,mBAAmB,GAC7B,kBAAkB,IAAI,KAAG,cA6KzB,CAAC;AAEJ,eAAO,MAAM,oBAAoB,GAAI,kBAAkB,IAAI,KAAG,QAI5D,CAAC"}
@@ -1,5 +1,5 @@
1
- import type { Endpoint, PayloadHandler } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AAEvD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAO5D,KAAK,IAAI,GAAG;IACV,YAAY,EAAE,4BAA4B,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,qBAAqB,GAC/B,kBAAkB,IAAI,KAAG,cAkCzB,CAAA;AA4RH,eAAO,MAAM,sBAAsB,GAAI,kBAAkB,IAAI,KAAG,QAI9D,CAAA"}
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;AAEF,eAAO,MAAM,qBAAqB,GAC/B,kBAAkB,IAAI,KAAG,cAkCzB,CAAC;AA4RJ,eAAO,MAAM,sBAAsB,GAAI,kBAAkB,IAAI,KAAG,QAI9D,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { CollectionBeforeChangeHook } from 'payload';
2
- import type { SanitizedCouponPluginOptions } from '../types';
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,CAAA;AACzD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAS5D,eAAO,MAAM,mBAAmB,GAC7B,cAAc,4BAA4B,KAAG,0BA2N7C,CAAA"}
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;AAS7D,eAAO,MAAM,mBAAmB,GAC7B,cAAc,4BAA4B,KAAG,0BA6N7C,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
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 { calculateCommissionAndDiscount, getProgramMinimumOrderAmount, } from './utilities/calculateValues';
7
- export { getCartTotalWithDiscounts } from './utilities/getCartTotalWithDiscounts';
8
- export { recordCouponUsageForOrder } from './utilities/recordCouponUsageForOrder';
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 { calculateCommissionAndDiscount, getProgramMinimumOrderAmount, } from "./utilities/calculateValues";
7
+ export { getCartTotalWithDiscounts } from "./utilities/getCartTotalWithDiscounts";
8
+ export { recordCouponUsageForOrder } from "./utilities/recordCouponUsageForOrder";
9
9
  export { createCouponsCollection, createReferralCodesCollection, createReferralProgramsCollection, payloadEcommerceCouponPlugin as payloadEcommerceCoupon, };
10
- export type { AdminGroupConfig, ApplyCouponHook, ApplyCouponResponse, CouponPluginAccess, CouponPluginCollections, CouponPluginOptions, OrderIntegrationConfig, PartnerDashboardConfig, PartnerDashboardData, PartnerStats, ReferralProgramConfig, RoleConfig, } from './types';
11
- export type { CartLike } from './utilities/getCartTotalWithDiscounts';
10
+ export type { AdminGroupConfig, ApplyCouponHook, ApplyCouponResponse, CouponPluginAccess, CouponPluginCollections, CouponPluginOptions, OrderIntegrationConfig, PartnerDashboardConfig, PartnerDashboardData, PartnerStats, ReferralProgramConfig, RoleConfig, } from "./types";
11
+ export type { CartLike } from "./utilities/getCartTotalWithDiscounts";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAA;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAA;AAC3F,OAAO,EAAE,gCAAgC,EAAE,MAAM,gDAAgD,CAAA;AACjG,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAA;AAEvD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnF,OAAO,EACL,8BAA8B,EAC9B,4BAA4B,GAC7B,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAA;AACjF,OAAO,EACL,uBAAuB,EACvB,6BAA6B,EAC7B,gCAAgC,EAChC,4BAA4B,IAAI,sBAAsB,GACvD,CAAA;AAED,YAAY,EACV,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAA;AAChB,YAAY,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAA"}
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,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,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,qBAAqB,EACrB,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -335,7 +335,11 @@ const createReferralCodesCollection = (pluginConfig) => {
335
335
  function toNumber(value) {
336
336
  return typeof value === "number" && Number.isFinite(value) ? value : null;
337
337
  }
338
- const deriveCustomerSplit = (partnerSplit) => {
338
+ const deriveCustomerSplit = (partnerSplit, totalCommission) => {
339
+ if (totalCommission?.type === "fixed" && totalCommission.value == null) {
340
+ const partner = toNumber(partnerSplit);
341
+ return partner != null ? partner : 0;
342
+ }
339
343
  const partner = toNumber(partnerSplit);
340
344
  if (partner == null) return 0;
341
345
  if (partner < 0) return 100;
@@ -369,16 +373,23 @@ const createReferralProgramsCollection = (pluginConfig) => {
369
373
  if (!r.totalCommission) throw new Error(`Commission rule ${index + 1}: Total Commission is required`);
370
374
  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(", ")}`);
371
375
  const totalValue = toNumber(r.totalCommission.value);
372
- if (totalValue == null || totalValue < 0) throw new Error(`Commission rule ${index + 1}: Total Commission value must be a non-negative number`);
373
- if (r.totalCommission.type === "percentage" && totalValue > 100) throw new Error(`Commission rule ${index + 1}: Percentage Total Commission cannot exceed 100`);
376
+ if (r.totalCommission.type === "percentage" && (totalValue == null || totalValue < 0)) throw new Error(`Commission rule ${index + 1}: Total Commission value must be a non-negative number`);
377
+ if (r.totalCommission.type === "percentage" && totalValue && totalValue > 100) throw new Error(`Commission rule ${index + 1}: Percentage Total Commission cannot exceed 100`);
374
378
  const maxAmount = toNumber(r.totalCommission.maxAmount);
375
379
  if (maxAmount != null && maxAmount < 0) throw new Error(`Commission rule ${index + 1}: Max Amount must be a non-negative number`);
376
380
  const appliesTo = r.appliesTo ?? "all";
377
381
  if (appliesTo === "products" && (!r.products || r.products.length === 0)) throw new Error(`Commission rule ${index + 1}: At least one product is required`);
378
382
  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`);
379
383
  const partnerSplit = toNumber(r.partnerSplit);
380
- if (partnerSplit == null || partnerSplit < 0 || partnerSplit > 100) throw new Error(`Commission rule ${index + 1}: Partner Split must be between 0 and 100`);
381
- const customerSplit = 100 - partnerSplit;
384
+ if (partnerSplit == null || partnerSplit < 0) throw new Error(`Commission rule ${index + 1}: Partner Split must be a non-negative number`);
385
+ const hasFixedValue = r.totalCommission.type === "fixed" && toNumber(r.totalCommission.value) != null;
386
+ if (!hasFixedValue && r.totalCommission.type !== "fixed" && partnerSplit > 100) throw new Error(`Commission rule ${index + 1}: Partner Split must be between 0 and 100`);
387
+ if (hasFixedValue && partnerSplit > 100) throw new Error(`Commission rule ${index + 1}: Partner Split must be between 0 and 100`);
388
+ let customerSplit = null;
389
+ if (r.totalCommission.type === "fixed" && !hasFixedValue) {
390
+ customerSplit = toNumber(r.customerSplit);
391
+ if (customerSplit == null || customerSplit < 0) throw new Error(`Commission rule ${index + 1}: For fixed commissions with no value, both partnerSplit and customerSplit must be non-negative numbers`);
392
+ } else customerSplit = 100 - partnerSplit;
382
393
  const minOrderAmount = toNumber(r.minOrderAmount);
383
394
  if (minOrderAmount != null && minOrderAmount < 0) throw new Error(`Commission rule ${index + 1}: Minimum Order Amount must be a non-negative number`);
384
395
  return {
@@ -490,9 +501,11 @@ const createReferralProgramsCollection = (pluginConfig) => {
490
501
  {
491
502
  name: "value",
492
503
  type: "number",
493
- required: true,
494
- min: 0,
495
- admin: { description: `Total commission value` }
504
+ admin: {
505
+ condition: ({ siblingData }) => siblingData?.type === "percentage",
506
+ description: "Total commission value (shown for percentage rules; ignored when using fixed split amounts)"
507
+ },
508
+ min: 0
496
509
  },
497
510
  {
498
511
  name: "maxAmount",
@@ -507,9 +520,7 @@ const createReferralProgramsCollection = (pluginConfig) => {
507
520
  type: "number",
508
521
  required: true,
509
522
  min: 0,
510
- max: 100,
511
- defaultValue: referralConfig.defaultPartnerSplit,
512
- admin: { description: "Percentage of total commission given to Partner (0-100)" }
523
+ admin: { description: "For percentage rules this is the percent that goes to the partner; when using fixed type it becomes the literal amount per item" }
513
524
  },
514
525
  {
515
526
  name: "minOrderAmount",
@@ -521,15 +532,14 @@ const createReferralProgramsCollection = (pluginConfig) => {
521
532
  name: "customerSplit",
522
533
  type: "number",
523
534
  min: 0,
524
- max: 100,
525
- hooks: {
526
- beforeValidate: [({ siblingData }) => deriveCustomerSplit(siblingData?.partnerSplit)],
527
- beforeChange: [({ siblingData }) => deriveCustomerSplit(siblingData?.partnerSplit)]
528
- },
529
535
  admin: {
530
- readOnly: true,
531
- description: "Auto-calculated from Partner Split (saved automatically)"
532
- }
536
+ condition: ({ siblingData }) => siblingData?.totalCommission?.type !== "fixed",
537
+ description: "When using percentage rules this is auto-calculated; for fixed-type rules you may enter a literal amount"
538
+ },
539
+ hooks: { beforeValidate: [({ siblingData }) => {
540
+ if (!siblingData) return 0;
541
+ return deriveCustomerSplit(siblingData.partnerSplit, siblingData.totalCommission);
542
+ }] }
533
543
  }
534
544
  ]
535
545
  }
@@ -620,6 +630,15 @@ function calculateItemRewardByRule({ rule, itemTotal, quantity, allowedTotalComm
620
630
  const allowedTypes = allowedCommissionTypesSet(allowedTotalCommissionTypes);
621
631
  if (rule.totalCommission) {
622
632
  if (!allowedTypes.has(rule.totalCommission.type)) return null;
633
+ if (rule.totalCommission.type === "fixed" && rule.totalCommission.value == null) {
634
+ const partnerAmt = typeof rule.partnerSplit === "number" ? rule.partnerSplit : null;
635
+ const customerAmt = typeof rule.customerSplit === "number" ? rule.customerSplit : null;
636
+ if (partnerAmt == null || customerAmt == null) return null;
637
+ return {
638
+ partner: partnerAmt * quantity,
639
+ customer: customerAmt * quantity
640
+ };
641
+ }
623
642
  const splits = getRuleSplits(rule);
624
643
  if (!splits) return null;
625
644
  let totalPot = 0;