@gem-sdk/components 2.1.36 → 2.1.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -18,9 +18,17 @@ const ProductTag = ({ setting, styles, builderProps, ...passProps })=>{
|
|
|
18
18
|
const mode = core.useEditorMode();
|
|
19
19
|
const product = core.useProduct();
|
|
20
20
|
const currentVariant = core.useCurrentVariant();
|
|
21
|
+
const { quantity, hasUpdatePrice } = core.useQuantity();
|
|
22
|
+
const quantityProduct = React.useMemo(()=>{
|
|
23
|
+
return hasUpdatePrice && customContent?.unit !== 'percentage' ? quantity || 1 : 1;
|
|
24
|
+
}, [
|
|
25
|
+
hasUpdatePrice,
|
|
26
|
+
customContent?.unit,
|
|
27
|
+
quantity
|
|
28
|
+
]);
|
|
21
29
|
const price = currentVariant?.price ?? 0;
|
|
22
30
|
const salePrice = currentVariant?.salePrice ?? 0;
|
|
23
|
-
const priceSave = salePrice - price;
|
|
31
|
+
const priceSave = (salePrice - price) * quantityProduct;
|
|
24
32
|
const moneyFormatted = core.useFormatMoney(priceSave < 0 ? 0 : priceSave, setting?.moneyWithCurrentFormat || false);
|
|
25
33
|
const customDisplayWithUnit = React.useMemo(()=>{
|
|
26
34
|
if (!salePrice && salePrice !== 0 || !price && price !== 0) return `${customContent?.unit === 'percentage' ? '0%' : moneyFormatted}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useMoneyFormat, makeGlobalSize, useEditorMode, useProduct, useCurrentVariant, useFormatMoney, useProductBundleDiscount, formatMoney, getGlobalColorClass, cls, makeStyleResponsive, makeStyle, getRadiusCSSFromGlobal, getCustomRadius } from '@gem-sdk/core';
|
|
2
|
+
import { useMoneyFormat, makeGlobalSize, useEditorMode, useProduct, useCurrentVariant, useQuantity, useFormatMoney, useProductBundleDiscount, formatMoney, getGlobalColorClass, cls, makeStyleResponsive, makeStyle, getRadiusCSSFromGlobal, getCustomRadius } from '@gem-sdk/core';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import Text from '../../text/components/Text.js';
|
|
5
5
|
import { DiscountType } from './constants/product-bundle.js';
|
|
@@ -14,9 +14,17 @@ const ProductTag = ({ setting, styles, builderProps, ...passProps })=>{
|
|
|
14
14
|
const mode = useEditorMode();
|
|
15
15
|
const product = useProduct();
|
|
16
16
|
const currentVariant = useCurrentVariant();
|
|
17
|
+
const { quantity, hasUpdatePrice } = useQuantity();
|
|
18
|
+
const quantityProduct = useMemo(()=>{
|
|
19
|
+
return hasUpdatePrice && customContent?.unit !== 'percentage' ? quantity || 1 : 1;
|
|
20
|
+
}, [
|
|
21
|
+
hasUpdatePrice,
|
|
22
|
+
customContent?.unit,
|
|
23
|
+
quantity
|
|
24
|
+
]);
|
|
17
25
|
const price = currentVariant?.price ?? 0;
|
|
18
26
|
const salePrice = currentVariant?.salePrice ?? 0;
|
|
19
|
-
const priceSave = salePrice - price;
|
|
27
|
+
const priceSave = (salePrice - price) * quantityProduct;
|
|
20
28
|
const moneyFormatted = useFormatMoney(priceSave < 0 ? 0 : priceSave, setting?.moneyWithCurrentFormat || false);
|
|
21
29
|
const customDisplayWithUnit = useMemo(()=>{
|
|
22
30
|
if (!salePrice && salePrice !== 0 || !price && price !== 0) return `${customContent?.unit === 'percentage' ? '0%' : moneyFormatted}`;
|