create-brainerce-store 1.27.5 → 1.27.6
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.
- package/dist/index.js +3 -12
- package/messages/en.json +382 -378
- package/messages/he.json +382 -378
- package/package.json +46 -46
- package/templates/nextjs/base/next.config.ts +31 -31
- package/templates/nextjs/base/src/app/checkout/page.tsx +973 -972
- package/templates/nextjs/base/src/app/order-confirmation/page.tsx +271 -271
- package/templates/nextjs/base/src/app/payment-complete/page.tsx +59 -59
- package/templates/nextjs/base/src/app/products/[slug]/product-client-section.tsx +27 -12
- package/templates/nextjs/base/src/app/products/page.tsx +475 -475
- package/templates/nextjs/base/src/components/checkout/custom-fields-step.tsx +258 -184
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +592 -592
- package/templates/nextjs/base/src/lib/navigation.tsx.ejs +60 -60
- package/templates/nextjs/themes/luxury/globals.css +399 -399
- package/templates/nextjs/themes/luxury/theme.json +23 -23
- package/templates/nextjs/themes/playful/globals.css +400 -400
- package/templates/nextjs/themes/playful/theme.json +23 -23
|
@@ -157,20 +157,35 @@ export function ProductClientSection({ product: initialProduct }: ProductClientS
|
|
|
157
157
|
// Price info - use variant price if selected, else product price
|
|
158
158
|
const priceInfo = useMemo(() => {
|
|
159
159
|
if (selectedVariant?.price) {
|
|
160
|
+
const variantBase = parseFloat(selectedVariant.price);
|
|
161
|
+
const variantSale = selectedVariant.salePrice ? parseFloat(selectedVariant.salePrice) : null;
|
|
162
|
+
const variantEffective =
|
|
163
|
+
variantSale != null && variantSale < variantBase ? variantSale : variantBase;
|
|
164
|
+
|
|
165
|
+
// Overlay any product-level discount rule onto the variant price using the rule's ratio
|
|
166
|
+
if (product.discount) {
|
|
167
|
+
const ruleOriginal = parseFloat(product.discount.originalPrice) || 0;
|
|
168
|
+
const ruleDiscounted = parseFloat(product.discount.discountedPrice) || 0;
|
|
169
|
+
const ratio = ruleOriginal > 0 ? ruleDiscounted / ruleOriginal : 1;
|
|
170
|
+
const discounted = variantEffective * ratio;
|
|
171
|
+
const amount = Math.max(0, variantEffective - discounted);
|
|
172
|
+
return {
|
|
173
|
+
price: discounted,
|
|
174
|
+
originalPrice: variantEffective,
|
|
175
|
+
isOnSale: discounted < variantEffective,
|
|
176
|
+
discountAmount: amount,
|
|
177
|
+
discountPercent:
|
|
178
|
+
variantEffective > 0 ? Math.round((amount / variantEffective) * 100) : 0,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
160
182
|
return {
|
|
161
|
-
price:
|
|
162
|
-
originalPrice:
|
|
163
|
-
isOnSale:
|
|
164
|
-
selectedVariant.salePrice != null &&
|
|
165
|
-
parseFloat(selectedVariant.salePrice) < parseFloat(selectedVariant.price),
|
|
183
|
+
price: variantEffective,
|
|
184
|
+
originalPrice: variantBase,
|
|
185
|
+
isOnSale: variantEffective < variantBase,
|
|
166
186
|
discountPercent:
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
? Math.round(
|
|
170
|
-
((parseFloat(selectedVariant.price) - parseFloat(selectedVariant.salePrice)) /
|
|
171
|
-
parseFloat(selectedVariant.price)) *
|
|
172
|
-
100
|
|
173
|
-
)
|
|
187
|
+
variantEffective < variantBase && variantBase > 0
|
|
188
|
+
? Math.round(((variantBase - variantEffective) / variantBase) * 100)
|
|
174
189
|
: 0,
|
|
175
190
|
};
|
|
176
191
|
}
|