diff --git a/constants/sku.tsx b/constants/sku.tsx index 9b6006df2..8c35db037 100644 --- a/constants/sku.tsx +++ b/constants/sku.tsx @@ -68,3 +68,13 @@ export const sizeSKUs = { xxxl: '3XL', }; +export const printSizeSKUs = { + [sizeSKUs.xxs]: 1, + [sizeSKUs.xs]: 1, + [sizeSKUs.s]: 2, + [sizeSKUs.m]: 2, + [sizeSKUs.l]: 3, + [sizeSKUs.xl]: 3, + [sizeSKUs.xxl]: 3, + [sizeSKUs.xxxl]: 3, +} diff --git a/lib/helpers/skus.tsx b/lib/helpers/skus.tsx index e1df3f82a..8e35d7810 100644 --- a/lib/helpers/skus.tsx +++ b/lib/helpers/skus.tsx @@ -1,4 +1,13 @@ -import { collectionsSKUs, colorSKUs, customisationSKUs, garmentHandleKeys, garmentSKUs, garmentSizes, sizeSKUs } from "constants/sku"; +import { + collectionsSKUs, + colorSKUs, + customisationSKUs, + garmentHandleKeys, + garmentSKUs, + garmentSizes, + printSizeSKUs, + sizeSKUs, +} from "constants/sku"; type TitleInfo = Awaited>; @@ -22,12 +31,13 @@ const extractInfoFromTitle = (productTitle: string) => { } } -const collectionSKUMapper = (titleInfo: TitleInfo) => { +const collectionSKUMapper = (titleInfo: TitleInfo, size: keyof typeof sizeSKUs) => { const collectionSKU = collectionsSKUs[titleInfo.collectionKey as keyof typeof collectionsSKUs]; const artworkSKU = titleInfo.artworkNumber!.padStart(4, "0"); const garmentSKU = garmentHandleKeyMapper(titleInfo.garmentKeys); + const printSizeSKU = printSizeSKUs[size]; - return `SCSQ${collectionSKU}${artworkSKU}_${garmentSKU}`; + return `SCSQ${collectionSKU}${artworkSKU}${printSizeSKU}_${garmentSKU}`; } const customisationSKUMapper = () => @@ -41,8 +51,8 @@ export const createProductSKUs = (productTitle: string) => { return getGarmentSizes?.map(size => { const currentSizeSKU = sizeSKUs[size as keyof typeof sizeSKUs] - const collectionSKU = collectionSKUMapper(titleInfo) - + const collectionSKU = collectionSKUMapper(titleInfo, currentSizeSKU as keyof typeof sizeSKUs) + return `${collectionSKU}_${currentSizeSKU}_${customisationSKUs}` }) }