@payloadcms/plugin-ecommerce 0.0.1-beta.0 → 3.57.0-internal.46327a6
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/collections/addresses/createAddressesCollection.d.ts +21 -0
- package/dist/collections/addresses/createAddressesCollection.d.ts.map +1 -0
- package/dist/collections/addresses/createAddressesCollection.js +71 -0
- package/dist/collections/addresses/createAddressesCollection.js.map +1 -0
- package/dist/collections/addresses/defaultAddressFields.d.ts +3 -0
- package/dist/collections/addresses/defaultAddressFields.d.ts.map +1 -0
- package/dist/collections/addresses/defaultAddressFields.js +72 -0
- package/dist/collections/addresses/defaultAddressFields.js.map +1 -0
- package/dist/collections/addresses/defaultCountries.d.ts +9 -0
- package/dist/collections/addresses/defaultCountries.d.ts.map +1 -0
- package/dist/collections/addresses/defaultCountries.js +169 -0
- package/dist/collections/addresses/defaultCountries.js.map +1 -0
- package/dist/collections/addresses/hooks/beforeChange.d.ts +8 -0
- package/dist/collections/addresses/hooks/beforeChange.d.ts.map +1 -0
- package/dist/collections/addresses/hooks/beforeChange.js +12 -0
- package/dist/collections/addresses/hooks/beforeChange.js.map +1 -0
- package/dist/collections/carts/beforeChange.d.ts +8 -0
- package/dist/collections/carts/beforeChange.d.ts.map +1 -0
- package/dist/collections/carts/beforeChange.js +37 -0
- package/dist/collections/carts/beforeChange.js.map +1 -0
- package/dist/collections/carts/createCartsCollection.d.ts +29 -0
- package/dist/collections/carts/createCartsCollection.d.ts.map +1 -0
- package/dist/collections/carts/createCartsCollection.js +138 -0
- package/dist/collections/carts/createCartsCollection.js.map +1 -0
- package/dist/collections/carts/statusBeforeRead.d.ts +3 -0
- package/dist/collections/carts/statusBeforeRead.d.ts.map +1 -0
- package/dist/collections/carts/statusBeforeRead.js +18 -0
- package/dist/collections/carts/statusBeforeRead.js.map +1 -0
- package/dist/collections/orders/createOrdersCollection.d.ts +34 -0
- package/dist/collections/orders/createOrdersCollection.d.ts.map +1 -0
- package/dist/collections/orders/createOrdersCollection.js +162 -0
- package/dist/collections/orders/createOrdersCollection.js.map +1 -0
- package/dist/collections/products/createProductsCollection.d.ts +26 -0
- package/dist/collections/products/createProductsCollection.d.ts.map +1 -0
- package/dist/collections/products/createProductsCollection.js +62 -0
- package/dist/collections/products/createProductsCollection.js.map +1 -0
- package/dist/collections/transactions/createTransactionsCollection.d.ts +40 -0
- package/dist/collections/transactions/createTransactionsCollection.d.ts.map +1 -0
- package/dist/collections/transactions/createTransactionsCollection.js +157 -0
- package/dist/collections/transactions/createTransactionsCollection.js.map +1 -0
- package/dist/collections/variants/createVariantOptionsCollection.d.ts +15 -0
- package/dist/collections/variants/createVariantOptionsCollection.d.ts.map +1 -0
- package/dist/collections/variants/createVariantOptionsCollection.js +53 -0
- package/dist/collections/variants/createVariantOptionsCollection.js.map +1 -0
- package/dist/collections/variants/createVariantTypesCollection.d.ts +15 -0
- package/dist/collections/variants/createVariantTypesCollection.d.ts.map +1 -0
- package/dist/collections/variants/createVariantTypesCollection.js +49 -0
- package/dist/collections/variants/createVariantTypesCollection.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.d.ts +8 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.js +38 -0
- package/dist/collections/variants/createVariantsCollection/hooks/beforeChange.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.d.ts +7 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.js +53 -0
- package/dist/collections/variants/createVariantsCollection/hooks/validateOptions.js.map +1 -0
- package/dist/collections/variants/createVariantsCollection/index.d.ts +24 -0
- package/dist/collections/variants/createVariantsCollection/index.d.ts.map +1 -0
- package/dist/collections/variants/createVariantsCollection/index.js +101 -0
- package/dist/collections/variants/createVariantsCollection/index.js.map +1 -0
- package/dist/currencies/index.d.ts +5 -0
- package/dist/currencies/index.d.ts.map +1 -0
- package/dist/currencies/index.js +20 -0
- package/dist/currencies/index.js.map +1 -0
- package/dist/endpoints/confirmOrder.d.ts +42 -0
- package/dist/endpoints/confirmOrder.d.ts.map +1 -0
- package/dist/endpoints/confirmOrder.js +143 -0
- package/dist/endpoints/confirmOrder.js.map +1 -0
- package/dist/endpoints/initiatePayment.d.ts +43 -0
- package/dist/endpoints/initiatePayment.d.ts.map +1 -0
- package/dist/endpoints/initiatePayment.js +220 -0
- package/dist/endpoints/initiatePayment.js.map +1 -0
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -0
- package/dist/exports/client/index.js +4 -0
- package/dist/exports/client/index.js.map +1 -0
- package/dist/exports/client/react.d.ts +4 -0
- package/dist/exports/client/react.d.ts.map +1 -0
- package/dist/exports/client/react.js +5 -0
- package/dist/exports/client/react.js.map +1 -0
- package/dist/exports/payments/stripe.d.ts +2 -0
- package/dist/exports/payments/stripe.d.ts.map +1 -0
- package/dist/exports/payments/stripe.js +3 -0
- package/dist/exports/payments/stripe.js.map +1 -0
- package/dist/exports/rsc.d.ts +3 -0
- package/dist/exports/rsc.d.ts.map +1 -0
- package/dist/exports/rsc.js +4 -0
- package/dist/exports/rsc.js.map +1 -0
- package/dist/exports/translations.d.ts +2 -0
- package/dist/exports/translations.d.ts.map +1 -0
- package/dist/exports/translations.js +3 -0
- package/dist/exports/translations.js.map +1 -0
- package/dist/exports/types.d.ts +2 -0
- package/dist/exports/types.d.ts.map +1 -0
- package/dist/exports/types.js +3 -0
- package/dist/exports/types.js.map +1 -0
- package/dist/fields/amountField.d.ts +13 -0
- package/dist/fields/amountField.d.ts.map +1 -0
- package/dist/fields/amountField.js +33 -0
- package/dist/fields/amountField.js.map +1 -0
- package/dist/fields/cartItemsField.d.ts +26 -0
- package/dist/fields/cartItemsField.d.ts.map +1 -0
- package/dist/fields/cartItemsField.js +55 -0
- package/dist/fields/cartItemsField.js.map +1 -0
- package/dist/fields/currencyField.d.ts +9 -0
- package/dist/fields/currencyField.d.ts.map +1 -0
- package/dist/fields/currencyField.js +29 -0
- package/dist/fields/currencyField.js.map +1 -0
- package/dist/fields/inventoryField.d.ts +7 -0
- package/dist/fields/inventoryField.d.ts.map +1 -0
- package/dist/fields/inventoryField.js +16 -0
- package/dist/fields/inventoryField.js.map +1 -0
- package/dist/fields/pricesField.d.ts +12 -0
- package/dist/fields/pricesField.d.ts.map +1 -0
- package/dist/fields/pricesField.js +54 -0
- package/dist/fields/pricesField.js.map +1 -0
- package/dist/fields/statusField.d.ts +8 -0
- package/dist/fields/statusField.d.ts.map +1 -0
- package/dist/fields/statusField.js +49 -0
- package/dist/fields/statusField.js.map +1 -0
- package/dist/fields/variantsFields.d.ts +14 -0
- package/dist/fields/variantsFields.d.ts.map +1 -0
- package/dist/fields/variantsFields.js +48 -0
- package/dist/fields/variantsFields.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +238 -0
- package/dist/index.js.map +1 -0
- package/dist/payments/adapters/stripe/confirmOrder.d.ts +11 -0
- package/dist/payments/adapters/stripe/confirmOrder.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/confirmOrder.js +101 -0
- package/dist/payments/adapters/stripe/confirmOrder.js.map +1 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.d.ts +13 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.js +53 -0
- package/dist/payments/adapters/stripe/endpoints/webhooks.js.map +1 -0
- package/dist/payments/adapters/stripe/index.d.ts +60 -0
- package/dist/payments/adapters/stripe/index.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/index.js +68 -0
- package/dist/payments/adapters/stripe/index.js.map +1 -0
- package/dist/payments/adapters/stripe/initiatePayment.d.ts +11 -0
- package/dist/payments/adapters/stripe/initiatePayment.d.ts.map +1 -0
- package/dist/payments/adapters/stripe/initiatePayment.js +102 -0
- package/dist/payments/adapters/stripe/initiatePayment.js.map +1 -0
- package/dist/react/provider/index.d.ts +41 -0
- package/dist/react/provider/index.d.ts.map +1 -0
- package/dist/react/provider/index.js +791 -0
- package/dist/react/provider/index.js.map +1 -0
- package/dist/react/provider/types.d.ts +171 -0
- package/dist/react/provider/types.d.ts.map +1 -0
- package/dist/react/provider/types.js +3 -0
- package/dist/react/provider/types.js.map +1 -0
- package/dist/react/provider/utilities.d.ts +9 -0
- package/dist/react/provider/utilities.d.ts.map +1 -0
- package/dist/react/provider/utilities.js +13 -0
- package/dist/react/provider/utilities.js.map +1 -0
- package/dist/translations/en.d.ts +3 -0
- package/dist/translations/en.d.ts.map +1 -0
- package/dist/translations/en.js +86 -0
- package/dist/translations/en.js.map +1 -0
- package/dist/translations/index.d.ts +7 -0
- package/dist/translations/index.d.ts.map +1 -0
- package/dist/translations/index.js +6 -0
- package/dist/translations/index.js.map +1 -0
- package/dist/types.d.ts +658 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/ui/PriceCell/index.d.ts +12 -0
- package/dist/ui/PriceCell/index.d.ts.map +1 -0
- package/dist/ui/PriceCell/index.js +38 -0
- package/dist/ui/PriceCell/index.js.map +1 -0
- package/dist/ui/PriceInput/FormattedInput.d.ts +17 -0
- package/dist/ui/PriceInput/FormattedInput.d.ts.map +1 -0
- package/dist/ui/PriceInput/FormattedInput.js +146 -0
- package/dist/ui/PriceInput/FormattedInput.js.map +1 -0
- package/{src/ui/PriceInput/index.scss → dist/ui/PriceInput/index.css} +7 -0
- package/dist/ui/PriceInput/index.d.ts +11 -0
- package/dist/ui/PriceInput/index.d.ts.map +1 -0
- package/dist/ui/PriceInput/index.js +20 -0
- package/dist/ui/PriceInput/index.js.map +1 -0
- package/dist/ui/PriceRowLabel/index.d.ts +8 -0
- package/dist/ui/PriceRowLabel/index.d.ts.map +1 -0
- package/dist/ui/PriceRowLabel/index.js +66 -0
- package/dist/ui/PriceRowLabel/index.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.d.ts +8 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.js +28 -0
- package/dist/ui/VariantOptionsSelector/ErrorBox.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.d.ts +13 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.js +71 -0
- package/dist/ui/VariantOptionsSelector/OptionsSelect.js.map +1 -0
- package/dist/ui/VariantOptionsSelector/index.d.ts +6 -0
- package/dist/ui/VariantOptionsSelector/index.d.ts.map +1 -0
- package/dist/ui/VariantOptionsSelector/index.js +78 -0
- package/dist/ui/VariantOptionsSelector/index.js.map +1 -0
- package/dist/ui/utilities.d.ts +16 -0
- package/dist/ui/utilities.d.ts.map +1 -0
- package/dist/ui/utilities.js +26 -0
- package/dist/ui/utilities.js.map +1 -0
- package/dist/utilities/defaultProductsValidation.d.ts +3 -0
- package/dist/utilities/defaultProductsValidation.d.ts.map +1 -0
- package/dist/utilities/defaultProductsValidation.js +40 -0
- package/dist/utilities/defaultProductsValidation.js.map +1 -0
- package/dist/utilities/errorCodes.d.ts +3 -0
- package/dist/utilities/errorCodes.d.ts.map +1 -0
- package/dist/utilities/errorCodes.js +4 -0
- package/dist/utilities/errorCodes.js.map +1 -0
- package/dist/utilities/getCollectionSlugMap.d.ts +11 -0
- package/dist/utilities/getCollectionSlugMap.d.ts.map +1 -0
- package/dist/utilities/getCollectionSlugMap.js +25 -0
- package/dist/utilities/getCollectionSlugMap.js.map +1 -0
- package/dist/utilities/sanitizePluginConfig.d.ts +7 -0
- package/dist/utilities/sanitizePluginConfig.d.ts.map +1 -0
- package/dist/utilities/sanitizePluginConfig.js +67 -0
- package/dist/utilities/sanitizePluginConfig.js.map +1 -0
- package/package.json +98 -1
- package/.prettierignore +0 -12
- package/.swcrc +0 -24
- package/eslint.config.js +0 -18
- package/src/addresses/addressesCollection.ts +0 -76
- package/src/addresses/defaultAddressFields.ts +0 -83
- package/src/addresses/defaultCountries.ts +0 -50
- package/src/carts/beforeChange.ts +0 -51
- package/src/carts/cartsCollection.ts +0 -146
- package/src/currencies/index.ts +0 -29
- package/src/endpoints/confirmOrder.ts +0 -312
- package/src/endpoints/initiatePayment.ts +0 -322
- package/src/exports/addresses.ts +0 -2
- package/src/exports/currencies.ts +0 -1
- package/src/exports/fields.ts +0 -5
- package/src/exports/orders.ts +0 -1
- package/src/exports/payments/stripe.ts +0 -1
- package/src/exports/plugin.ts +0 -1
- package/src/exports/products.ts +0 -1
- package/src/exports/react.ts +0 -8
- package/src/exports/transactions.ts +0 -1
- package/src/exports/translations.ts +0 -1
- package/src/exports/types.ts +0 -7
- package/src/exports/ui.ts +0 -3
- package/src/exports/variants.ts +0 -5
- package/src/fields/amountField.ts +0 -43
- package/src/fields/cartItemsField.ts +0 -84
- package/src/fields/currencyField.ts +0 -39
- package/src/fields/inventoryField.ts +0 -22
- package/src/fields/pricesField.ts +0 -65
- package/src/fields/statusField.ts +0 -57
- package/src/fields/variantsFields.ts +0 -56
- package/src/index.ts +0 -275
- package/src/orders/ordersCollection.ts +0 -157
- package/src/payments/adapters/stripe/confirmOrder.ts +0 -123
- package/src/payments/adapters/stripe/endpoints/webhooks.ts +0 -69
- package/src/payments/adapters/stripe/index.ts +0 -135
- package/src/payments/adapters/stripe/initiatePayment.ts +0 -131
- package/src/products/productsCollection.ts +0 -78
- package/src/react/provider/index.tsx +0 -893
- package/src/react/provider/types.ts +0 -184
- package/src/react/provider/utilities.ts +0 -22
- package/src/transactions/transactionsCollection.ts +0 -166
- package/src/translations/en.ts +0 -64
- package/src/translations/index.ts +0 -11
- package/src/types.ts +0 -403
- package/src/ui/PriceInput/FormattedInput.tsx +0 -134
- package/src/ui/PriceInput/index.tsx +0 -43
- package/src/ui/PriceInput/utilities.ts +0 -46
- package/src/ui/PriceRowLabel/index.tsx +0 -56
- package/src/ui/VariantOptionsSelector/ErrorBox.tsx +0 -27
- package/src/ui/VariantOptionsSelector/OptionsSelect.tsx +0 -78
- package/src/ui/VariantOptionsSelector/index.tsx +0 -83
- package/src/utilities/defaultProductsValidation.ts +0 -42
- package/src/utilities/errorCodes.ts +0 -14
- package/src/utilities/getCollectionSlugMap.ts +0 -84
- package/src/utilities/sanitizePluginConfig.ts +0 -80
- package/src/variants/variantOptionsCollection.ts +0 -59
- package/src/variants/variantTypesCollection.ts +0 -55
- package/src/variants/variantsCollection/hooks/beforeChange.ts +0 -47
- package/src/variants/variantsCollection/hooks/validateOptions.ts +0 -72
- package/src/variants/variantsCollection/index.ts +0 -119
- package/tsconfig.json +0 -7
- package/tsconfig.tsbuildinfo +0 -1
- /package/{src → dist}/translations/translation-schema.json +0 -0
- /package/{src → dist}/ui/PriceRowLabel/index.css +0 -0
- /package/{src → dist}/ui/VariantOptionsSelector/index.css +0 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { amountField } from '../../fields/amountField.js';
|
|
2
|
+
import { cartItemsField } from '../../fields/cartItemsField.js';
|
|
3
|
+
import { currencyField } from '../../fields/currencyField.js';
|
|
4
|
+
import { beforeChangeCart } from './beforeChange.js';
|
|
5
|
+
import { statusBeforeRead } from './statusBeforeRead.js';
|
|
6
|
+
export const createCartsCollection = (props)=>{
|
|
7
|
+
const { access: { adminOrCustomerOwner, publicAccess }, currenciesConfig, customersSlug = 'users', enableVariants = false, productsSlug = 'products', variantsSlug = 'variants' } = props || {};
|
|
8
|
+
const fields = [
|
|
9
|
+
cartItemsField({
|
|
10
|
+
enableVariants,
|
|
11
|
+
overrides: {
|
|
12
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
13
|
+
t('plugin-ecommerce:items'),
|
|
14
|
+
labels: {
|
|
15
|
+
plural: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
16
|
+
t('plugin-ecommerce:items'),
|
|
17
|
+
singular: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
18
|
+
t('plugin-ecommerce:item')
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
productsSlug,
|
|
22
|
+
variantsSlug
|
|
23
|
+
}),
|
|
24
|
+
{
|
|
25
|
+
name: 'customer',
|
|
26
|
+
type: 'relationship',
|
|
27
|
+
admin: {
|
|
28
|
+
position: 'sidebar'
|
|
29
|
+
},
|
|
30
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
31
|
+
t('plugin-ecommerce:customer'),
|
|
32
|
+
relationTo: customersSlug
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'purchasedAt',
|
|
36
|
+
type: 'date',
|
|
37
|
+
admin: {
|
|
38
|
+
date: {
|
|
39
|
+
pickerAppearance: 'dayAndTime'
|
|
40
|
+
},
|
|
41
|
+
position: 'sidebar'
|
|
42
|
+
},
|
|
43
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
44
|
+
t('plugin-ecommerce:purchasedAt')
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'status',
|
|
48
|
+
type: 'select',
|
|
49
|
+
admin: {
|
|
50
|
+
position: 'sidebar',
|
|
51
|
+
readOnly: true
|
|
52
|
+
},
|
|
53
|
+
hooks: {
|
|
54
|
+
afterRead: [
|
|
55
|
+
statusBeforeRead
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
59
|
+
t('plugin-ecommerce:status'),
|
|
60
|
+
options: [
|
|
61
|
+
{
|
|
62
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
63
|
+
label: ({ t })=>t('plugin-ecommerce:active'),
|
|
64
|
+
value: 'active'
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
68
|
+
label: ({ t })=>t('plugin-ecommerce:purchased'),
|
|
69
|
+
value: 'purchased'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
73
|
+
label: ({ t })=>t('plugin-ecommerce:abandoned'),
|
|
74
|
+
value: 'abandoned'
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
virtual: true
|
|
78
|
+
},
|
|
79
|
+
...currenciesConfig ? [
|
|
80
|
+
{
|
|
81
|
+
type: 'row',
|
|
82
|
+
admin: {
|
|
83
|
+
position: 'sidebar'
|
|
84
|
+
},
|
|
85
|
+
fields: [
|
|
86
|
+
amountField({
|
|
87
|
+
currenciesConfig,
|
|
88
|
+
overrides: {
|
|
89
|
+
name: 'subtotal',
|
|
90
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
91
|
+
t('plugin-ecommerce:subtotal')
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
currencyField({
|
|
95
|
+
currenciesConfig
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
] : []
|
|
100
|
+
];
|
|
101
|
+
const baseConfig = {
|
|
102
|
+
slug: 'carts',
|
|
103
|
+
access: {
|
|
104
|
+
create: publicAccess,
|
|
105
|
+
delete: adminOrCustomerOwner,
|
|
106
|
+
read: adminOrCustomerOwner,
|
|
107
|
+
update: adminOrCustomerOwner
|
|
108
|
+
},
|
|
109
|
+
admin: {
|
|
110
|
+
description: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
111
|
+
t('plugin-ecommerce:cartsCollectionDescription'),
|
|
112
|
+
group: 'Ecommerce',
|
|
113
|
+
useAsTitle: 'createdAt'
|
|
114
|
+
},
|
|
115
|
+
fields,
|
|
116
|
+
hooks: {
|
|
117
|
+
beforeChange: [
|
|
118
|
+
// This hook can be used to update the subtotal before saving the cart
|
|
119
|
+
beforeChangeCart({
|
|
120
|
+
productsSlug,
|
|
121
|
+
variantsSlug
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
},
|
|
125
|
+
labels: {
|
|
126
|
+
plural: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
127
|
+
t('plugin-ecommerce:carts'),
|
|
128
|
+
singular: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
129
|
+
t('plugin-ecommerce:cart')
|
|
130
|
+
},
|
|
131
|
+
timestamps: true
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
...baseConfig
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=createCartsCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/carts/createCartsCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\nimport { beforeChangeCart } from './beforeChange.js'\nimport { statusBeforeRead } from './statusBeforeRead.js'\n\ntype Props = {\n access: {\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n publicAccess: NonNullable<AccessConfig['publicAccess']>\n }\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n /**\n * Enables support for variants in the cart.\n * Defaults to false.\n */\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createCartsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOrCustomerOwner, publicAccess },\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n cartItemsField({\n enableVariants,\n overrides: {\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'purchasedAt',\n type: 'date',\n admin: {\n date: { pickerAppearance: 'dayAndTime' },\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:purchasedAt'),\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n readOnly: true,\n },\n hooks: {\n afterRead: [statusBeforeRead],\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:active'),\n value: 'active',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:purchased'),\n value: 'purchased',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:abandoned'),\n value: 'abandoned',\n },\n ],\n virtual: true,\n },\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: { position: 'sidebar' },\n fields: [\n amountField({\n currenciesConfig,\n overrides: {\n name: 'subtotal',\n\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:subtotal'),\n },\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'carts',\n access: {\n create: publicAccess,\n delete: adminOrCustomerOwner,\n read: adminOrCustomerOwner,\n update: adminOrCustomerOwner,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cartsCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n hooks: {\n beforeChange: [\n // This hook can be used to update the subtotal before saving the cart\n beforeChangeCart({ productsSlug, variantsSlug }),\n ],\n },\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:carts'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:cart'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","beforeChangeCart","statusBeforeRead","createCartsCollection","props","access","adminOrCustomerOwner","publicAccess","currenciesConfig","customersSlug","enableVariants","productsSlug","variantsSlug","fields","overrides","label","t","labels","plural","singular","name","type","admin","position","relationTo","date","pickerAppearance","readOnly","hooks","afterRead","options","value","virtual","baseConfig","slug","create","delete","read","update","description","group","useAsTitle","beforeChange","timestamps"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statusBeforeRead.d.ts","sourceRoot":"","sources":["../../../src/collections/carts/statusBeforeRead.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,eAAO,MAAM,gBAAgB,EAAE,SAiB9B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const statusBeforeRead = ({ data })=>{
|
|
2
|
+
if (data?.purchasedAt) {
|
|
3
|
+
return 'purchased';
|
|
4
|
+
}
|
|
5
|
+
if (data?.createdAt) {
|
|
6
|
+
const timeNow = new Date().getTime();
|
|
7
|
+
const createdAt = new Date(data.createdAt).getTime();
|
|
8
|
+
const differenceToCheck = 7 * 24 * 60 * 60 * 1000 // 7 days
|
|
9
|
+
;
|
|
10
|
+
if (timeNow - createdAt < differenceToCheck) {
|
|
11
|
+
// If the cart was created within the last 7 days, it is considered 'active'
|
|
12
|
+
return 'active';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return 'abandoned';
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=statusBeforeRead.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/carts/statusBeforeRead.ts"],"sourcesContent":["import type { FieldHook } from 'payload'\n\nexport const statusBeforeRead: FieldHook = ({ data }) => {\n if (data?.purchasedAt) {\n return 'purchased'\n }\n\n if (data?.createdAt) {\n const timeNow = new Date().getTime()\n const createdAt = new Date(data.createdAt).getTime()\n const differenceToCheck = 7 * 24 * 60 * 60 * 1000 // 7 days\n\n if (timeNow - createdAt < differenceToCheck) {\n // If the cart was created within the last 7 days, it is considered 'active'\n return 'active'\n }\n }\n\n return 'abandoned'\n}\n"],"names":["statusBeforeRead","data","purchasedAt","createdAt","timeNow","Date","getTime","differenceToCheck"],"mappings":"AAEA,OAAO,MAAMA,mBAA8B,CAAC,EAAEC,IAAI,EAAE;IAClD,IAAIA,MAAMC,aAAa;QACrB,OAAO;IACT;IAEA,IAAID,MAAME,WAAW;QACnB,MAAMC,UAAU,IAAIC,OAAOC,OAAO;QAClC,MAAMH,YAAY,IAAIE,KAAKJ,KAAKE,SAAS,EAAEG,OAAO;QAClD,MAAMC,oBAAoB,IAAI,KAAK,KAAK,KAAK,KAAK,SAAS;;QAE3D,IAAIH,UAAUD,YAAYI,mBAAmB;YAC3C,4EAA4E;YAC5E,OAAO;QACT;IACF;IAEA,OAAO;AACT,EAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig } from '../../types.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
access: {
|
|
5
|
+
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
6
|
+
adminOnlyFieldAccess: NonNullable<AccessConfig['adminOnlyFieldAccess']>;
|
|
7
|
+
adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Array of fields used for capturing the shipping address data.
|
|
11
|
+
*/
|
|
12
|
+
addressFields?: Field[];
|
|
13
|
+
currenciesConfig?: CurrenciesConfig;
|
|
14
|
+
/**
|
|
15
|
+
* Slug of the customers collection, defaults to 'users'.
|
|
16
|
+
*/
|
|
17
|
+
customersSlug?: string;
|
|
18
|
+
enableVariants?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Slug of the products collection, defaults to 'products'.
|
|
21
|
+
*/
|
|
22
|
+
productsSlug?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Slug of the transactions collection, defaults to 'transactions'.
|
|
25
|
+
*/
|
|
26
|
+
transactionsSlug?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Slug of the variants collection, defaults to 'variants'.
|
|
29
|
+
*/
|
|
30
|
+
variantsSlug?: string;
|
|
31
|
+
};
|
|
32
|
+
export declare const createOrdersCollection: (props: Props) => CollectionConfig;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=createOrdersCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOrdersCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/orders/createOrdersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAMpE,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,oBAAoB,EAAE,WAAW,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;QACvE,oBAAoB,EAAE,WAAW,CAAC,YAAY,CAAC,sBAAsB,CAAC,CAAC,CAAA;KACxE,CAAA;IACD;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;IACvB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,sBAAsB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBAwLtD,CAAA"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { amountField } from '../../fields/amountField.js';
|
|
2
|
+
import { cartItemsField } from '../../fields/cartItemsField.js';
|
|
3
|
+
import { currencyField } from '../../fields/currencyField.js';
|
|
4
|
+
export const createOrdersCollection = (props)=>{
|
|
5
|
+
const { access: { adminOnly, adminOnlyFieldAccess, adminOrCustomerOwner }, addressFields, currenciesConfig, customersSlug = 'users', enableVariants = false, productsSlug = 'products', transactionsSlug = 'transactions', variantsSlug = 'variants' } = props || {};
|
|
6
|
+
const fields = [
|
|
7
|
+
{
|
|
8
|
+
type: 'tabs',
|
|
9
|
+
tabs: [
|
|
10
|
+
{
|
|
11
|
+
fields: [
|
|
12
|
+
cartItemsField({
|
|
13
|
+
enableVariants,
|
|
14
|
+
overrides: {
|
|
15
|
+
name: 'items',
|
|
16
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
17
|
+
t('plugin-ecommerce:items'),
|
|
18
|
+
labels: {
|
|
19
|
+
plural: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
20
|
+
t('plugin-ecommerce:items'),
|
|
21
|
+
singular: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
22
|
+
t('plugin-ecommerce:item')
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
productsSlug,
|
|
26
|
+
variantsSlug
|
|
27
|
+
})
|
|
28
|
+
],
|
|
29
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
30
|
+
t('plugin-ecommerce:orderDetails')
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
fields: [
|
|
34
|
+
...addressFields ? [
|
|
35
|
+
{
|
|
36
|
+
name: 'shippingAddress',
|
|
37
|
+
type: 'group',
|
|
38
|
+
fields: addressFields,
|
|
39
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
40
|
+
t('plugin-ecommerce:shippingAddress')
|
|
41
|
+
}
|
|
42
|
+
] : []
|
|
43
|
+
],
|
|
44
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
45
|
+
t('plugin-ecommerce:shipping')
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'customer',
|
|
51
|
+
type: 'relationship',
|
|
52
|
+
admin: {
|
|
53
|
+
position: 'sidebar'
|
|
54
|
+
},
|
|
55
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
56
|
+
t('plugin-ecommerce:customer'),
|
|
57
|
+
relationTo: customersSlug
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: 'customerEmail',
|
|
61
|
+
type: 'email',
|
|
62
|
+
admin: {
|
|
63
|
+
position: 'sidebar'
|
|
64
|
+
},
|
|
65
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
66
|
+
t('plugin-ecommerce:customerEmail')
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'transactions',
|
|
70
|
+
type: 'relationship',
|
|
71
|
+
access: {
|
|
72
|
+
create: adminOnlyFieldAccess,
|
|
73
|
+
read: adminOnlyFieldAccess,
|
|
74
|
+
update: adminOnlyFieldAccess
|
|
75
|
+
},
|
|
76
|
+
admin: {
|
|
77
|
+
position: 'sidebar'
|
|
78
|
+
},
|
|
79
|
+
hasMany: true,
|
|
80
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
81
|
+
t('plugin-ecommerce:transactions'),
|
|
82
|
+
relationTo: transactionsSlug
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'status',
|
|
86
|
+
type: 'select',
|
|
87
|
+
admin: {
|
|
88
|
+
position: 'sidebar'
|
|
89
|
+
},
|
|
90
|
+
defaultValue: 'processing',
|
|
91
|
+
interfaceName: 'OrderStatus',
|
|
92
|
+
label: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
93
|
+
t('plugin-ecommerce:status'),
|
|
94
|
+
options: [
|
|
95
|
+
{
|
|
96
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
97
|
+
label: ({ t })=>t('plugin-ecommerce:processing'),
|
|
98
|
+
value: 'processing'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
102
|
+
label: ({ t })=>t('plugin-ecommerce:completed'),
|
|
103
|
+
value: 'completed'
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
107
|
+
label: ({ t })=>t('plugin-ecommerce:cancelled'),
|
|
108
|
+
value: 'cancelled'
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
// @ts-expect-error - translations are not typed in plugins yet
|
|
112
|
+
label: ({ t })=>t('plugin-ecommerce:refunded'),
|
|
113
|
+
value: 'refunded'
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
},
|
|
117
|
+
...currenciesConfig ? [
|
|
118
|
+
{
|
|
119
|
+
type: 'row',
|
|
120
|
+
admin: {
|
|
121
|
+
position: 'sidebar'
|
|
122
|
+
},
|
|
123
|
+
fields: [
|
|
124
|
+
amountField({
|
|
125
|
+
currenciesConfig
|
|
126
|
+
}),
|
|
127
|
+
currencyField({
|
|
128
|
+
currenciesConfig
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
] : []
|
|
133
|
+
];
|
|
134
|
+
const baseConfig = {
|
|
135
|
+
slug: 'orders',
|
|
136
|
+
access: {
|
|
137
|
+
create: adminOnly,
|
|
138
|
+
delete: adminOnly,
|
|
139
|
+
read: adminOrCustomerOwner,
|
|
140
|
+
update: adminOnly
|
|
141
|
+
},
|
|
142
|
+
admin: {
|
|
143
|
+
description: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
144
|
+
t('plugin-ecommerce:ordersCollectionDescription'),
|
|
145
|
+
group: 'Ecommerce',
|
|
146
|
+
useAsTitle: 'createdAt'
|
|
147
|
+
},
|
|
148
|
+
fields,
|
|
149
|
+
labels: {
|
|
150
|
+
plural: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
151
|
+
t('plugin-ecommerce:orders'),
|
|
152
|
+
singular: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
153
|
+
t('plugin-ecommerce:order')
|
|
154
|
+
},
|
|
155
|
+
timestamps: true
|
|
156
|
+
};
|
|
157
|
+
return {
|
|
158
|
+
...baseConfig
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
//# sourceMappingURL=createOrdersCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/orders/createOrdersCollection.ts"],"sourcesContent":["import type { CollectionConfig, Field } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig } from '../../types.js'\n\nimport { amountField } from '../../fields/amountField.js'\nimport { cartItemsField } from '../../fields/cartItemsField.js'\nimport { currencyField } from '../../fields/currencyField.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOnlyFieldAccess: NonNullable<AccessConfig['adminOnlyFieldAccess']>\n adminOrCustomerOwner: NonNullable<AccessConfig['adminOrCustomerOwner']>\n }\n /**\n * Array of fields used for capturing the shipping address data.\n */\n addressFields?: Field[]\n currenciesConfig?: CurrenciesConfig\n /**\n * Slug of the customers collection, defaults to 'users'.\n */\n customersSlug?: string\n enableVariants?: boolean\n /**\n * Slug of the products collection, defaults to 'products'.\n */\n productsSlug?: string\n /**\n * Slug of the transactions collection, defaults to 'transactions'.\n */\n transactionsSlug?: string\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n}\n\nexport const createOrdersCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOnlyFieldAccess, adminOrCustomerOwner },\n addressFields,\n currenciesConfig,\n customersSlug = 'users',\n enableVariants = false,\n productsSlug = 'products',\n transactionsSlug = 'transactions',\n variantsSlug = 'variants',\n } = props || {}\n\n const fields: Field[] = [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n cartItemsField({\n enableVariants,\n overrides: {\n name: 'items',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:items'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:item'),\n },\n },\n productsSlug,\n variantsSlug,\n }),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orderDetails'),\n },\n {\n fields: [\n ...(addressFields\n ? [\n {\n name: 'shippingAddress',\n type: 'group',\n fields: addressFields,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shippingAddress'),\n } as Field,\n ]\n : []),\n ],\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:shipping'),\n },\n ],\n },\n {\n name: 'customer',\n type: 'relationship',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customer'),\n relationTo: customersSlug,\n },\n {\n name: 'customerEmail',\n type: 'email',\n admin: {\n position: 'sidebar',\n },\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:customerEmail'),\n },\n {\n name: 'transactions',\n type: 'relationship',\n access: {\n create: adminOnlyFieldAccess,\n read: adminOnlyFieldAccess,\n update: adminOnlyFieldAccess,\n },\n admin: {\n position: 'sidebar',\n },\n hasMany: true,\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:transactions'),\n relationTo: transactionsSlug,\n },\n {\n name: 'status',\n type: 'select',\n admin: {\n position: 'sidebar',\n },\n defaultValue: 'processing',\n interfaceName: 'OrderStatus',\n label: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:status'),\n options: [\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:processing'),\n value: 'processing',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:completed'),\n value: 'completed',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:cancelled'),\n value: 'cancelled',\n },\n {\n // @ts-expect-error - translations are not typed in plugins yet\n label: ({ t }) => t('plugin-ecommerce:refunded'),\n value: 'refunded',\n },\n ],\n },\n\n ...(currenciesConfig\n ? [\n {\n type: 'row',\n admin: {\n position: 'sidebar',\n },\n fields: [\n amountField({\n currenciesConfig,\n }),\n currencyField({\n currenciesConfig,\n }),\n ],\n } as Field,\n ]\n : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'orders',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrCustomerOwner,\n update: adminOnly,\n },\n admin: {\n description: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:ordersCollectionDescription'),\n group: 'Ecommerce',\n useAsTitle: 'createdAt',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:orders'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:order'),\n },\n timestamps: true,\n }\n\n return { ...baseConfig }\n}\n"],"names":["amountField","cartItemsField","currencyField","createOrdersCollection","props","access","adminOnly","adminOnlyFieldAccess","adminOrCustomerOwner","addressFields","currenciesConfig","customersSlug","enableVariants","productsSlug","transactionsSlug","variantsSlug","fields","type","tabs","overrides","name","label","t","labels","plural","singular","admin","position","relationTo","create","read","update","hasMany","defaultValue","interfaceName","options","value","baseConfig","slug","delete","description","group","useAsTitle","timestamps"],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CollectionConfig } from 'payload';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
access: {
|
|
5
|
+
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
6
|
+
adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>;
|
|
7
|
+
};
|
|
8
|
+
currenciesConfig: CurrenciesConfig;
|
|
9
|
+
enableVariants?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Adds in an inventory field to the product and its variants. This is useful for tracking inventory levels.
|
|
12
|
+
* Defaults to true.
|
|
13
|
+
*/
|
|
14
|
+
inventory?: boolean | InventoryConfig;
|
|
15
|
+
/**
|
|
16
|
+
* Slug of the variants collection, defaults to 'variants'.
|
|
17
|
+
*/
|
|
18
|
+
variantsSlug?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Slug of the variant types collection, defaults to 'variantTypes'.
|
|
21
|
+
*/
|
|
22
|
+
variantTypesSlug?: string;
|
|
23
|
+
};
|
|
24
|
+
export declare const createProductsCollection: (props: Props) => CollectionConfig;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=createProductsCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createProductsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/products/createProductsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMrF,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;QACjD,sBAAsB,EAAE,WAAW,CAAC,YAAY,CAAC,wBAAwB,CAAC,CAAC,CAAA;KAC5E,CAAA;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,eAAe,CAAA;IACrC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA2DxD,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { inventoryField } from '../../fields/inventoryField.js';
|
|
2
|
+
import { pricesField } from '../../fields/pricesField.js';
|
|
3
|
+
import { variantsFields } from '../../fields/variantsFields.js';
|
|
4
|
+
export const createProductsCollection = (props)=>{
|
|
5
|
+
const { access: { adminOnly, adminOrPublishedStatus }, currenciesConfig, enableVariants = false, inventory = true, variantsSlug = 'variants', variantTypesSlug = 'variantTypes' } = props || {};
|
|
6
|
+
const fields = [
|
|
7
|
+
...inventory ? [
|
|
8
|
+
inventoryField({
|
|
9
|
+
overrides: {
|
|
10
|
+
admin: {
|
|
11
|
+
condition: ({ enableVariants })=>!enableVariants
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
] : [],
|
|
16
|
+
...enableVariants ? variantsFields({
|
|
17
|
+
variantsSlug,
|
|
18
|
+
variantTypesSlug
|
|
19
|
+
}) : [],
|
|
20
|
+
...currenciesConfig ? [
|
|
21
|
+
...pricesField({
|
|
22
|
+
currenciesConfig
|
|
23
|
+
})
|
|
24
|
+
] : []
|
|
25
|
+
];
|
|
26
|
+
const baseConfig = {
|
|
27
|
+
slug: 'products',
|
|
28
|
+
access: {
|
|
29
|
+
create: adminOnly,
|
|
30
|
+
delete: adminOnly,
|
|
31
|
+
read: adminOrPublishedStatus,
|
|
32
|
+
update: adminOnly
|
|
33
|
+
},
|
|
34
|
+
admin: {
|
|
35
|
+
defaultColumns: [
|
|
36
|
+
...currenciesConfig ? [
|
|
37
|
+
'prices'
|
|
38
|
+
] : [],
|
|
39
|
+
...enableVariants ? [
|
|
40
|
+
'variants'
|
|
41
|
+
] : []
|
|
42
|
+
],
|
|
43
|
+
group: 'Ecommerce'
|
|
44
|
+
},
|
|
45
|
+
fields,
|
|
46
|
+
labels: {
|
|
47
|
+
plural: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
48
|
+
t('plugin-ecommerce:products'),
|
|
49
|
+
singular: ({ t })=>// @ts-expect-error - translations are not typed in plugins yet
|
|
50
|
+
t('plugin-ecommerce:product')
|
|
51
|
+
},
|
|
52
|
+
trash: true,
|
|
53
|
+
versions: {
|
|
54
|
+
drafts: {
|
|
55
|
+
autosave: true
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return baseConfig;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
//# sourceMappingURL=createProductsCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/collections/products/createProductsCollection.ts"],"sourcesContent":["import type { CollectionConfig } from 'payload'\n\nimport type { AccessConfig, CurrenciesConfig, InventoryConfig } from '../../types.js'\n\nimport { inventoryField } from '../../fields/inventoryField.js'\nimport { pricesField } from '../../fields/pricesField.js'\nimport { variantsFields } from '../../fields/variantsFields.js'\n\ntype Props = {\n access: {\n adminOnly: NonNullable<AccessConfig['adminOnly']>\n adminOrPublishedStatus: NonNullable<AccessConfig['adminOrPublishedStatus']>\n }\n currenciesConfig: CurrenciesConfig\n enableVariants?: boolean\n /**\n * Adds in an inventory field to the product and its variants. This is useful for tracking inventory levels.\n * Defaults to true.\n */\n inventory?: boolean | InventoryConfig\n /**\n * Slug of the variants collection, defaults to 'variants'.\n */\n variantsSlug?: string\n /**\n * Slug of the variant types collection, defaults to 'variantTypes'.\n */\n variantTypesSlug?: string\n}\n\nexport const createProductsCollection: (props: Props) => CollectionConfig = (props) => {\n const {\n access: { adminOnly, adminOrPublishedStatus },\n currenciesConfig,\n enableVariants = false,\n inventory = true,\n variantsSlug = 'variants',\n variantTypesSlug = 'variantTypes',\n } = props || {}\n\n const fields = [\n ...(inventory\n ? [\n inventoryField({\n overrides: {\n admin: {\n condition: ({ enableVariants }) => !enableVariants,\n },\n },\n }),\n ]\n : []),\n ...(enableVariants ? variantsFields({ variantsSlug, variantTypesSlug }) : []),\n ...(currenciesConfig ? [...pricesField({ currenciesConfig })] : []),\n ]\n\n const baseConfig: CollectionConfig = {\n slug: 'products',\n access: {\n create: adminOnly,\n delete: adminOnly,\n read: adminOrPublishedStatus,\n update: adminOnly,\n },\n admin: {\n defaultColumns: [\n ...(currenciesConfig ? ['prices'] : []),\n ...(enableVariants ? ['variants'] : []),\n ],\n group: 'Ecommerce',\n },\n fields,\n labels: {\n plural: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:products'),\n singular: ({ t }) =>\n // @ts-expect-error - translations are not typed in plugins yet\n t('plugin-ecommerce:product'),\n },\n trash: true,\n versions: {\n drafts: {\n autosave: true,\n },\n },\n }\n\n return baseConfig\n}\n"],"names":["inventoryField","pricesField","variantsFields","createProductsCollection","props","access","adminOnly","adminOrPublishedStatus","currenciesConfig","enableVariants","inventory","variantsSlug","variantTypesSlug","fields","overrides","admin","condition","baseConfig","slug","create","delete","read","update","defaultColumns","group","labels","plural","t","singular","trash","versions","drafts","autosave"],"mappings":"AAIA,SAASA,cAAc,QAAQ,iCAAgC;AAC/D,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,cAAc,QAAQ,iCAAgC;AAwB/D,OAAO,MAAMC,2BAA+D,CAACC;IAC3E,MAAM,EACJC,QAAQ,EAAEC,SAAS,EAAEC,sBAAsB,EAAE,EAC7CC,gBAAgB,EAChBC,iBAAiB,KAAK,EACtBC,YAAY,IAAI,EAChBC,eAAe,UAAU,EACzBC,mBAAmB,cAAc,EAClC,GAAGR,SAAS,CAAC;IAEd,MAAMS,SAAS;WACTH,YACA;YACEV,eAAe;gBACbc,WAAW;oBACTC,OAAO;wBACLC,WAAW,CAAC,EAAEP,cAAc,EAAE,GAAK,CAACA;oBACtC;gBACF;YACF;SACD,GACD,EAAE;WACFA,iBAAiBP,eAAe;YAAES;YAAcC;QAAiB,KAAK,EAAE;WACxEJ,mBAAmB;eAAIP,YAAY;gBAAEO;YAAiB;SAAG,GAAG,EAAE;KACnE;IAED,MAAMS,aAA+B;QACnCC,MAAM;QACNb,QAAQ;YACNc,QAAQb;YACRc,QAAQd;YACRe,MAAMd;YACNe,QAAQhB;QACV;QACAS,OAAO;YACLQ,gBAAgB;mBACVf,mBAAmB;oBAAC;iBAAS,GAAG,EAAE;mBAClCC,iBAAiB;oBAAC;iBAAW,GAAG,EAAE;aACvC;YACDe,OAAO;QACT;QACAX;QACAY,QAAQ;YACNC,QAAQ,CAAC,EAAEC,CAAC,EAAE,GACZ,+DAA+D;gBAC/DA,EAAE;YACJC,UAAU,CAAC,EAAED,CAAC,EAAE,GACd,+DAA+D;gBAC/DA,EAAE;QACN;QACAE,OAAO;QACPC,UAAU;YACRC,QAAQ;gBACNC,UAAU;YACZ;QACF;IACF;IAEA,OAAOf;AACT,EAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from 'payload';
|
|
2
|
+
import type { AccessConfig, CurrenciesConfig, PaymentAdapter } from '../../types.js';
|
|
3
|
+
type Props = {
|
|
4
|
+
access: {
|
|
5
|
+
adminOnly: NonNullable<AccessConfig['adminOnly']>;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Array of fields used for capturing the billing address.
|
|
9
|
+
*/
|
|
10
|
+
addressFields?: Field[];
|
|
11
|
+
/**
|
|
12
|
+
* Slug of the carts collection, defaults to 'carts'.
|
|
13
|
+
*/
|
|
14
|
+
cartsSlug?: string;
|
|
15
|
+
currenciesConfig?: CurrenciesConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Slug of the customers collection, defaults to 'users'.
|
|
18
|
+
*/
|
|
19
|
+
customersSlug?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Enable variants in the transactions collection.
|
|
22
|
+
*/
|
|
23
|
+
enableVariants?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Slug of the orders collection, defaults to 'orders'.
|
|
26
|
+
*/
|
|
27
|
+
ordersSlug?: string;
|
|
28
|
+
paymentMethods?: PaymentAdapter[];
|
|
29
|
+
/**
|
|
30
|
+
* Slug of the products collection, defaults to 'products'.
|
|
31
|
+
*/
|
|
32
|
+
productsSlug?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Slug of the variants collection, defaults to 'variants'.
|
|
35
|
+
*/
|
|
36
|
+
variantsSlug?: string;
|
|
37
|
+
};
|
|
38
|
+
export declare const createTransactionsCollection: (props: Props) => CollectionConfig;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=createTransactionsCollection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransactionsCollection.d.ts","sourceRoot":"","sources":["../../../src/collections/transactions/createTransactionsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAOpF,KAAK,KAAK,GAAG;IACX,MAAM,EAAE;QACN,SAAS,EAAE,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAA;KAClD,CAAA;IACD;;OAEG;IACH,aAAa,CAAC,EAAE,KAAK,EAAE,CAAA;IACvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,cAAc,EAAE,CAAA;IACjC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,4BAA4B,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,gBA+K5D,CAAA"}
|