Skip to content

Commit

Permalink
fix: cart to quote issue
Browse files Browse the repository at this point in the history
  • Loading branch information
b3aton committed Mar 17, 2023
1 parent 8d02166 commit 7950e2b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
7 changes: 4 additions & 3 deletions apps/storefront/src/hooks/useCartToQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,13 @@ const useCartToQuote = ({
name,
quantity,
variantId,
originalPrice,
salePrice,
imageUrl,
listPrice,
} = product

const optionsList = getOptionsList(options)

const currentProductSearch = newProductInfo.find((product: any) => +product.id === +productId)

const quoteListitem = {
Expand All @@ -265,8 +266,8 @@ const useCartToQuote = ({
quantity: +quantity || 1,
optionList: JSON.stringify(optionsList),
productId,
basePrice: originalPrice,
tax: salePrice - originalPrice,
basePrice: listPrice,
tax: salePrice - listPrice,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ interface NodeProps {
variantId: number,
variantSku: string,
productsSearch: CustomFieldItems,
optionSelections: CustomFieldItems,
}

interface ProductsProps {
Expand Down Expand Up @@ -208,17 +209,12 @@ const QuickOrderFooter = (props: QuickOrderFooterProps) => {
inventoryInfos.forEach((inventory: CustomFieldItems) => {
if (node.variantSku === inventory.variantSku) {
const {
optionList,
optionSelections,
quantity,
} = node

const options = optionList.map((option: CustomFieldItems) => ({
optionId: option.product_option_id,
optionValue: option.value,
}))

lineItems.push({
optionList: options,
optionSelections,
productId: parseInt(inventory.productId, 10) || 0,
quantity,
variantId: parseInt(inventory.variantId, 10) || 0,
Expand Down Expand Up @@ -347,6 +343,7 @@ const QuickOrderFooter = (props: QuickOrderFooterProps) => {
} = product

const optionsList = getOptionsList(optionList)

const currentProductSearch = newProductInfo.find((product: CustomFieldItems) => +product.id === +productId)

const variantItem = currentProductSearch.variants.find((item: CustomFieldItems) => item.sku === variantSku)
Expand Down
2 changes: 1 addition & 1 deletion apps/storefront/src/pages/quote/QuoteDraft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ const QuoteDraft = ({

let prices = 0
let tax = 0
node.additionalCalculatedPrices.forEach((item: CustomFieldItems) => {
node.additionalCalculatedPrices?.forEach((item: CustomFieldItems) => {
prices += item.additionalCalculatedPrice
tax += item.additionalCalculatedPriceTax
})
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/shared/service/b2b/graphql/quickorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ const orderedProducts = (data: CustomFieldItems) => `{
discount,
tax,
enteredInclusive,
productUrl
productUrl,
optionSelections,
}
}
}
Expand Down

0 comments on commit 7950e2b

Please sign in to comment.