fix: shipping cost calculation and performance optimization
- Fix shipping cost not included in checkout total - Add useShippingMethodSelector hook for proper abstraction - Remove blocking initCheckout from Header for better performance - Checkout now initializes lazily when cart opens or item added
This commit is contained in:
@@ -55,14 +55,14 @@ export default function Header({ locale: propLocale = "sr" }: HeaderProps) {
|
||||
setLangDropdownOpen(false);
|
||||
};
|
||||
|
||||
// Set language code first, then initialize checkout
|
||||
// Set language code - checkout initializes lazily when cart is opened
|
||||
useEffect(() => {
|
||||
if (locale) {
|
||||
setLanguageCode(locale);
|
||||
// Initialize checkout after language code is set
|
||||
initCheckout();
|
||||
// Checkout will initialize lazily when user adds to cart or opens cart drawer
|
||||
// This prevents blocking page render with unnecessary API calls
|
||||
}
|
||||
}, [locale, setLanguageCode, initCheckout]);
|
||||
}, [locale, setLanguageCode]);
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
|
||||
Reference in New Issue
Block a user