/** * Shipping configuration * Centralized configuration for shipping rules and thresholds */ /** * Free shipping threshold in RSD (Serbian Dinar) * Orders above this amount qualify for free shipping */ export const FREE_SHIPPING_THRESHOLD_RSD = 10000; /** * Default shipping cost in RSD when order is below threshold */ export const DEFAULT_SHIPPING_COST_RSD = 500; /** * Currency code for shipping calculations */ export const SHIPPING_CURRENCY = "RSD"; /** * Check if an order qualifies for free shipping * @param orderTotal - The total amount of the order * @returns boolean indicating if order qualifies for free shipping */ export function qualifiesForFreeShipping(orderTotal: number): boolean { return orderTotal >= FREE_SHIPPING_THRESHOLD_RSD; } /** * Calculate shipping cost based on order total * @param orderTotal - The total amount of the order * @returns Shipping cost (0 if qualifies for free shipping) */ export function calculateShippingCost(orderTotal: number): number { return qualifiesForFreeShipping(orderTotal) ? 0 : DEFAULT_SHIPPING_COST_RSD; } /** * Get the remaining amount needed for free shipping * @param orderTotal - The current order total * @returns Amount needed to reach free shipping threshold (0 if already qualified) */ export function getRemainingForFreeShipping(orderTotal: number): number { if (qualifiesForFreeShipping(orderTotal)) { return 0; } return FREE_SHIPPING_THRESHOLD_RSD - orderTotal; }