Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Added Product Types API/SDK and React Dashboard UI

Damian Legawiec39f64b1b3044
diff --git a/packages/admin-sdk/src/admin-client.ts b/packages/admin-sdk/src/admin-client.ts
index ec7e11c140..af9b109014 100644
--- a/packages/admin-sdk/src/admin-client.ts
+++ b/packages/admin-sdk/src/admin-client.ts
@@ -136,6 +136,8 @@ import type {
PriceListUpdateParams,
PriceUpdateParams,
ProductCreateParams,
+ ProductTypeCreateParams,
+ ProductTypeUpdateParams,
ProductUpdateParams,
PromotionActionCalculator,
PromotionActionCreateParams,
@@ -197,6 +199,7 @@ import type {
Price,
PriceList,
Product,
+ ProductType,
Promotion,
PromotionAction,
PromotionRule,
@@ -2208,6 +2211,33 @@ export class AdminClient {
// Tax Categories
// ============================================
+ readonly productTypes = {
+ list: (
+ params?: ListParams & Record<string, unknown>,
+ options?: RequestOptions,
+ ): Promise<PaginatedResponse<ProductType>> =>
+ this.request<PaginatedResponse<ProductType>>('GET', '/product_types', {
+ ...options,
+ params: params ? transformListParams(params) : undefined,
+ }),
+
+ get: (id: string, options?: RequestOptions): Promise<ProductType> =>
+ this.request<ProductType>('GET', `/product_types/${id}`, options),
+
+ create: (params: ProductTypeCreateParams, options?: RequestOptions): Promise<ProductType> =>
+ this.request<ProductType>('POST', '/product_types', { ...options, body: params }),
+
+ update: (
+ id: string,
+ params: ProductTypeUpdateParams,
+ options?: RequestOptions,
+ ): Promise<ProductType> =>
+ this.request<ProductType>('PATCH', `/product_types/${id}`, { ...options, body: params }),
+
+ delete: (id: string, options?: RequestOptions): Promise<void> =>
+ this.request<void>('DELETE', `/product_types/${id}`, options),
+ }
+
readonly taxCategories = {
list: (
params?: ListParams & Record<string, unknown>,
diff --git a/packages/admin-sdk/src/params.ts b/packages/admin-sdk/src/params.ts
index fef24af76e..dce0b9725e 100644
--- a/packages/admin-sdk/src/params.ts
+++ b/packages/admin-sdk/src/params.ts
@@ -772,6 +772,17 @@ export interface WebhookEndpointDisableParams {
reason?: string
}
+export interface ProductTypeCreateParams {
+ name: string
+ /** Fulfillment types products of this type support (e.g. ['shipping', 'pickup']). */
+ fulfillment_types?: string[]
+}
+
+export interface ProductTypeUpdateParams {
+ name?: string
+ fulfillment_types?: string[]
+}
+
export interface TaxCategoryCreateParams {
name: string
tax_code?: string | null
@@ -1384,6 +1395,8 @@ export interface DeliveryMethodParams {
estimated_transit_business_days_max?: number | null
/** Prefixed tax category ID (`taxcat_...`), or null to clear. */
tax_category_id?: string | null
+ /** Product type prefixed ID (pt_...); drives fulfillment eligibility. */
+ product_type_id?: string | null
/** Delivery calculator class name (see `deliveryMethods.calculators()`). */
calculator_type?: string
calculator_preferences?: Record<string, unknown>
diff --git a/packages/admin-sdk/src/types/generated/Product.ts b/packages/admin-sdk/src/types/generated/Product.ts
index 71129f92cd..6f8b3117c4 100644
--- a/packages/admin-sdk/src/types/generated/Product.ts
+++ b/packages/admin-sdk/src/types/generated/Product.ts
@@ -1,4 +1,4 @@
-// Typelizer digest cb42889c9b73f728609a007abb834f28
+// Typelizer digest 13faed800013f68593bb28068ed62513
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {Price, PriceHistory, Media, Variant, OptionType, OptionValue, Category, CustomField, ProductPublication, Channel} from '@/types'
@@ -40,6 +40,7 @@ interface Product {
deleted_at: string | null;
created_at: string;
updated_at: string;
+ product_type_id: string | null;
tax_category_id: string | null;
product_publications?: Array<ProductPublication>;
channels?: Array<Channel>;
diff --git a/packages/admin-sdk/src/types/generated/ProductType.ts b/packages/admin-sdk/src/types/generated/ProductType.ts
new file mode 100644
index 0000000000..9b78ae42d6
--- /dev/null
+++ b/packages/admin-sdk/src/types/generated/ProductType.ts
@@ -0,0 +1,14 @@
+// Typelizer digest fec9914b31bfc8048d81a9a0be2edd18
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface ProductType {
+ id: string;
+ name: string;
+ fulfillment_types: Array<string>;
+ products_count: number;
+ created_at: string;
+ updated_at: string;
+}
+
+export default ProductType;
diff --git a/packages/admin-sdk/src/types/generated/index.ts b/packages/admin-sdk/src/types/generated/index.ts
index e38fc30e14..ae09137530 100644
--- a/packages/admin-sdk/src/types/generated/index.ts
+++ b/packages/admin-sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest e57fbfabe59fc981107a0bdfba77862e
+// Typelizer digest 58561d67ac3adf59af542c538dc3af8e
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -51,6 +51,7 @@ export type { default as PriceRule } from './PriceRule'
export type { default as Price } from './Price'
export type { default as ProductPublication } from './ProductPublication'
export type { default as Product } from './Product'
+export type { default as ProductType } from './ProductType'
export type { default as PromotionAction } from './PromotionAction'
export type { default as PromotionRule } from './PromotionRule'
export type { default as Promotion } from './Promotion'
diff --git a/packages/admin-sdk/src/types/index.ts b/packages/admin-sdk/src/types/index.ts
index 2742e0e395..ed331d2e5d 100644
--- a/packages/admin-sdk/src/types/index.ts
+++ b/packages/admin-sdk/src/types/index.ts
@@ -55,6 +55,7 @@ export type { default as PriceList } from './generated/PriceList'
export type { default as PriceRule } from './generated/PriceRule'
export type { default as Product } from './generated/Product'
export type { default as ProductPublication } from './generated/ProductPublication'
+export type { default as ProductType } from './generated/ProductType'
export type { default as Promotion } from './generated/Promotion'
export type { default as PromotionAction } from './generated/PromotionAction'
export type { default as PromotionRule } from './generated/PromotionRule'
diff --git a/packages/dashboard-core/src/lib/permissions.ts b/packages/dashboard-core/src/lib/permissions.ts
index c689bb06ed..5d788be51c 100644
--- a/packages/dashboard-core/src/lib/permissions.ts
+++ b/packages/dashboard-core/src/lib/permissions.ts
@@ -7,6 +7,7 @@
export const Subject = {
All: 'all',
Product: 'Spree::Product',
+ ProductType: 'Spree::ProductType',
Variant: 'Spree::Variant',
Order: 'Spree::Order',
Customer: 'Spree::User',
diff --git a/packages/dashboard-starter/src/routeTree.gen.ts b/packages/dashboard-starter/src/routeTree.gen.ts
index 8c8cb7081c..67263aaff1 100644
--- a/packages/dashboard-starter/src/routeTree.gen.ts
+++ b/packages/dashboard-starter/src/routeTree.gen.ts
@@ -31,6 +31,7 @@ import { Route as SettingsStoreRouteImport } from './../../dashboard/src/routes/
import { Route as SettingsStockLocationsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/stock-locations'
import { Route as SettingsStaffRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/staff'
import { Route as SettingsProfileRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/profile'
+import { Route as SettingsProductTypesRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/product-types'
import { Route as SettingsPaymentMethodsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/payment-methods'
import { Route as SettingsMarketsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/markets'
import { Route as SettingsEmailsRouteImport } from './../../dashboard/src/routes/_authenticated/$storeId/settings/emails'
@@ -173,6 +174,11 @@ const SettingsProfileRoute = SettingsProfileRouteImport.update({
path: '/profile',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsProductTypesRoute = SettingsProductTypesRouteImport.update({
+ id: '/product-types',
+ path: '/product-types',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsPaymentMethodsRoute = SettingsPaymentMethodsRouteImport.update({
id: '/payment-methods',
path: '/payment-methods',
@@ -366,6 +372,7 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -418,6 +425,7 @@ export interface FileRoutesByTo {
'/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -474,6 +482,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/emails': typeof SettingsEmailsRoute
'/_authenticated/$storeId/settings/markets': typeof SettingsMarketsRoute
'/_authenticated/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/_authenticated/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/_authenticated/$storeId/settings/profile': typeof SettingsProfileRoute
'/_authenticated/$storeId/settings/staff': typeof SettingsStaffRoute
'/_authenticated/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -530,6 +539,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/emails'
| '/$storeId/settings/markets'
| '/$storeId/settings/payment-methods'
+ | '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
@@ -582,6 +592,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/emails'
| '/$storeId/settings/markets'
| '/$storeId/settings/payment-methods'
+ | '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
@@ -637,6 +648,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/emails'
| '/_authenticated/$storeId/settings/markets'
| '/_authenticated/$storeId/settings/payment-methods'
+ | '/_authenticated/$storeId/settings/product-types'
| '/_authenticated/$storeId/settings/profile'
| '/_authenticated/$storeId/settings/staff'
| '/_authenticated/$storeId/settings/stock-locations'
@@ -823,6 +835,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsProfileRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/product-types': {
+ id: '/_authenticated/$storeId/settings/product-types'
+ path: '/product-types'
+ fullPath: '/$storeId/settings/product-types'
+ preLoaderRoute: typeof SettingsProductTypesRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/payment-methods': {
id: '/_authenticated/$storeId/settings/payment-methods'
path: '/payment-methods'
@@ -1053,6 +1072,7 @@ interface SettingsRouteChildren {
SettingsEmailsRoute: typeof SettingsEmailsRoute
SettingsMarketsRoute: typeof SettingsMarketsRoute
SettingsPaymentMethodsRoute: typeof SettingsPaymentMethodsRoute
+ SettingsProductTypesRoute: typeof SettingsProductTypesRoute
SettingsProfileRoute: typeof SettingsProfileRoute
SettingsStaffRoute: typeof SettingsStaffRoute
SettingsStockLocationsRoute: typeof SettingsStockLocationsRoute
@@ -1074,6 +1094,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsEmailsRoute: SettingsEmailsRoute,
SettingsMarketsRoute: SettingsMarketsRoute,
SettingsPaymentMethodsRoute: SettingsPaymentMethodsRoute,
+ SettingsProductTypesRoute: SettingsProductTypesRoute,
SettingsProfileRoute: SettingsProfileRoute,
SettingsStaffRoute: SettingsStaffRoute,
SettingsStockLocationsRoute: SettingsStockLocationsRoute,
diff --git a/packages/dashboard/e2e/product-types.spec.ts b/packages/dashboard/e2e/product-types.spec.ts
new file mode 100644
index 0000000000..ed97d25e31
--- /dev/null
+++ b/packages/dashboard/e2e/product-types.spec.ts
@@ -0,0 +1,44 @@
+import { expect, test } from '@playwright/test'
+import { gotoIndex, login } from './helpers'
+
+const PATH = (storeId: string) => `/${storeId}/settings/product-types`
+const CTA = /add product type/i
+
+test.describe('product types', () => {
+ test('lists product types', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, PATH(creds.store_id), CTA)
+ })
+
+ test('creates a pickup-capable product type', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, PATH(creds.store_id), CTA)
+
+ const name = `E2E Collectable ${Date.now()}`
+
+ await page.getByRole('button', { name: CTA }).click()
+ await expect(page.getByRole('heading', { name: /new product type/i })).toBeVisible()
+
+ await page.locator('#name').fill(name)
+ // Shipping is preselected; add pickup on top.
+ await page.locator('#fulfillment-type-pickup').click()
+
+ await page.getByRole('button', { name: /create product type/i }).click()
+
+ await expect(page.getByText(name)).toBeVisible({ timeout: 15_000 })
+ })
+
+ test('rejects a product type with no fulfillment types', async ({ page }) => {
+ const creds = await login(page)
+ await gotoIndex(page, PATH(creds.store_id), CTA)
+
+ await page.getByRole('button', { name: CTA }).click()
+ await page.locator('#name').fill(`E2E Invalid ${Date.now()}`)
+ await page.locator('#fulfillment-type-shipping').click() // uncheck the default
+
+ await page.getByRole('button', { name: /create product type/i }).click()
+
+ // Client-side validation keeps the sheet open with an error.
+ await expect(page.getByRole('heading', { name: /new product type/i })).toBeVisible()
+ })
+})
diff --git a/packages/dashboard/src/components/spree/products/product-form-cards.tsx b/packages/dashboard/src/components/spree/products/product-form-cards.tsx
index 023a6f4ec1..551d89e10d 100644
--- a/packages/dashboard/src/components/spree/products/product-form-cards.tsx
+++ b/packages/dashboard/src/components/spree/products/product-form-cards.tsx
@@ -46,6 +46,7 @@ import { useTranslation } from 'react-i18next'
import { toast } from 'sonner'
import { categoryAutocompleteProps, useCategories } from '../../../hooks/use-categories'
import { useDeleteProductMedia } from '../../../hooks/use-product-media'
+import { useProductTypes } from '../../../hooks/use-product-types'
import { useTaxCategories } from '../../../hooks/use-tax-categories'
import type { ProductFormValues } from '../../../schemas/product'
import { ProductBulkPriceEditor } from '../bulk-price-editor/product-bulk-price-editor'
@@ -644,12 +645,44 @@ export function StatusCard({ form }: FormCardProps) {
export function CategorizationCard({ form }: FormCardProps) {
const { t } = useTranslation()
const { data: categoriesData } = useCategories()
+ const { data: productTypesData } = useProductTypes()
+ const productTypes = productTypesData?.data ?? []
return (
<Card>
<CardHeader>
<CardTitle>{t('admin.pages.products.section_categorization')}</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-4">
+ <Field>
+ <FieldLabel>{t('admin.fields.product.product_type_id.label')}</FieldLabel>
+ <Controller
+ name="product_type_id"
+ control={form.control}
+ render={({ field }) => (
+ <Select value={field.value ?? ''} onValueChange={(v) => field.onChange(v || null)}>
+ <SelectTrigger className="w-full">
+ <SelectValue placeholder={t('admin.products.product_type_placeholder')}>
+ {(v) =>
+ productTypes.find((pt) => pt.id === v)?.name ??
+ t('admin.products.product_type_placeholder')
+ }
+ </SelectValue>
+ </SelectTrigger>
+ <SelectContent>
+ {productTypes.map((productType) => (
+ <SelectItem key={productType.id} value={productType.id}>
+ {productType.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ )}
+ />
+ <span className="text-muted-foreground text-xs">
+ {t('admin.fields.product.product_type_id.help')}
+ </span>
+ </Field>
+
<Field>
<FieldLabel>{t('admin.fields.product.category_ids.label')}</FieldLabel>
<Controller
diff --git a/packages/dashboard/src/hooks/use-product-types.ts b/packages/dashboard/src/hooks/use-product-types.ts
new file mode 100644
index 0000000000..7a5725fcfd
--- /dev/null
+++ b/packages/dashboard/src/hooks/use-product-types.ts
@@ -0,0 +1,67 @@
+import type {
+ ProductType,
+ ProductTypeCreateParams,
+ ProductTypeUpdateParams,
+} from '@spree/admin-sdk'
+import {
+ adminClient,
+ useResourceKey,
+ useResourceKeyBuilder,
+ useResourceMutation,
+} from '@spree/dashboard-core'
+import { useQuery, useQueryClient } from '@tanstack/react-query'
+import i18n from 'i18next'
+
+interface UseProductTypesParams {
+ page?: number
+ limit?: number
+}
+
+export function useProductTypes({ page = 1, limit = 100 }: UseProductTypesParams = {}) {
+ return useQuery({
+ queryKey: useResourceKey('product-types', { page, limit }),
+ queryFn: () => adminClient.productTypes.list({ page, limit }),
+ staleTime: 1000 * 60 * 5,
+ })
+}
+
+export function useProductType(id: string | undefined) {
+ return useQuery({
+ queryKey: useResourceKey('product-types', id ?? 'noop'),
+ queryFn: () => adminClient.productTypes.get(id as string),
+ enabled: !!id,
+ })
+}
+
+export function useCreateProductType() {
+ return useResourceMutation<ProductType, Error, ProductTypeCreateParams>({
+ mutationFn: (params) => adminClient.productTypes.create(params),
+ invalidate: [['product-types']],
+ successMessage: i18n.t('admin.product_types.messages.created'),
+ errorMessage: i18n.t('admin.errors.failed_to_create'),
+ })
+}
+
+export function useUpdateProductType(id: string) {
+ return useResourceMutation<ProductType, Error, ProductTypeUpdateParams>({
+ mutationFn: (params) => adminClient.productTypes.update(id, params),
+ invalidate: [['product-types'], ['product-types', id]],
+ successMessage: i18n.t('admin.product_types.messages.updated'),
+ errorMessage: i18n.t('admin.errors.failed_to_update'),
+ })
+}
+
+export function useDeleteProductType() {
+ const queryClient = useQueryClient()
+ const buildKey = useResourceKeyBuilder()
+
+ return useResourceMutation<void, Error, string>({
+ mutationFn: (id) => adminClient.productTypes.delete(id),
+ invalidate: [['product-types']],
+ successMessage: i18n.t('admin.product_types.messages.deleted'),
+ errorMessage: i18n.t('admin.errors.failed_to_delete'),
+ onSuccess: (_data, id) => {
+ queryClient.removeQueries({ queryKey: buildKey('product-types', id) })
+ },
+ })
+}
diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.json
index 592bca1665..faaccc7cbf 100644
--- a/packages/dashboard/src/locales/ar.json
+++ b/packages/dashboard/src/locales/ar.json
@@ -589,6 +589,10 @@
"delivery_zones": {
"label": "مناطق التوصيل"
},
+ "fulfillment_provider": {
+ "label": "مزود التنفيذ",
+ "help": "كيفية معالجة عمليات التنفيذ لهذه الطريقة وتتبعها."
+ },
"fulfillment_type": {
"label": "نوع التنفيذ"
},
@@ -844,6 +848,10 @@
"label": "الاسم",
"placeholder": "اسم المنتج"
},
+ "product_type_id": {
+ "help": "يحدد خيارات التسليم المتاحة عند إتمام الشراء.",
+ "label": "نوع المنتج"
+ },
"tags": {
"label": "Tags"
}
@@ -860,6 +868,18 @@
"placeholder": "أبدًا"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "كيف يمكن تسليم منتجات هذا النوع — شحن، استلام من المتجر، نقطة استلام، أو رقمي.",
+ "label": "طرق التنفيذ"
+ },
+ "name": {
+ "placeholder": "مثال: تي شيرت"
+ },
+ "products_count": {
+ "label": "المنتجات"
+ }
+ },
"products_count": {
"label": "المنتجات"
},
@@ -2289,6 +2309,25 @@
"preferred_amount": "كمية",
"preferred_percent": "نسبة مئوية"
},
+ "product_types": {
+ "add_cta": "إضافة نوع منتج",
+ "add_sheet_title": "نوع منتج جديد",
+ "create_description": "جمّع المنتجات وحدد طرق تسليمها.",
+ "create_label": "إنشاء نوع منتج",
+ "delete_confirm": {
+ "message": "هل أنت متأكد من حذف “{{name}}”؟ لا يمكن حذف الأنواع التي لا تزال مستخدمة من قبل منتجات.",
+ "title": "حذف نوع المنتج"
+ },
+ "edit_description": "غيّر الاسم أو طرق تسليم منتجات هذا النوع.",
+ "edit_sheet_title": "تعديل نوع المنتج",
+ "empty": "لا توجد أنواع منتجات بعد",
+ "messages": {
+ "created": "تم إنشاء نوع المنتج",
+ "deleted": "تم حذف نوع المنتج",
+ "updated": "تم تحديث نوع المنتج"
+ },
+ "search_placeholder": "ابحث في أنواع المنتجات"
+ },
"products": {
"category_search_placeholder": "فئات البحث…",
"columns": {
@@ -2358,6 +2397,7 @@
"ends_after_starts": "يجب أن يكون بعد تاريخ البدء."
}
},
+ "product_type_placeholder": "بدون نوع منتج",
"save_label": "حفظ المنتج",
"seo": {
"meta_description_placeholder": "SEO description",
@@ -2708,6 +2748,7 @@
"imports": "عمليات الاستيراد",
"markets": "الأسواق",
"payment_methods": "طرق الدفع",
+ "product_types": "أنواع المنتجات",
"profile": "الملف الشخصي",
"staff": "الموظفون",
"stock_locations": "مواقع المخزون",
diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.json
index 2f67c0b812..db664ebe51 100644
--- a/packages/dashboard/src/locales/de.json
+++ b/packages/dashboard/src/locales/de.json
@@ -589,6 +589,10 @@
"delivery_zones": {
"label": "Lieferzonen"
},
+ "fulfillment_provider": {
+ "label": "Fulfillment-Anbieter",
+ "help": "Wie Sendungen dieser Methode abgewickelt und verfolgt werden."
+ },
"fulfillment_type": {
"label": "Fulfillment-Typ"
},
@@ -844,6 +848,10 @@
"label": "Name",
"placeholder": "Produktname"
},
+ "product_type_id": {
+ "help": "Bestimmt, welche Lieferoptionen im Checkout angeboten werden.",
+ "label": "Produkttyp"
+ },
"tags": {
"label": "Tags"
}
@@ -860,6 +868,18 @@
"placeholder": "Nie"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "Wie Produkte dieses Typs geliefert werden können — Versand, Abholung im Geschäft, Abholstation oder digital.",
+ "label": "Fulfillment-Arten"
+ },
+ "name": {
+ "placeholder": "z. B. T-Shirt"
+ },
+ "products_count": {
+ "label": "Produkte"
+ }
+ },
"products_count": {
"label": "Produkte"
},
@@ -2289,6 +2309,25 @@
"preferred_amount": "Betrag",
"preferred_percent": "Prozent"
},
+ "product_types": {
+ "add_cta": "Produkttyp hinzufügen",
+ "add_sheet_title": "Neuer Produkttyp",
+ "create_description": "Produkte gruppieren und festlegen, wie sie geliefert werden können.",
+ "create_label": "Produkttyp erstellen",
+ "delete_confirm": {
+ "message": "Möchten Sie „{{name}}“ wirklich löschen? Typen, die noch von Produkten verwendet werden, können nicht gelöscht werden.",
+ "title": "Produkttyp löschen"
+ },
+ "edit_description": "Namen oder Lieferarten der Produkte dieses Typs ändern.",
+ "edit_sheet_title": "Produkttyp bearbeiten",
+ "empty": "Noch keine Produkttypen",
+ "messages": {
+ "created": "Produkttyp erstellt",
+ "deleted": "Produkttyp gelöscht",
+ "updated": "Produkttyp aktualisiert"
+ },
+ "search_placeholder": "Produkttypen durchsuchen"
+ },
"products": {
"category_search_placeholder": "Kategorien suchen…",
"columns": {
@@ -2358,6 +2397,7 @@
"ends_after_starts": "Muss nach dem Startdatum liegen."
}
},
+ "product_type_placeholder": "Kein Produkttyp",
"save_label": "Produkt speichern",
"seo": {
"meta_description_placeholder": "SEO-Beschreibung",
@@ -2708,6 +2748,7 @@
"imports": "Importe",
"markets": "Märkte",
"payment_methods": "Zahlungsmethoden",
+ "product_types": "Produkttypen",
"profile": "Profil",
"staff": "Mitarbeiter",
"stock_locations": "Lagerstandorte",
diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.json
index a4385eea35..10c157db90 100644
--- a/packages/dashboard/src/locales/en.json
+++ b/packages/dashboard/src/locales/en.json
@@ -589,6 +589,10 @@
"delivery_zones": {
"label": "Delivery zones"
},
+ "fulfillment_provider": {
+ "label": "Fulfillment provider",
+ "help": "How fulfillments for this method are dispatched and tracked."
+ },
"fulfillment_type": {
"label": "Fulfillment type"
},
@@ -844,6 +848,10 @@
"label": "Name",
"placeholder": "Product name"
},
+ "product_type_id": {
+ "help": "Controls which delivery options are offered at checkout.",
+ "label": "Product type"
+ },
"tags": {
"label": "Tags"
}
@@ -860,6 +868,18 @@
"placeholder": "Never"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "How products of this type can be delivered — shipping, store pickup, pickup point, or digital.",
+ "label": "Fulfillment types"
+ },
+ "name": {
+ "placeholder": "e.g. T-Shirt"
+ },
+ "products_count": {
+ "label": "Products"
+ }
+ },
"products_count": {
"label": "Products"
},
@@ -2289,6 +2309,25 @@
"preferred_amount": "Amount",
"preferred_percent": "Percent"
},
+ "product_types": {
+ "add_cta": "Add product type",
+ "add_sheet_title": "New product type",
+ "create_description": "Group products and define how they can be delivered.",
+ "create_label": "Create product type",
+ "delete_confirm": {
+ "message": "Are you sure you want to delete “{{name}}”? Types still used by products cannot be deleted.",
+ "title": "Delete product type"
+ },
+ "edit_description": "Change the name or the ways products of this type are delivered.",
+ "edit_sheet_title": "Edit product type",
+ "empty": "No product types yet",
+ "messages": {
+ "created": "Product type created",
+ "deleted": "Product type deleted",
+ "updated": "Product type updated"
+ },
+ "search_placeholder": "Search product types"
+ },
"products": {
"category_search_placeholder": "Search categories…",
"columns": {
@@ -2358,6 +2397,7 @@
"ends_after_starts": "Must be after start date."
}
},
+ "product_type_placeholder": "No product type",
"save_label": "Save product",
"seo": {
"meta_description_placeholder": "SEO description",
@@ -2708,6 +2748,7 @@
"imports": "Imports",
"markets": "Markets",
"payment_methods": "Payment methods",
+ "product_types": "Product types",
"profile": "Profile",
"staff": "Staff",
"stock_locations": "Stock locations",
diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.json
index 9adc09a15c..fa4734512e 100644
--- a/packages/dashboard/src/locales/fr.json
+++ b/packages/dashboard/src/locales/fr.json
@@ -589,6 +589,10 @@
"delivery_zones": {
"label": "Zones de livraison"
},
+ "fulfillment_provider": {
+ "label": "Fournisseur d'expédition",
+ "help": "Comment les expéditions de cette méthode sont traitées et suivies."
+ },
"fulfillment_type": {
"label": "Type de traitement"
},
@@ -844,6 +848,10 @@
"label": "Nom",
"placeholder": "Nom du produit"
},
+ "product_type_id": {
+ "help": "Détermine les options de livraison proposées au paiement.",
+ "label": "Type de produit"
+ },
"tags": {
"label": "Étiquettes"
}
@@ -860,6 +868,18 @@
"placeholder": "Jamais"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "Comment les produits de ce type peuvent être livrés — expédition, retrait en magasin, point relais ou numérique.",
+ "label": "Modes d'expédition"
+ },
+ "name": {
+ "placeholder": "p. ex. T-Shirt"
+ },
+ "products_count": {
+ "label": "Produits"
+ }
+ },
"products_count": {
"label": "Produits"
},
@@ -2289,6 +2309,25 @@
"preferred_amount": "Montant",
"preferred_percent": "Pourcentage"
},
+ "product_types": {
+ "add_cta": "Ajouter un type de produit",
+ "add_sheet_title": "Nouveau type de produit",
+ "create_description": "Regroupez les produits et définissez leurs modes de livraison.",
+ "create_label": "Créer le type de produit",
+ "delete_confirm": {
+ "message": "Voulez-vous vraiment supprimer « {{name}} » ? Les types encore utilisés par des produits ne peuvent pas être supprimés.",
+ "title": "Supprimer le type de produit"
+ },
+ "edit_description": "Modifier le nom ou les modes de livraison des produits de ce type.",
+ "edit_sheet_title": "Modifier le type de produit",
+ "empty": "Aucun type de produit",
+ "messages": {
+ "created": "Type de produit créé",
+ "deleted": "Type de produit supprimé",
+ "updated": "Type de produit mis à jour"
+ },
+ "search_placeholder": "Rechercher des types de produit"
+ },
"products": {
"category_search_placeholder": "Rechercher des catégories…",
"columns": {
@@ -2358,6 +2397,7 @@
"ends_after_starts": "Doit être postérieur à la date de début."
}
},
+ "product_type_placeholder": "Aucun type de produit",
"save_label": "Enregistrer le produit",
"seo": {
"meta_description_placeholder": "Description SEO",
@@ -2708,6 +2748,7 @@
"imports": "Imports",
"markets": "Marchés",
"payment_methods": "Modes de paiement",
+ "product_types": "Types de produit",
"profile": "Profil",
"staff": "Personnel",
"stock_locations": "Emplacements de stock",
diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.json
index ca6eecdf1d..48c7a33e15 100644
--- a/packages/dashboard/src/locales/pl.json
+++ b/packages/dashboard/src/locales/pl.json
@@ -593,6 +593,10 @@
"delivery_zones": {
"label": "Strefy dostawy"
},
+ "fulfillment_provider": {
+ "label": "Dostawca realizacji",
+ "help": "Jak realizacje tej metody są przetwarzane i śledzone."
+ },
"fulfillment_type": {
"label": "Typ realizacji"
},
@@ -848,6 +852,10 @@
"label": "Nazwa",
"placeholder": "Nazwa produktu"
},
+ "product_type_id": {
+ "help": "Określa, które opcje dostawy są oferowane przy zamówieniu.",
+ "label": "Typ produktu"
+ },
"tags": {
"label": "Tagi"
}
@@ -864,6 +872,18 @@
"placeholder": "Nigdy"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "Jak produkty tego typu mogą być dostarczane — wysyłka, odbiór w sklepie, punkt odbioru lub cyfrowo.",
+ "label": "Sposoby realizacji"
+ },
+ "name": {
+ "placeholder": "np. T-Shirt"
+ },
+ "products_count": {
+ "label": "Produkty"
+ }
+ },
"products_count": {
"label": "Produkty"
},
@@ -2317,6 +2337,25 @@
"preferred_amount": "Kwota",
"preferred_percent": "Procent"
},
+ "product_types": {
+ "add_cta": "Dodaj typ produktu",
+ "add_sheet_title": "Nowy typ produktu",
+ "create_description": "Grupuj produkty i określ, jak mogą być dostarczane.",
+ "create_label": "Utwórz typ produktu",
+ "delete_confirm": {
+ "message": "Czy na pewno usunąć „{{name}}”? Typów używanych przez produkty nie można usunąć.",
+ "title": "Usuń typ produktu"
+ },
+ "edit_description": "Zmień nazwę lub sposoby dostawy produktów tego typu.",
+ "edit_sheet_title": "Edytuj typ produktu",
+ "empty": "Brak typów produktów",
+ "messages": {
+ "created": "Utworzono typ produktu",
+ "deleted": "Usunięto typ produktu",
+ "updated": "Zaktualizowano typ produktu"
+ },
+ "search_placeholder": "Szukaj typów produktów"
+ },
"products": {
"category_search_placeholder": "Szukaj kategorii…",
"columns": {
@@ -2388,6 +2427,7 @@
"ends_after_starts": "Musi być po dacie rozpoczęcia."
}
},
+ "product_type_placeholder": "Brak typu produktu",
"save_label": "Zapisz produkt",
"seo": {
"meta_description_placeholder": "Opis SEO",
@@ -2740,6 +2780,7 @@
"imports": "Importy",
"markets": "Rynki",
"payment_methods": "Metody płatności",
+ "product_types": "Typy produktów",
"profile": "Profil",
"staff": "Zespół",
"stock_locations": "Lokalizacje magazynowe",
diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.json
index d013138f96..fbfbf08ae6 100644
--- a/packages/dashboard/src/locales/zh-CN.json
+++ b/packages/dashboard/src/locales/zh-CN.json
@@ -589,6 +589,10 @@
"delivery_zones": {
"label": "配送区域"
},
+ "fulfillment_provider": {
+ "label": "履约服务商",
+ "help": "此配送方式的履约如何发运与跟踪。"
+ },
"fulfillment_type": {
"label": "履约类型"
},
@@ -844,6 +848,10 @@
"label": "名称",
"placeholder": "产品名称"
},
+ "product_type_id": {
+ "help": "决定结账时提供哪些配送选项。",
+ "label": "商品类型"
+ },
"tags": {
"label": "标签"
}
@@ -860,6 +868,18 @@
"placeholder": "永不"
}
},
+ "product_type": {
+ "fulfillment_types": {
+ "help": "此类型商品的交付方式 — 配送、到店自提、自提点或数字交付。",
+ "label": "履约方式"
+ },
+ "name": {
+ "placeholder": "例如:T恤"
+ },
+ "products_count": {
+ "label": "商品数"
+ }
+ },
"products_count": {
"label": "商品"
},
@@ -2289,6 +2309,25 @@
"preferred_amount": "金额",
"preferred_percent": "百分比"
},
+ "product_types": {
+ "add_cta": "添加商品类型",
+ "add_sheet_title": "新建商品类型",
+ "create_description": "将商品分组并定义其交付方式。",
+ "create_label": "创建商品类型",
+ "delete_confirm": {
+ "message": "确定要删除“{{name}}”吗?仍被商品使用的类型无法删除。",
+ "title": "删除商品类型"
+ },
+ "edit_description": "修改名称或此类型商品的交付方式。",
+ "edit_sheet_title": "编辑商品类型",
+ "empty": "暂无商品类型",
+ "messages": {
+ "created": "商品类型已创建",
+ "deleted": "商品类型已删除",
+ "updated": "商品类型已更新"
+ },
+ "search_placeholder": "搜索商品类型"
+ },
"products": {
"category_search_placeholder": "搜索分类…",
"columns": {
@@ -2358,6 +2397,7 @@
"ends_after_starts": "必须晚于开始日期。"
}
},
+ "product_type_placeholder": "无商品类型",
"save_label": "保存产品",
"seo": {
"meta_description_placeholder": "SEO 描述",
@@ -2708,6 +2748,7 @@
"imports": "导入",
"markets": "市场",
"payment_methods": "支付方式",
+ "product_types": "商品类型",
"profile": "个人资料",
"staff": "员工",
"stock_locations": "库存地点",
diff --git a/packages/dashboard/src/nav/settings.ts b/packages/dashboard/src/nav/settings.ts
index 745553a7d5..f9e10c3973 100644
--- a/packages/dashboard/src/nav/settings.ts
+++ b/packages/dashboard/src/nav/settings.ts
@@ -8,6 +8,7 @@ import {
MapIcon,
PercentIcon,
RadioTowerIcon,
+ ShapesIcon,
StoreIcon,
TagIcon,
TruckIcon,
@@ -95,6 +96,16 @@ settingsNav.add({
subject: Subject.Market,
})
+settingsNav.add({
+ key: 'settings.product-types',
+ labelKey: 'admin.settings_nav.items.product_types',
+ path: '/product-types',
+ icon: ShapesIcon,
+ group: 'fulfillment',
+ position: 70,
+ subject: Subject.ProductType,
+})
+
settingsNav.add({
key: 'settings.delivery-methods',
labelKey: 'admin.settings_nav.items.delivery_methods',
diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.ts
index ed5339c4f8..7915892a87 100644
--- a/packages/dashboard/src/routeTree.gen.ts
+++ b/packages/dashboard/src/routeTree.gen.ts
@@ -30,6 +30,7 @@ import { Route as SettingsStoreRouteImport } from './routes/_authenticated/$stor
import { Route as SettingsStockLocationsRouteImport } from './routes/_authenticated/$storeId/settings/stock-locations'
import { Route as SettingsStaffRouteImport } from './routes/_authenticated/$storeId/settings/staff'
import { Route as SettingsProfileRouteImport } from './routes/_authenticated/$storeId/settings/profile'
+import { Route as SettingsProductTypesRouteImport } from './routes/_authenticated/$storeId/settings/product-types'
import { Route as SettingsPaymentMethodsRouteImport } from './routes/_authenticated/$storeId/settings/payment-methods'
import { Route as SettingsMarketsRouteImport } from './routes/_authenticated/$storeId/settings/markets'
import { Route as SettingsEmailsRouteImport } from './routes/_authenticated/$storeId/settings/emails'
@@ -166,6 +167,11 @@ const SettingsProfileRoute = SettingsProfileRouteImport.update({
path: '/profile',
getParentRoute: () => SettingsRoute,
} as any)
+const SettingsProductTypesRoute = SettingsProductTypesRouteImport.update({
+ id: '/product-types',
+ path: '/product-types',
+ getParentRoute: () => SettingsRoute,
+} as any)
const SettingsPaymentMethodsRoute = SettingsPaymentMethodsRouteImport.update({
id: '/payment-methods',
path: '/payment-methods',
@@ -353,6 +359,7 @@ export interface FileRoutesByFullPath {
'/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -403,6 +410,7 @@ export interface FileRoutesByTo {
'/$storeId/settings/emails': typeof SettingsEmailsRoute
'/$storeId/settings/markets': typeof SettingsMarketsRoute
'/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/$storeId/settings/profile': typeof SettingsProfileRoute
'/$storeId/settings/staff': typeof SettingsStaffRoute
'/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -457,6 +465,7 @@ export interface FileRoutesById {
'/_authenticated/$storeId/settings/emails': typeof SettingsEmailsRoute
'/_authenticated/$storeId/settings/markets': typeof SettingsMarketsRoute
'/_authenticated/$storeId/settings/payment-methods': typeof SettingsPaymentMethodsRoute
+ '/_authenticated/$storeId/settings/product-types': typeof SettingsProductTypesRoute
'/_authenticated/$storeId/settings/profile': typeof SettingsProfileRoute
'/_authenticated/$storeId/settings/staff': typeof SettingsStaffRoute
'/_authenticated/$storeId/settings/stock-locations': typeof SettingsStockLocationsRoute
@@ -511,6 +520,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/emails'
| '/$storeId/settings/markets'
| '/$storeId/settings/payment-methods'
+ | '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
@@ -561,6 +571,7 @@ export interface FileRouteTypes {
| '/$storeId/settings/emails'
| '/$storeId/settings/markets'
| '/$storeId/settings/payment-methods'
+ | '/$storeId/settings/product-types'
| '/$storeId/settings/profile'
| '/$storeId/settings/staff'
| '/$storeId/settings/stock-locations'
@@ -614,6 +625,7 @@ export interface FileRouteTypes {
| '/_authenticated/$storeId/settings/emails'
| '/_authenticated/$storeId/settings/markets'
| '/_authenticated/$storeId/settings/payment-methods'
+ | '/_authenticated/$storeId/settings/product-types'
| '/_authenticated/$storeId/settings/profile'
| '/_authenticated/$storeId/settings/staff'
| '/_authenticated/$storeId/settings/stock-locations'
@@ -792,6 +804,13 @@ declare module '@tanstack/react-router' {
preLoaderRoute: typeof SettingsProfileRouteImport
parentRoute: typeof SettingsRoute
}
+ '/_authenticated/$storeId/settings/product-types': {
+ id: '/_authenticated/$storeId/settings/product-types'
+ path: '/product-types'
+ fullPath: '/$storeId/settings/product-types'
+ preLoaderRoute: typeof SettingsProductTypesRouteImport
+ parentRoute: typeof SettingsRoute
+ }
'/_authenticated/$storeId/settings/payment-methods': {
id: '/_authenticated/$storeId/settings/payment-methods'
path: '/payment-methods'
@@ -1015,6 +1034,7 @@ interface SettingsRouteChildren {
SettingsEmailsRoute: typeof SettingsEmailsRoute
SettingsMarketsRoute: typeof SettingsMarketsRoute
SettingsPaymentMethodsRoute: typeof SettingsPaymentMethodsRoute
+ SettingsProductTypesRoute: typeof SettingsProductTypesRoute
SettingsProfileRoute: typeof SettingsProfileRoute
SettingsStaffRoute: typeof SettingsStaffRoute
SettingsStockLocationsRoute: typeof SettingsStockLocationsRoute
@@ -1036,6 +1056,7 @@ const SettingsRouteChildren: SettingsRouteChildren = {
SettingsEmailsRoute: SettingsEmailsRoute,
SettingsMarketsRoute: SettingsMarketsRoute,
SettingsPaymentMethodsRoute: SettingsPaymentMethodsRoute,
+ SettingsProductTypesRoute: SettingsProductTypesRoute,
SettingsProfileRoute: SettingsProfileRoute,
SettingsStaffRoute: SettingsStaffRoute,
SettingsStockLocationsRoute: SettingsStockLocationsRoute,
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
index cd7041213b..d131865885 100644
--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/$productId.tsx
@@ -141,6 +141,7 @@ function productToFormValues(
category_ids: product.categories?.map((t) => t.id) ?? [],
tags: product.tags ?? [],
tax_category_id: product.tax_category_id ?? null,
+ product_type_id: product.product_type_id ?? null,
meta_title: product.meta_title ?? '',
meta_description: product.meta_description ?? '',
slug: product.slug ?? '',
diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/product-types.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/product-types.tsx
new file mode 100644
index 0000000000..674033d81c
--- /dev/null
+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/product-types.tsx
@@ -0,0 +1,348 @@
+import { zodResolver } from '@hookform/resolvers/zod'
+import type { ProductType } from '@spree/admin-sdk'
+import {
+ adminClient,
+ Can,
+ mapSpreeErrorsToForm,
+ ResourceTable,
+ resourceSearchSchema,
+ Subject,
+ usePermissions,
+} from '@spree/dashboard-core'
+import {
+ Button,
+ Checkbox,
+ Field,
+ FieldError,
+ FieldGroup,
+ FieldLabel,
+ Input,
+ RowActions,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetFooter,
+ SheetHeader,
+ SheetTitle,
+ useConfirm,
+ useRowClickBridge,
+} from '@spree/dashboard-ui'
+import { createFileRoute, useNavigate } from '@tanstack/react-router'
+import { PlusIcon } from 'lucide-react'
+import { useEffect } from 'react'
+import { Controller, type UseFormReturn, useForm } from 'react-hook-form'
+import { useTranslation } from 'react-i18next'
+import { z } from 'zod/v4'
+import {
+ useCreateProductType,
+ useDeleteProductType,
+ useProductType,
+ useUpdateProductType,
+} from '../../../../hooks/use-product-types'
+import { FULFILLMENT_TYPES } from '../../../../schemas/delivery-method'
+import '../../../../tables/product-types'
+
+const productTypeFormSchema = z.object({
+ name: z.string().min(1),
+ fulfillment_types: z.array(z.string()).min(1),
+})
+
+type ProductTypeFormValues = z.infer<typeof productTypeFormSchema>
+
+const PRODUCT_TYPE_DEFAULTS: ProductTypeFormValues = {
+ name: '',
+ fulfillment_types: ['shipping'],
+}
+
+const productTypesSearchSchema = resourceSearchSchema.extend({
+ edit: z.string().optional(),
+ new: z.coerce.boolean().optional(),
+})
+
+export const Route = createFileRoute('/_authenticated/$storeId/settings/product-types')({
+ validateSearch: productTypesSearchSchema,
+ component: ProductTypesPage,
+})
+
+function ProductTypesPage() {
+ const { t } = useTranslation()
+ const search = Route.useSearch() as z.infer<typeof productTypesSearchSchema>
+ const navigate = useNavigate()
+ const confirm = useConfirm()
+ const deleteMutation = useDeleteProductType()
+ const { permissions } = usePermissions()
+
+ const editId = search.edit
+ const isCreating = !!search.new
+
+ const closeSheet = () =>
+ navigate({
+ search: (prev: Record<string, unknown>) => {
+ const { edit: _e, new: _n, ...rest } = prev
+ return rest as never
+ },
+ })
+
+ const openCreate = () =>
+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, new: true }) as never })
+
+ const openEdit = (id: string) =>
+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, edit: id }) as never })
+
+ useRowClickBridge('data-product-type-id', openEdit)
+
+ async function handleDelete(productType: ProductType) {
+ const ok = await confirm({
+ title: t('admin.product_types.delete_confirm.title'),
+ message: t('admin.product_types.delete_confirm.message', {
+ name: productType.name ?? '',
+ }),
+ variant: 'destructive',
+ confirmLabel: t('admin.actions.delete'),
+ })
+ if (!ok) return
+ await deleteMutation.mutateAsync(productType.id).catch(() => undefined)
+ }
+
+ return (
+ <>
+ <ResourceTable<ProductType>
+ tableKey="product-types"
+ queryKey="product-types"
+ queryFn={(params) => adminClient.productTypes.list(params)}
+ searchParams={search}
+ rowActions={(productType) => (
+ <RowActions
+ actions={[
+ { key: 'edit', onSelect: () => openEdit(productType.id) },
+ {
+ key: 'delete',
+ destructive: true,
+ visible: permissions.can('destroy', Subject.ProductType),
+ disabled: deleteMutation.isPending,
+ onSelect: () => handleDelete(productType),
+ },
+ ]}
+ />
+ )}
+ actions={
+ <Can I="create" a={Subject.ProductType}>
+ <Button size="sm" className="h-[2.125rem]" onClick={openCreate}>
+ <PlusIcon className="size-4" />
+ {t('admin.product_types.add_cta')}
+ </Button>
+ </Can>
+ }
+ />
+
+ {isCreating && <CreateProductTypeSheet open onOpenChange={(o) => !o && closeSheet()} />}
+ {editId && <EditProductTypeSheet id={editId} open onOpenChange={(o) => !o && closeSheet()} />}
+ </>
+ )
+}
+
+function CreateProductTypeSheet({
+ open,
+ onOpenChange,
+}: {
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const createMutation = useCreateProductType()
+ const form = useForm<ProductTypeFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(productTypeFormSchema) as any,
+ defaultValues: PRODUCT_TYPE_DEFAULTS,
+ })
+
+ async function onSubmit(values: ProductTypeFormValues) {
+ try {
+ await createMutation.mutateAsync(values)
+ form.reset(PRODUCT_TYPE_DEFAULTS)
+ onOpenChange(false)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ return (
+ <Sheet
+ open={open}
+ onOpenChange={(next) => {
+ if (!next) form.reset(PRODUCT_TYPE_DEFAULTS)
+ onOpenChange(next)
+ }}
+ >
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{t('admin.product_types.add_sheet_title')}</SheetTitle>
+ <SheetDescription>{t('admin.product_types.create_description')}</SheetDescription>
+ </SheetHeader>
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <ProductTypeFormFields form={form} />
+ </div>
+ <SheetFooter>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button type="submit" size="sm" disabled={form.formState.isSubmitting}>
+ {form.formState.isSubmitting
+ ? t('admin.actions.creating')
+ : t('admin.product_types.create_label')}
+ </Button>
+ </SheetFooter>
+ </form>
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function EditProductTypeSheet({
+ id,
+ open,
+ onOpenChange,
+}: {
+ id: string
+ open: boolean
+ onOpenChange: (open: boolean) => void
+}) {
+ const { t } = useTranslation()
+ const { data: productType, isLoading } = useProductType(id)
+ const updateMutation = useUpdateProductType(id)
+
+ const form = useForm<ProductTypeFormValues>({
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ resolver: zodResolver(productTypeFormSchema) as any,
+ defaultValues: PRODUCT_TYPE_DEFAULTS,
+ })
+
+ useEffect(() => {
+ if (productType) {
+ form.reset({
+ name: productType.name,
+ fulfillment_types: productType.fulfillment_types ?? ['shipping'],
+ })
+ }
+ }, [productType, form])
+
+ async function onSubmit(values: ProductTypeFormValues) {
+ try {
+ await updateMutation.mutateAsync(values)
+ form.reset(values)
+ onOpenChange(false)
+ } catch (err) {
+ if (!mapSpreeErrorsToForm(err, form.setError)) throw err
+ }
+ }
+
+ return (
+ <Sheet open={open} onOpenChange={onOpenChange}>
+ <SheetContent>
+ <SheetHeader>
+ <SheetTitle>{productType?.name ?? t('admin.product_types.edit_sheet_title')}</SheetTitle>
+ <SheetDescription>{t('admin.product_types.edit_description')}</SheetDescription>
+ </SheetHeader>
+ {isLoading ? (
+ <div className="p-4 text-sm text-muted-foreground">{t('admin.common.loading')}</div>
+ ) : (
+ <form onSubmit={form.handleSubmit(onSubmit)} className="flex min-h-0 flex-1 flex-col">
+ <div className="flex flex-1 flex-col gap-4 overflow-y-auto p-4">
+ <ProductTypeFormFields form={form} />
+ </div>
+ <SheetFooter>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={() => onOpenChange(false)}
+ disabled={form.formState.isSubmitting}
+ >
+ {t('admin.actions.cancel')}
+ </Button>
+ <Button
+ type="submit"
+ size="sm"
+ disabled={form.formState.isSubmitting || !form.formState.isDirty}
+ >
+ {form.formState.isSubmitting ? t('admin.actions.saving') : t('admin.actions.save')}
+ </Button>
+ </SheetFooter>
+ </form>
+ )}
+ </SheetContent>
+ </Sheet>
+ )
+}
+
+function ProductTypeFormFields({ form }: { form: UseFormReturn<ProductTypeFormValues> }) {
+ const { t } = useTranslation()
+ const { errors } = form.formState
+
+ return (
+ <FieldGroup>
+ {errors.root?.message && (
+ <p className="text-sm text-destructive" role="alert">
+ {errors.root.message}
+ </p>
+ )}
+ <Field>
+ <FieldLabel htmlFor="name">{t('admin.fields.name.label')}</FieldLabel>
+ <Input
+ id="name"
+ autoFocus
+ placeholder={t('admin.fields.product_type.name.placeholder')}
+ aria-invalid={!!errors.name || undefined}
+ {...form.register('name')}
+ />
+ <FieldError errors={[errors.name]} />
+ </Field>
+
+ <Field>
+ <FieldLabel>{t('admin.fields.product_type.fulfillment_types.label')}</FieldLabel>
+ <span className="text-muted-foreground text-xs">
+ {t('admin.fields.product_type.fulfillment_types.help')}
+ </span>
+ <Controller
+ name="fulfillment_types"
+ control={form.control}
+ render={({ field }) => (
+ <div className="flex flex-col gap-2">
+ {FULFILLMENT_TYPES.map((fulfillmentType) => {
+ const checked = field.value.includes(fulfillmentType)
+ return (
+ <label
+ key={fulfillmentType}
+ htmlFor={`fulfillment-type-${fulfillmentType}`}
+ className="flex items-center gap-2 text-sm"
+ >
+ <Checkbox
+ id={`fulfillment-type-${fulfillmentType}`}
+ checked={checked}
+ onCheckedChange={(next) => {
+ field.onChange(
+ next
+ ? [...field.value, fulfillmentType]
+ : field.value.filter((value) => value !== fulfillmentType),
+ )
+ }}
+ />
+ {t(`admin.delivery_methods.fulfillment_types.${fulfillmentType}`)}
+ </label>
+ )
+ })}
+ </div>
+ )}
+ />
+ <FieldError errors={[errors.fulfillment_types]} />
+ </Field>
+ </FieldGroup>
+ )
+}
diff --git a/packages/dashboard/src/schemas/product.ts b/packages/dashboard/src/schemas/product.ts
index ea76d8f8ed..3fdc4dc228 100644
--- a/packages/dashboard/src/schemas/product.ts
+++ b/packages/dashboard/src/schemas/product.ts
@@ -108,6 +108,9 @@ export const productFormSchema = z.object({
// Tax
tax_category_id: z.string().nullable().optional(),
+ // Product type — drives fulfillment eligibility (shipping/pickup/digital)
+ product_type_id: z.string().nullable().optional(),
+
// SEO
meta_title: z.string().optional(),
meta_description: z.string().optional(),
@@ -148,6 +151,7 @@ export function newProductFormDefaults(): ProductFormValues {
category_ids: [],
tags: [],
tax_category_id: null,
+ product_type_id: null,
meta_title: '',
meta_description: '',
slug: '',
diff --git a/packages/dashboard/src/tables/product-types.tsx b/packages/dashboard/src/tables/product-types.tsx
new file mode 100644
index 0000000000..0d685d87f2
--- /dev/null
+++ b/packages/dashboard/src/tables/product-types.tsx
@@ -0,0 +1,52 @@
+import type { ProductType } from '@spree/admin-sdk'
+import { defineTable } from '@spree/dashboard-core'
+import { Badge, ResourceNameCell } from '@spree/dashboard-ui'
+import i18n from 'i18next'
+import { ShapesIcon } from 'lucide-react'
+
+defineTable<ProductType>('product-types', {
+ title: i18n.t('admin.settings_nav.items.product_types'),
+ searchParam: 'name_cont',
+ searchPlaceholder: i18n.t('admin.product_types.search_placeholder'),
+ defaultSort: { field: 'name', direction: 'asc' },
+ emptyIcon: <ShapesIcon className="size-8 text-muted-foreground" />,
+ emptyMessage: i18n.t('admin.product_types.empty'),
+ columns: [
+ {
+ key: 'name',
+ label: i18n.t('admin.fields.name.label'),
+ sortable: true,
+ filterable: true,
+ default: true,
+ render: (productType) => (
+ <ResourceNameCell
+ id={productType.id}
+ dataAttr="data-product-type-id"
+ name={productType.name}
+ />
+ ),
+ },
+ {
+ key: 'fulfillment_types',
+ label: i18n.t('admin.fields.product_type.fulfillment_types.label'),
+ default: true,
+ render: (productType) => (
+ <div className="flex flex-wrap gap-1">
+ {(productType.fulfillment_types ?? []).map((fulfillmentType) => (
+ <Badge key={fulfillmentType} variant="secondary">
+ {i18n.t(`admin.delivery_methods.fulfillment_types.${fulfillmentType}`, {
+ defaultValue: fulfillmentType,
+ })}
+ </Badge>
+ ))}
+ </div>
+ ),
+ },
+ {
+ key: 'products_count',
+ label: i18n.t('admin.fields.product_type.products_count.label'),
+ default: true,
+ render: (productType) => productType.products_count,
+ },
+ ],
+})
diff --git a/packages/sdk/src/types/generated/ProductType.ts b/packages/sdk/src/types/generated/ProductType.ts
new file mode 100644
index 0000000000..416dd22e3d
--- /dev/null
+++ b/packages/sdk/src/types/generated/ProductType.ts
@@ -0,0 +1,10 @@
+// Typelizer digest bd0975d0124a6e79331aee6f94c055ad
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+interface ProductType {
+ id: string;
+ name: string;
+}
+
+export default ProductType;
diff --git a/packages/sdk/src/types/generated/index.ts b/packages/sdk/src/types/generated/index.ts
index 3e4f36ab16..efbb301a3f 100644
--- a/packages/sdk/src/types/generated/index.ts
+++ b/packages/sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest af38c3d2c47b5db8a900b9c388b07063
+// Typelizer digest cadf3d42e60cae8c5179438aea071d93
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as Address } from './Address'
@@ -53,6 +53,7 @@ export type { default as ProductFilterSortOption } from './ProductFilterSortOpti
export type { default as ProductFilters } from './ProductFilters'
export type { default as ProductPublication } from './ProductPublication'
export type { default as Product } from './Product'
+export type { default as ProductType } from './ProductType'
export type { default as Promotion } from './Promotion'
export type { default as Refund } from './Refund'
export type { default as ReturnAuthorization } from './ReturnAuthorization'
diff --git a/packages/sdk/src/zod/generated/ProductType.ts b/packages/sdk/src/zod/generated/ProductType.ts
new file mode 100644
index 0000000000..500b74c19d
--- /dev/null
+++ b/packages/sdk/src/zod/generated/ProductType.ts
@@ -0,0 +1,9 @@
+// This file is auto-generated. Do not edit directly.
+import { z } from 'zod';
+
+export const ProductTypeSchema = z.object({
+ id: z.string(),
+ name: z.string(),
+});
+
+export type ProductType = z.infer<typeof ProductTypeSchema>;
diff --git a/packages/sdk/src/zod/generated/index.ts b/packages/sdk/src/zod/generated/index.ts
index fbfd94d369..738ababe85 100644
--- a/packages/sdk/src/zod/generated/index.ts
+++ b/packages/sdk/src/zod/generated/index.ts
@@ -51,6 +51,7 @@ export { ProductFilterPriceRangeSchema, type ProductFilterPriceRange } from './P
export { ProductFilterSortOptionSchema, type ProductFilterSortOption } from './ProductFilterSortOption';
export { ProductFiltersSchema, type ProductFilters } from './ProductFilters';
export { ProductPublicationSchema, type ProductPublication } from './ProductPublication';
+export { ProductTypeSchema, type ProductType } from './ProductType';
export { PromotionSchema, type Promotion } from './Promotion';
export { RefundSchema, type Refund } from './Refund';
export { ReturnAuthorizationSchema, type ReturnAuthorization } from './ReturnAuthorization';
diff --git a/spree/api/app/controllers/spree/api/v3/admin/product_types_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/product_types_controller.rb
new file mode 100644
index 0000000000..5d88a16d4a
--- /dev/null
+++ b/spree/api/app/controllers/spree/api/v3/admin/product_types_controller.rb
@@ -0,0 +1,25 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class ProductTypesController < ResourceController
+ scoped_resource :products
+
+ protected
+
+ def model_class
+ Spree::ProductType
+ end
+
+ def serializer_class
+ Spree.api.admin_product_type_serializer
+ end
+
+ def permitted_params
+ params.permit(:name, fulfillment_types: [])
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
index a947f4d240..eafc8a640f 100644
--- a/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
+++ b/spree/api/app/controllers/spree/api/v3/admin/products_controller.rb
@@ -177,7 +177,7 @@ module Spree
params.permit(
:name, :description, :slug, :status,
:meta_title, :meta_description, :meta_keywords,
- :tax_category_id,
+ :tax_category_id, :product_type_id,
:promotionable, :digital,
tags: [],
category_ids: [],
diff --git a/spree/api/app/serializers/spree/api/v3/admin/product_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/product_serializer.rb
index 7a87a62a8f..93c4859659 100644
--- a/spree/api/app/serializers/spree/api/v3/admin/product_serializer.rb
+++ b/spree/api/app/serializers/spree/api/v3/admin/product_serializer.rb
@@ -10,6 +10,7 @@ module Spree
typelize status: :string,
tax_category_id: [:string, nullable: true],
+ product_type_id: [:string, nullable: true],
price: ['Price', nullable: true],
deleted_at: [:string, nullable: true],
metadata: 'Record<string, unknown>'
@@ -18,6 +19,10 @@ module Spree
:metadata, deleted_at: :iso8601,
created_at: :iso8601, updated_at: :iso8601
+ attribute :product_type_id do |product|
+ product.product_type&.prefixed_id
+ end
+
attribute :tax_category_id do |product|
product.tax_category&.prefixed_id
end
diff --git a/spree/api/app/serializers/spree/api/v3/admin/product_type_serializer.rb b/spree/api/app/serializers/spree/api/v3/admin/product_type_serializer.rb
new file mode 100644
index 0000000000..6ec7f54bb2
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/admin/product_type_serializer.rb
@@ -0,0 +1,15 @@
+module Spree
+ module Api
+ module V3
+ module Admin
+ class ProductTypeSerializer < V3::ProductTypeSerializer
+ typelize fulfillment_types: [:string, multi: true],
+ products_count: :number
+
+ attributes :fulfillment_types, :products_count,
+ created_at: :iso8601, updated_at: :iso8601
+ end
+ end
+ end
+ end
+end
diff --git a/spree/api/app/serializers/spree/api/v3/product_type_serializer.rb b/spree/api/app/serializers/spree/api/v3/product_type_serializer.rb
new file mode 100644
index 0000000000..f3bacffae2
--- /dev/null
+++ b/spree/api/app/serializers/spree/api/v3/product_type_serializer.rb
@@ -0,0 +1,13 @@
+module Spree
+ module Api
+ module V3
+ # Store API Product Type Serializer
+ # Read-only expand on products — customers only see the type's name.
+ class ProductTypeSerializer < BaseSerializer
+ typelize name: :string
+
+ attributes :name
+ end
+ end
+ end
+end
diff --git a/spree/api/config/routes.rb b/spree/api/config/routes.rb
index 330100e529..3baf2c0e82 100644
--- a/spree/api/config/routes.rb
+++ b/spree/api/config/routes.rb
@@ -227,6 +227,7 @@ Spree::Core::Engine.add_routes do
end
# Products
+ resources :product_types
resources :products, concerns: [:custom_fieldable, :translatable] do
member do
post :clone
@@ -298,6 +299,7 @@ Spree::Core::Engine.add_routes do
resources :delivery_methods do
collection do
get :calculators
+ get :fulfillment_providers
end
resources :rules, controller: 'delivery_methods/rules', only: [:index, :show, :create, :update, :destroy]
end
diff --git a/spree/api/lib/spree/api/dependencies.rb b/spree/api/lib/spree/api/dependencies.rb
index 7bb7d5e01d..fd933bb644 100644
--- a/spree/api/lib/spree/api/dependencies.rb
+++ b/spree/api/lib/spree/api/dependencies.rb
@@ -9,6 +9,7 @@ module Spree
price_serializer: 'Spree::Api::V3::PriceSerializer',
price_history_serializer: 'Spree::Api::V3::PriceHistorySerializer',
product_serializer: 'Spree::Api::V3::ProductSerializer',
+ product_type_serializer: 'Spree::Api::V3::ProductTypeSerializer',
variant_serializer: 'Spree::Api::V3::VariantSerializer',
media_serializer: 'Spree::Api::V3::MediaSerializer',
option_type_serializer: 'Spree::Api::V3::OptionTypeSerializer',
@@ -102,6 +103,7 @@ module Spree
admin_newsletter_subscriber_serializer: 'Spree::Api::V3::Admin::NewsletterSubscriberSerializer',
admin_order_serializer: 'Spree::Api::V3::Admin::OrderSerializer',
admin_product_serializer: 'Spree::Api::V3::Admin::ProductSerializer',
+ admin_product_type_serializer: 'Spree::Api::V3::Admin::ProductTypeSerializer',
admin_variant_serializer: 'Spree::Api::V3::Admin::VariantSerializer',
admin_price_serializer: 'Spree::Api::V3::Admin::PriceSerializer',
admin_price_history_serializer: 'Spree::Api::V3::Admin::PriceHistorySerializer',
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/product_types_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/product_types_controller_spec.rb
new file mode 100644
index 0000000000..0278d27417
--- /dev/null
+++ b/spree/api/spec/controllers/spree/api/v3/admin/product_types_controller_spec.rb
@@ -0,0 +1,68 @@
+require 'spec_helper'
+
+RSpec.describe Spree::Api::V3::Admin::ProductTypesController, type: :controller do
+ render_views
+
+ include_context 'API v3 Admin authenticated'
+
+ let!(:product_type) { create(:product_type, name: 'T-Shirt', store: store) }
+
+ before { request.headers.merge!(headers) }
+
+ describe 'GET #index' do
+ it 'lists the store product types' do
+ get :index, params: {}, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['data'].map { |row| row['name'] }).to include('T-Shirt')
+ end
+
+ it 'does not leak other stores types' do
+ create(:product_type, name: 'Foreign', store: create(:store))
+
+ get :index, params: {}, as: :json
+
+ expect(json_response['data'].map { |row| row['name'] }).not_to include('Foreign')
+ end
+ end
+
+ describe 'POST #create' do
+ it 'creates a product type with fulfillment types' do
+ post :create, params: { name: 'Collectable', fulfillment_types: %w[shipping pickup] }, as: :json
+
+ expect(response).to have_http_status(:created)
+ expect(json_response['name']).to eq('Collectable')
+ expect(json_response['fulfillment_types']).to eq(%w[shipping pickup])
+
+ created = Spree::ProductType.find_by(name: 'Collectable')
+ expect(created.store).to eq(store)
+ end
+ end
+
+ describe 'PATCH #update' do
+ it 'updates fulfillment types' do
+ patch :update, params: { id: product_type.prefixed_id, fulfillment_types: %w[shipping pickup] }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(product_type.reload.fulfillment_types).to eq(%w[shipping pickup])
+ end
+ end
+
+ describe 'DELETE #destroy' do
+ it 'refuses while products still use the type' do
+ create(:product, product_type: product_type, store: store)
+
+ delete :destroy, params: { id: product_type.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:unprocessable_entity)
+ expect(product_type.reload).to be_present
+ end
+
+ it 'deletes an unused type' do
+ delete :destroy, params: { id: product_type.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:no_content)
+ expect(Spree::ProductType.find_by(id: product_type.id)).to be_nil
+ end
+ end
+end
diff --git a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
index 450c6d381f..143c19a795 100644
--- a/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
+++ b/spree/api/spec/controllers/spree/api/v3/admin/products_controller_spec.rb
@@ -726,6 +726,26 @@ RSpec.describe Spree::Api::V3::Admin::ProductsController, type: :controller do
expect(product.reload.name).to eq('Updated Name')
end
+ it 'assigns a product type by prefixed id and returns it' do
+ product_type = create(:product_type, store: store, fulfillment_types: %w[shipping pickup])
+
+ patch :update, params: { id: product.prefixed_id, product_type_id: product_type.prefixed_id }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(json_response['product_type_id']).to eq(product_type.prefixed_id)
+ expect(product.reload.product_type).to eq(product_type)
+ expect(product.fulfillment_types).to eq(%w[shipping pickup])
+ end
+
+ it 'clears the product type with null' do
+ product.update!(product_type: create(:product_type, store: store))
+
+ patch :update, params: { id: product.prefixed_id, product_type_id: nil }, as: :json
+
+ expect(response).to have_http_status(:ok)
+ expect(product.reload.product_type).to be_nil
+ end
+
context 'with full payload: name, description, status, categories, tags, SEO, variants with multi-currency prices' do
let!(:product_to_update) do
create(:product_with_option_types).tap do |p|
diff --git a/spree/core/app/models/spree/permission_sets/product_display.rb b/spree/core/app/models/spree/permission_sets/product_display.rb
index ac3c7ee9b9..8a9cdab301 100644
--- a/spree/core/app/models/spree/permission_sets/product_display.rb
+++ b/spree/core/app/models/spree/permission_sets/product_display.rb
@@ -13,6 +13,7 @@ module Spree
can [:read, :admin, :index], Spree::Product
can [:read, :admin], Spree::Variant
can [:read, :admin], Spree::OptionType
+ can [:read, :admin], Spree::ProductType
can [:read, :admin], Spree::OptionValue
can [:read, :admin], Spree::Metafield
can [:read, :admin], Spree::Collection
diff --git a/spree/core/app/models/spree/permission_sets/product_management.rb b/spree/core/app/models/spree/permission_sets/product_management.rb
index 2e356959ec..2ae417b5b5 100644
--- a/spree/core/app/models/spree/permission_sets/product_management.rb
+++ b/spree/core/app/models/spree/permission_sets/product_management.rb
@@ -11,6 +11,7 @@ module Spree
class ProductManagement < Base
def activate!
can :manage, Spree::Product
+ can :manage, Spree::ProductType
can :manage, Spree::Variant
can :manage, Spree::OptionType
can :manage, Spree::OptionValue