[buyoption]
- 갯수 늘렷을때 표시되는 금액 수정
This commit is contained in:
@@ -1502,6 +1502,7 @@ const BuyOption = ({
|
|||||||
productInfo={productInfo || productData}
|
productInfo={productInfo || productData}
|
||||||
selectedOptions={selectedOptions}
|
selectedOptions={selectedOptions}
|
||||||
patncNm={patncNm || productData?.patncNm || productInfo?.patncNm}
|
patncNm={patncNm || productData?.patncNm || productInfo?.patncNm}
|
||||||
|
quantity={quantity}
|
||||||
/>
|
/>
|
||||||
<div className={styles.buy_option__button_section}>
|
<div className={styles.buy_option__button_section}>
|
||||||
<TButton
|
<TButton
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { useSelector } from 'react-redux';
|
import { useSelector } from 'react-redux';
|
||||||
|
|
||||||
import usePriceInfo from '../../../hooks/usePriceInfo';
|
import usePriceInfo from '../../../hooks/usePriceInfo';
|
||||||
import { $L } from '../../../utils/helperMethods';
|
import { $L } from '../../../utils/helperMethods';
|
||||||
|
|
||||||
import styles from './BuyOptionPriceBlock.module.less';
|
import styles from './BuyOptionPriceBlock.module.less';
|
||||||
|
|
||||||
const BuyOptionPriceBlock = ({ patncNm, productInfo, selectedOptions, className }) => {
|
const BuyOptionPriceBlock = ({ patncNm, productInfo, selectedOptions, quantity, className }) => {
|
||||||
const productData = useSelector((state) => state.main.productData);
|
const productData = useSelector((state) => state.main.productData);
|
||||||
const sourceProduct = productInfo || productData;
|
const sourceProduct = productInfo || productData;
|
||||||
const { shippingCharge } = sourceProduct || {};
|
const { shippingCharge } = sourceProduct || {};
|
||||||
@@ -23,6 +23,26 @@ const BuyOptionPriceBlock = ({ patncNm, productInfo, selectedOptions, className
|
|||||||
return $L('Price');
|
return $L('Price');
|
||||||
}, [patncNm]);
|
}, [patncNm]);
|
||||||
|
|
||||||
|
// 가격에서 통화 기호와 숫자 분리
|
||||||
|
const extractPriceInfo = (priceString) => {
|
||||||
|
if (!priceString) return { currencySymbol: '', numericPrice: 0 };
|
||||||
|
|
||||||
|
const numericPrice = parseFloat(priceString.replace(/[^0-9.]/g, ''));
|
||||||
|
const currencySymbol = priceString.replace(/[0-9.]/g, '').trim();
|
||||||
|
|
||||||
|
return {
|
||||||
|
currencySymbol: currencySymbol || '',
|
||||||
|
numericPrice: isNaN(numericPrice) ? 0 : numericPrice
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// quantity를 곱한 총 가격 계산
|
||||||
|
const totalPrice = useMemo(() => {
|
||||||
|
const { currencySymbol, numericPrice } = extractPriceInfo(discountedPrice);
|
||||||
|
const total = numericPrice * (quantity || 1);
|
||||||
|
return `${currencySymbol}${total.toFixed(2)}`;
|
||||||
|
}, [discountedPrice, quantity]);
|
||||||
|
|
||||||
const showDiscountBadge = discountedPrice && originalPrice && discountedPrice !== originalPrice;
|
const showDiscountBadge = discountedPrice && originalPrice && discountedPrice !== originalPrice;
|
||||||
|
|
||||||
if (!discountedPrice && !shippingCharge) {
|
if (!discountedPrice && !shippingCharge) {
|
||||||
@@ -35,7 +55,7 @@ const BuyOptionPriceBlock = ({ patncNm, productInfo, selectedOptions, className
|
|||||||
<div className={styles.price_row}>
|
<div className={styles.price_row}>
|
||||||
<span className={styles.price_label}>{priceLabel}</span>
|
<span className={styles.price_label}>{priceLabel}</span>
|
||||||
<div className={styles.price_value_group}>
|
<div className={styles.price_value_group}>
|
||||||
<span className={styles.price_value}>{discountedPrice}</span>
|
<span className={styles.price_value}>{totalPrice}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user