feat(pricing): update storefront base pricing and checkout 18% GST display
This commit is contained in:
parent
45bb9213ce
commit
f27d3cdac7
6 changed files with 31 additions and 10 deletions
|
|
@ -48,18 +48,20 @@ export default function CartPage() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const subtotal = getCartTotal();
|
const subtotal = getCartTotal();
|
||||||
|
const tax = Math.round((subtotal * (18 / 82)) * 100) / 100;
|
||||||
|
const grossSubtotal = subtotal + tax;
|
||||||
const isFreeDelivery = Boolean(
|
const isFreeDelivery = Boolean(
|
||||||
deliverySettings?.free_delivery_enabled &&
|
deliverySettings?.free_delivery_enabled &&
|
||||||
deliverySettings?.free_delivery_min_order_amount &&
|
deliverySettings?.free_delivery_min_order_amount &&
|
||||||
subtotal >= deliverySettings.free_delivery_min_order_amount
|
grossSubtotal >= deliverySettings.free_delivery_min_order_amount
|
||||||
);
|
);
|
||||||
const baseDeliveryFee = deliverySettings ? deliverySettings.delivery_charge : 99.0;
|
const baseDeliveryFee = deliverySettings ? deliverySettings.delivery_charge : 99.0;
|
||||||
const shipping = subtotal > 0 ? (isFreeDelivery ? 0 : baseDeliveryFee) : 0;
|
const shipping = subtotal > 0 ? (isFreeDelivery ? 0 : baseDeliveryFee) : 0;
|
||||||
const total = subtotal + shipping;
|
const total = subtotal + tax + shipping;
|
||||||
|
|
||||||
const freeThreshold = deliverySettings?.free_delivery_min_order_amount || 999;
|
const freeThreshold = deliverySettings?.free_delivery_min_order_amount || 999;
|
||||||
const progressPercent = Math.min(100, (subtotal / freeThreshold) * 100);
|
const progressPercent = Math.min(100, (grossSubtotal / freeThreshold) * 100);
|
||||||
const amountNeeded = Math.max(0, freeThreshold - subtotal);
|
const amountNeeded = Math.max(0, freeThreshold - grossSubtotal);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-screen bg-[#F8F9FB] flex flex-col">
|
<div className="w-full min-h-screen bg-[#F8F9FB] flex flex-col">
|
||||||
|
|
@ -243,11 +245,17 @@ export default function CartPage() {
|
||||||
|
|
||||||
<div className="space-y-2.5 text-gray-500">
|
<div className="space-y-2.5 text-gray-500">
|
||||||
<div className="flex justify-between">
|
<div className="flex justify-between">
|
||||||
<span>Subtotal</span>
|
<span>Taxable Subtotal</span>
|
||||||
<span className="font-semibold text-[#1a1a1a]">
|
<span className="font-semibold text-[#1a1a1a]">
|
||||||
{formatCurrency(subtotal)}
|
{formatCurrency(subtotal)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="flex justify-between text-[13px]">
|
||||||
|
<span>GST (18%)</span>
|
||||||
|
<span className="font-semibold text-[#1a1a1a]">
|
||||||
|
{formatCurrency(tax)}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div className="flex justify-between items-center">
|
<div className="flex justify-between items-center">
|
||||||
<span>Shipping</span>
|
<span>Shipping</span>
|
||||||
<span>
|
<span>
|
||||||
|
|
|
||||||
|
|
@ -137,9 +137,9 @@ export default function CheckoutPage() {
|
||||||
couponDiscount = Math.min(subtotal, Math.max(0, couponDiscount));
|
couponDiscount = Math.min(subtotal, Math.max(0, couponDiscount));
|
||||||
|
|
||||||
const postDiscountSubtotal = Math.max(0, subtotal - couponDiscount);
|
const postDiscountSubtotal = Math.max(0, subtotal - couponDiscount);
|
||||||
const taxable_amount = postDiscountSubtotal / 1.18;
|
// Pre-tax base pricing: subtotal is pre-tax base (e.g. 820), 18% GST is added (e.g. 180) to equal catalog MRP (1000)
|
||||||
const tax = Math.round((postDiscountSubtotal - taxable_amount) * 100) / 100;
|
const tax = Math.round((postDiscountSubtotal * (18 / 82)) * 100) / 100;
|
||||||
const grossTotal = Math.round(postDiscountSubtotal + shipping);
|
const grossTotal = Math.round(postDiscountSubtotal + tax + shipping);
|
||||||
|
|
||||||
// Store credits deduction calculation
|
// Store credits deduction calculation
|
||||||
const availableCredits = wallet?.active_balance || 0;
|
const availableCredits = wallet?.active_balance || 0;
|
||||||
|
|
@ -1178,13 +1178,13 @@ export default function CheckoutPage() {
|
||||||
|
|
||||||
<div className="space-y-2 text-[#1a1a1a] border-t border-gray-100 pt-3">
|
<div className="space-y-2 text-[#1a1a1a] border-t border-gray-100 pt-3">
|
||||||
<div className="flex justify-between text-gray-500">
|
<div className="flex justify-between text-gray-500">
|
||||||
<span>Item Total</span>
|
<span>Taxable Subtotal</span>
|
||||||
<span className="font-semibold text-[#1a1a1a]">
|
<span className="font-semibold text-[#1a1a1a]">
|
||||||
{formatCurrency(subtotal)}
|
{formatCurrency(subtotal)}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex justify-between text-gray-500 text-[13px]">
|
<div className="flex justify-between text-gray-500 text-[13px]">
|
||||||
<span>Includes GST (18%)</span>
|
<span>GST (18%)</span>
|
||||||
<span className="font-semibold text-[#1a1a1a]">
|
<span className="font-semibold text-[#1a1a1a]">
|
||||||
{formatCurrency(tax)}
|
{formatCurrency(tax)}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,9 @@ export const ProductCard: React.FC<ProductCardProps> = ({
|
||||||
<span className="text-[14px] font-bold text-[#111]">
|
<span className="text-[14px] font-bold text-[#111]">
|
||||||
{formatCurrency(product.price)}
|
{formatCurrency(product.price)}
|
||||||
</span>
|
</span>
|
||||||
|
<span className="text-[10px] text-gray-500 font-medium">
|
||||||
|
+18% GST
|
||||||
|
</span>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -621,6 +621,9 @@ export const ProductInteractiveGrid: React.FC<ProductInteractiveGridProps> = ({
|
||||||
{formatCurrency(selectedCompare)}
|
{formatCurrency(selectedCompare)}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
<span className="text-xs text-muted-foreground font-medium bg-gray-100 px-2 py-0.5 rounded text-gray-600">
|
||||||
|
+18% GST at checkout {selectedVariant?.mrp ? `(MRP: ${formatCurrency(selectedVariant.mrp)})` : ''}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Store Credit Cashback Incentive Badge */}
|
{/* Store Credit Cashback Incentive Badge */}
|
||||||
|
|
|
||||||
|
|
@ -152,6 +152,9 @@ export function ProductCard({ product }: ProductCardProps) {
|
||||||
<span className="text-sm font-extrabold text-[#e4382f]">
|
<span className="text-sm font-extrabold text-[#e4382f]">
|
||||||
{formatCurrency(price)}
|
{formatCurrency(price)}
|
||||||
</span>
|
</span>
|
||||||
|
<span className="text-[10px] text-gray-400 font-medium">
|
||||||
|
+18% GST
|
||||||
|
</span>
|
||||||
{comparePrice && (
|
{comparePrice && (
|
||||||
<span className="text-xs text-gray-400 line-through">
|
<span className="text-xs text-gray-400 line-through">
|
||||||
{formatCurrency(comparePrice)}
|
{formatCurrency(comparePrice)}
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ export interface ProductVariantResponse {
|
||||||
/** API may return decimal strings like "199.00" */
|
/** API may return decimal strings like "199.00" */
|
||||||
price: number | string;
|
price: number | string;
|
||||||
compare_price: number | string | null;
|
compare_price: number | string | null;
|
||||||
|
mrp?: number | string | null;
|
||||||
cost_price: number | string;
|
cost_price: number | string;
|
||||||
low_stock_threshold: number;
|
low_stock_threshold: number;
|
||||||
status: string;
|
status: string;
|
||||||
|
|
@ -117,6 +118,9 @@ export interface ProductResponse {
|
||||||
description: string | null;
|
description: string | null;
|
||||||
status: string;
|
status: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
|
price?: number | string;
|
||||||
|
compare_price?: number | string | null;
|
||||||
|
mrp?: number | string | null;
|
||||||
thumbnail_url?: string | null;
|
thumbnail_url?: string | null;
|
||||||
images: ProductImageResponse[];
|
images: ProductImageResponse[];
|
||||||
variants: ProductVariantResponse[];
|
variants: ProductVariantResponse[];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue