Skip to content

Commit

Permalink
fix: hotfix quick order price
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and kris-liu-smile committed Jun 27, 2023
1 parent af91707 commit 82bed42
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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(),
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions apps/storefront/src/utils/b3Price.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { isEmpty } from 'lodash'

const getProductPriceIncTax = (
variants: CustomFieldItems,
variantId?: number,
Expand All @@ -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

0 comments on commit 82bed42

Please sign in to comment.