mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 23:46:58 +00:00
amending SKU factory to include printSizeSKUs
This commit is contained in:
parent
3a8f04ed96
commit
af3750c200
@ -68,3 +68,13 @@ export const sizeSKUs = {
|
|||||||
xxxl: '3XL',
|
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,
|
||||||
|
}
|
||||||
|
@ -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<ReturnType<typeof extractInfoFromTitle>>;
|
type TitleInfo = Awaited<ReturnType<typeof extractInfoFromTitle>>;
|
||||||
|
|
||||||
@ -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 collectionSKU = collectionsSKUs[titleInfo.collectionKey as keyof typeof collectionsSKUs];
|
||||||
const artworkSKU = titleInfo.artworkNumber!.padStart(4, "0");
|
const artworkSKU = titleInfo.artworkNumber!.padStart(4, "0");
|
||||||
const garmentSKU = garmentHandleKeyMapper(titleInfo.garmentKeys);
|
const garmentSKU = garmentHandleKeyMapper(titleInfo.garmentKeys);
|
||||||
|
const printSizeSKU = printSizeSKUs[size];
|
||||||
|
|
||||||
return `SCSQ${collectionSKU}${artworkSKU}_${garmentSKU}`;
|
return `SCSQ${collectionSKU}${artworkSKU}${printSizeSKU}_${garmentSKU}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const customisationSKUMapper = () =>
|
const customisationSKUMapper = () =>
|
||||||
@ -41,8 +51,8 @@ export const createProductSKUs = (productTitle: string) => {
|
|||||||
|
|
||||||
return getGarmentSizes?.map(size => {
|
return getGarmentSizes?.map(size => {
|
||||||
const currentSizeSKU = sizeSKUs[size as keyof typeof sizeSKUs]
|
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}`
|
return `${collectionSKU}_${currentSizeSKU}_${customisationSKUs}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user