fix: set language code before add to cart
Some checks failed
Build and Deploy / build (push) Has been cancelled

Ensure language code is set in checkout store before creating checkout.
This ensures orders created from any page will have correct language.

- Add setLanguageCode to NewHero before addLine
- Add setLanguageCode to ProductDetail before addLine
- Uses current locale from useLocale or props
This commit is contained in:
Unchained
2026-03-28 12:53:14 +02:00
parent 5ec0e6c92c
commit ca363a2406
2 changed files with 11 additions and 2 deletions

View File

@@ -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);