diff --git a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx index 04830a62..84619e02 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickOrderFooter.tsx @@ -294,6 +294,8 @@ function QuickOrderFooter(props: QuickOrderFooterProps) { const newProductInfo: CustomFieldItems = conversionProductsList(productsSearch) let isSuccess = false + let errorMessage = '' + let isFondVariant = true const newProducts: CustomFieldItems[] = [] productsWithSku.forEach((product: ListItemProps) => { @@ -320,6 +322,11 @@ function QuickOrderFooter(props: QuickOrderFooterProps) { (item: CustomFieldItems) => item.sku === variantSku ) + if (!variantItem) { + errorMessage = `${variantSku} not found` + isFondVariant = false + } + const quoteListitem = { node: { id: uuid(), @@ -343,6 +350,20 @@ function QuickOrderFooter(props: QuickOrderFooterProps) { isSuccess = validProductQty(newProducts) + if (!isFondVariant) { + snackbar.error('', { + jsx: successTip({ + message: errorMessage, + link: '', + linkText: '', + isOutLink: false, + }), + isClose: true, + }) + + return + } + if (isSuccess) { await calculateProductListPrice(newProducts, '2') addQuoteDraftProducts(newProducts) diff --git a/apps/storefront/src/pages/quickorder/components/QuickorderTable.tsx b/apps/storefront/src/pages/quickorder/components/QuickorderTable.tsx index 89f413ea..48f85c89 100644 --- a/apps/storefront/src/pages/quickorder/components/QuickorderTable.tsx +++ b/apps/storefront/src/pages/quickorder/components/QuickorderTable.tsx @@ -344,7 +344,8 @@ function QuickorderTable({ } = row let priceIncTax = +basePrice if (variants?.length) { - priceIncTax = getProductPriceIncTax(variants, +variantId) + priceIncTax = + getProductPriceIncTax(variants, +variantId) || +basePrice } const withTaxPrice = priceIncTax || +basePrice diff --git a/apps/storefront/src/utils/b3Price.ts b/apps/storefront/src/utils/b3Price.ts index beed253d..257350c1 100644 --- a/apps/storefront/src/utils/b3Price.ts +++ b/apps/storefront/src/utils/b3Price.ts @@ -1,3 +1,5 @@ +import { isEmpty } from 'lodash' + const getProductPriceIncTax = ( variants: CustomFieldItems, variantId?: number, @@ -8,13 +10,18 @@ const getProductPriceIncTax = ( (item: CustomFieldItems) => +item.variant_id === variantId || variantSku === item.sku ) || {} - const bcCalculatedPrice: { - tax_inclusive: number | string - } = currentVariantInfo.bc_calculated_price - const priceIncTax = +bcCalculatedPrice.tax_inclusive + if (!isEmpty(currentVariantInfo)) { + const bcCalculatedPrice: { + tax_inclusive: number | string + } = currentVariantInfo.bc_calculated_price + + const priceIncTax = +bcCalculatedPrice.tax_inclusive + + return priceIncTax + } - return priceIncTax + return false } export default getProductPriceIncTax