@payloadcms/plugin-ecommerce 3.69.0-canary.9 → 3.69.0-internal.35bf893
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beforeChange.d.ts","sourceRoot":"","sources":["../../../src/collections/carts/beforeChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAIzD,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"beforeChange.d.ts","sourceRoot":"","sources":["../../../src/collections/carts/beforeChange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAA;AAIzD,KAAK,KAAK,GAAG;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,0BAwD7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/collections/carts/beforeChange.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook } from 'payload'\n\nimport crypto from 'crypto'\n\ntype Props = {\n productsSlug: string\n variantsSlug: string\n}\n\nexport const beforeChangeCart: (args: Props) => CollectionBeforeChangeHook =\n ({ productsSlug, variantsSlug }) =>\n async ({ data, operation, req }) => {\n // Generate a secret for guest cart access on creation\n if (operation === 'create' && !data.customer && !data.secret) {\n // Generate a cryptographically secure random string\n const secret = crypto.randomBytes(20).toString('hex')\n data.secret = secret\n\n // Store in context so afterRead hook can include it in the creation response\n if (!req.context) {
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/carts/beforeChange.ts"],"sourcesContent":["import type { CollectionBeforeChangeHook } from 'payload'\n\nimport crypto from 'crypto'\n\ntype Props = {\n productsSlug: string\n variantsSlug: string\n}\n\nexport const beforeChangeCart: (args: Props) => CollectionBeforeChangeHook =\n ({ productsSlug, variantsSlug }) =>\n async ({ data, operation, req }) => {\n // Generate a secret for guest cart access on creation\n if (operation === 'create' && !data.customer && !data.secret) {\n // Generate a cryptographically secure random string\n const secret = crypto.randomBytes(20).toString('hex')\n data.secret = secret\n\n // Store in context so afterRead hook can include it in the creation response\n if (!req.context) {\n req.context = {}\n }\n req.context.newCartSecret = secret\n }\n\n // Update subtotal based on items in the cart\n if (data.items && Array.isArray(data.items)) {\n const priceField = `priceIn${data.currency}`\n\n let subtotal = 0\n\n for (const item of data.items) {\n if (item.variant) {\n const id = typeof item.variant === 'object' ? item.variant.id : item.variant\n\n const variant = await req.payload.findByID({\n id,\n collection: variantsSlug,\n depth: 0,\n select: {\n [priceField]: true,\n },\n })\n\n subtotal += variant[priceField] * item.quantity\n } else {\n const id = typeof item.product === 'object' ? item.product.id : item.product\n\n const product = await req.payload.findByID({\n id,\n collection: productsSlug,\n depth: 0,\n select: {\n [priceField]: true,\n },\n })\n\n subtotal += product[priceField] * item.quantity\n }\n }\n\n data.subtotal = subtotal\n } else {\n data.subtotal = 0\n }\n }\n"],"names":["crypto","beforeChangeCart","productsSlug","variantsSlug","data","operation","req","customer","secret","randomBytes","toString","context","newCartSecret","items","Array","isArray","priceField","currency","subtotal","item","variant","id","payload","findByID","collection","depth","select","quantity","product"],"mappings":"AAEA,OAAOA,YAAY,SAAQ;AAO3B,OAAO,MAAMC,mBACX,CAAC,EAAEC,YAAY,EAAEC,YAAY,EAAE,GAC/B,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,GAAG,EAAE;QAC7B,sDAAsD;QACtD,IAAID,cAAc,YAAY,CAACD,KAAKG,QAAQ,IAAI,CAACH,KAAKI,MAAM,EAAE;YAC5D,oDAAoD;YAC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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-ecommerce",
|
|
3
|
-
"version": "3.69.0-
|
|
3
|
+
"version": "3.69.0-internal.35bf893",
|
|
4
4
|
"description": "Ecommerce plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -69,22 +69,22 @@
|
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
71
|
"qs-esm": "7.0.2",
|
|
72
|
-
"@payloadcms/translations": "3.69.0-
|
|
73
|
-
"@payloadcms/ui": "3.69.0-
|
|
72
|
+
"@payloadcms/translations": "3.69.0-internal.35bf893",
|
|
73
|
+
"@payloadcms/ui": "3.69.0-internal.35bf893"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/json-schema": "7.0.15",
|
|
77
77
|
"@types/react": "19.2.1",
|
|
78
78
|
"@types/react-dom": "19.2.1",
|
|
79
79
|
"stripe": "18.3.0",
|
|
80
|
-
"
|
|
80
|
+
"@payloadcms/next": "3.69.0-internal.35bf893",
|
|
81
81
|
"@payloadcms/eslint-config": "3.28.0",
|
|
82
|
-
"
|
|
82
|
+
"payload": "3.69.0-internal.35bf893"
|
|
83
83
|
},
|
|
84
84
|
"peerDependencies": {
|
|
85
85
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
86
86
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
87
|
-
"payload": "3.69.0-
|
|
87
|
+
"payload": "3.69.0-internal.35bf893"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"registry": "https://registry.npmjs.org/"
|