diff --git a/src/components/home/NewHero.tsx b/src/components/home/NewHero.tsx index 2e57e89..948a9e9 100644 --- a/src/components/home/NewHero.tsx +++ b/src/components/home/NewHero.tsx @@ -15,9 +15,13 @@ interface NewHeroProps { export default function NewHero({ featuredProduct }: NewHeroProps) { const locale = useLocale(); - const { addLine, openCart } = useSaleorCheckoutStore(); + const { addLine, openCart, setLanguageCode } = useSaleorCheckoutStore(); const handleAddToCart = async () => { + // Set language code before adding to cart + if (locale) { + setLanguageCode(locale); + } const variant = featuredProduct?.variants?.[0]; if (variant?.id) { await addLine(variant.id, 1); diff --git a/src/components/product/ProductDetail.tsx b/src/components/product/ProductDetail.tsx index 2d88b2c..7a56bba 100644 --- a/src/components/product/ProductDetail.tsx +++ b/src/components/product/ProductDetail.tsx @@ -99,7 +99,7 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts const [isAdding, setIsAdding] = useState(false); const [urgencyIndex, setUrgencyIndex] = useState(0); const [selectedBundleVariantId, setSelectedBundleVariantId] = useState(null); - const { addLine, openCart } = useSaleorCheckoutStore(); + const { addLine, openCart, setLanguageCode } = useSaleorCheckoutStore(); const { trackProductView, trackAddToCart } = useAnalytics(); const validLocale = isValidLocale(locale) ? locale : "sr"; @@ -147,6 +147,11 @@ export default function ProductDetail({ product, relatedProducts, bundleProducts const handleAddToCart = async () => { if (!selectedVariantId) return; + // Set language code before adding to cart + if (validLocale) { + setLanguageCode(validLocale); + } + setIsAdding(true); try { await addLine(selectedVariantId, 1);