[장바구니] 금액 노출관련 수정
- 계산했을때 맞지않던 부분, 옵션가 노출관련 처리. - 사이드바 부분에서도 계산 맞지않던 부분에 대하여 수정
This commit is contained in:
@@ -138,12 +138,12 @@ const CartProduct = ({ cartInfo, getScrollTo, scrollTop }) => {
|
||||
// 파트너사별 총합 계산
|
||||
const calculatePartnerTotal = (items) => {
|
||||
const productTotal = items.reduce((sum, item) =>
|
||||
sum + (parseFloat(item.price3 || item.price2 || 0) * item.prodQty), 0
|
||||
sum + (parseFloat(Number(item.price3) !== 0 ? Number(item.price3) : Number(item.price2) !== 0 ? Number(item.price2) : 0) * item.prodQty), 0
|
||||
);
|
||||
// const optionTotal = items.reduce((sum, item) =>
|
||||
// sum + (parseFloat(item.optPrc.replace("$","") || 0) * item.prodQty), 0
|
||||
// );
|
||||
const optionTotal = 0;
|
||||
const optionTotal = items.reduce((sum, item) =>
|
||||
sum + (parseFloat(Number(item.price5) !== 0 ? Number(item.price5) : Number(item.optPrc) !== 0 ? Number(item.optPrc) : 0) * item.prodQty), 0
|
||||
);
|
||||
|
||||
const shippingTotal = items.reduce((sum, item) =>
|
||||
sum + parseFloat((item.shippingCharge) * item.prodQty || 0), 0
|
||||
);
|
||||
@@ -268,7 +268,6 @@ const CartProduct = ({ cartInfo, getScrollTo, scrollTop }) => {
|
||||
<>
|
||||
{Object.entries(groupedCartData).map(([partnerKey, group], index) => {
|
||||
const totals = calculatePartnerTotal(group.items);
|
||||
|
||||
return (
|
||||
<Container key={partnerKey} className={css.productBox}>
|
||||
{index === 0 && (
|
||||
@@ -298,13 +297,15 @@ const CartProduct = ({ cartInfo, getScrollTo, scrollTop }) => {
|
||||
Product Total ${totals.productTotal.toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})} +
|
||||
|
||||
{/* Option ${totals.optionTotal.toLocaleString('en-US', {
|
||||
})} +
|
||||
{totals.optionTotal > 0 && (
|
||||
<>
|
||||
Option ${totals.optionTotal.toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})} + */}
|
||||
Option $0.00 +
|
||||
})} +
|
||||
</>
|
||||
)}
|
||||
S&H ${totals.shippingTotal.toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
@@ -372,20 +373,22 @@ const CartProduct = ({ cartInfo, getScrollTo, scrollTop }) => {
|
||||
)}
|
||||
<div className={css.accountBox}>
|
||||
<span className={css.account}>
|
||||
${parseFloat(item.price3 || item.price2 || 0).toLocaleString('en-US', {
|
||||
${parseFloat(Number(item.price3) > 0 ? Number(item.price3) : Number(item.price2) > 0 ? Number(item.price2) : 0).toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})}
|
||||
</span>
|
||||
<div className={css.accountInfo}>
|
||||
{item.price2 && (
|
||||
<span className={css.originalAcc}>
|
||||
{item.price2 && (parseFloat(item.price2) > 0 && parseFloat(item.price3) > 0 && parseFloat(item.price2) !== parseFloat(item.price3)) && (
|
||||
<>
|
||||
${parseFloat(item.price2).toLocaleString('en-US', {
|
||||
minimumFractionDigits: 2,
|
||||
maximumFractionDigits: 2
|
||||
})}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</span>
|
||||
{item.price5 && parseFloat(item.price5) > 0 && (
|
||||
<span className={css.optionAcc}>
|
||||
OPTION : ${parseFloat(item.price5).toLocaleString('en-US', {
|
||||
|
||||
@@ -175,16 +175,16 @@ const CartSidebar = ({ cartInfo }) => {
|
||||
// API Mode: 실제 장바구니 데이터로 계산
|
||||
const itemCount = displayCartInfo.reduce((sum, item) => sum + (item.prodQty || 1), 0);
|
||||
const subtotal = displayCartInfo.reduce((sum, item) => {
|
||||
const price = parseFloat(item.price3 || item.price2 || 0);
|
||||
const price = parseFloat(Number(item.price3) !== 0 ? Number(item.price3) : Number(item.price2) !== 0 ? Number(item.price2) : 0);
|
||||
return sum + (price * (item.prodQty || 1));
|
||||
}, 0);
|
||||
const optionTotal = displayCartInfo.reduce((sum, item) => {
|
||||
const optionPrice = parseFloat(item.price5 || item.optPrc || 0);
|
||||
const optionPrice = parseFloat(Number(item.price5) || Number(item.optPrc) || 0);
|
||||
return sum + (optionPrice * (item.prodQty || 1));
|
||||
}, 0);
|
||||
const shippingHandling = displayCartInfo.reduce((sum, item) =>
|
||||
sum + parseFloat(item.shippingCharge || 0), 0
|
||||
);
|
||||
const shippingHandling = displayCartInfo.reduce((sum, item) => {
|
||||
return sum + parseFloat(Number(item.shippingCharge) * (item.prodQty || 1))
|
||||
}, 0);
|
||||
|
||||
return {
|
||||
itemCount,
|
||||
|
||||
Reference in New Issue
Block a user