@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.
- package/dist/client/hooks.d.ts +1 -1
- package/dist/client/hooks.d.ts.map +1 -1
- package/dist/client/index.d.ts +6 -6
- 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/EarningsSummary.d.ts +2 -2
- package/dist/components/PartnerDashboard/EarningsSummary.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 +2 -2
- 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 +10 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -19
- 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,4 +1,4 @@
|
|
|
1
|
-
import type { ApplyCouponHook, ApplyCouponResponse, PartnerDashboardData } from
|
|
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,
|
|
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"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { PartnerDashboard } from
|
|
2
|
-
export { EarningsSummary } from
|
|
3
|
-
export { RecentReferrals } from
|
|
4
|
-
export { ReferralCodes } from
|
|
5
|
-
export { ReferralPerformance } from
|
|
6
|
-
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 { 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,
|
|
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
|
|
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,gBAyIF,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;AAG7D,eAAO,MAAM,6BAA6B,GACxC,cAAc,4BAA4B,KACzC,gBA0LF,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;AAwC7D,eAAO,MAAM,gCAAgC,GAC3C,cAAc,4BAA4B,KACzC,gBAsTF,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 { 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;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
|
|
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;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
|
|
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;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
|
|
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;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
|
|
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;AAS7D,eAAO,MAAM,mBAAmB,GAC7B,cAAc,4BAA4B,KAAG,0BA6N7C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { createCouponsCollection } from
|
|
2
|
-
import { createReferralCodesCollection } from
|
|
3
|
-
import { createReferralProgramsCollection } from
|
|
4
|
-
import { payloadEcommerceCouponPlugin } from
|
|
5
|
-
export { useCouponCode, usePartnerStats, validateCouponCode } from
|
|
6
|
-
export { calculateCommissionAndDiscount, getProgramMinimumOrderAmount, } from
|
|
7
|
-
export { getCartTotalWithDiscounts } from
|
|
8
|
-
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 { 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
|
|
11
|
-
export type { CartLike } from
|
|
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
|
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,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
|
|
381
|
-
const
|
|
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
|
-
|
|
494
|
-
|
|
495
|
-
|
|
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
|
-
|
|
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
|
-
|
|
531
|
-
description: "
|
|
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;
|