4 Commits

Author SHA1 Message Date
Unchained
ca363a2406 fix: set language code before add to cart
Some checks are pending
Build and Deploy / build (push) Waiting to run
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
2026-03-28 12:53:14 +02:00
Unchained
5ec0e6c92c feat: set checkout languageCode based on user locale
Some checks failed
Build and Deploy / build (push) Has been cancelled
- Add languageCode to checkout store state
- Add setLanguageCode action to store
- Pass languageCode when creating checkout
- Header component sets language code from useLocale hook
- Enables multi-language order confirmation emails
2026-03-28 12:31:34 +02:00
Unchained
ee574cb736 Merge dev into master
Some checks failed
Build and Deploy / build (push) Has been cancelled
Includes:
- feat: store userLanguage in checkout metadata for multi-language emails
- refactor: Remove email functionality - migrated to core-extensions app
- docs: Add comprehensive feature roadmap with 20 optimization features
2026-03-28 09:59:17 +02:00
Unchained
f66f9b87ab docs: Add comprehensive feature roadmap with 20 optimization features
- Organized into 7 implementation phases with dependencies
- Includes priority matrix (P0/P1/P2)
- Revenue and SEO impact ratings
- Success metrics for tracking
- Resource requirements and timeline estimates
- Dependency graph showing implementation order
2026-03-25 21:54:38 +02:00
4 changed files with 35 additions and 13 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);

View File

@@ -5,7 +5,7 @@ import Link from "next/link";
import Image from "next/image";
import { usePathname } from "next/navigation";
import { AnimatePresence, motion } from "framer-motion";
import { useTranslations } from "next-intl";
import { useTranslations, useLocale } from "next-intl";
import { useSaleorCheckoutStore } from "@/stores/saleorCheckoutStore";
import { User, ShoppingBag, Menu, X, Globe } from "lucide-react";
import CartDrawer from "@/components/cart/CartDrawer";
@@ -16,14 +16,15 @@ interface HeaderProps {
locale?: string;
}
export default function Header({ locale = "sr" }: HeaderProps) {
export default function Header({ locale: propLocale = "sr" }: HeaderProps) {
const t = useTranslations("Header");
const pathname = usePathname();
const dropdownRef = useRef<HTMLDivElement>(null);
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
const [scrolled, setScrolled] = useState(false);
const [langDropdownOpen, setLangDropdownOpen] = useState(false);
const { getLineCount, toggleCart, initCheckout } = useSaleorCheckoutStore();
const { getLineCount, toggleCart, initCheckout, setLanguageCode } = useSaleorCheckoutStore();
const locale = useLocale();
const itemCount = getLineCount();
const currentLocale = isValidLocale(locale) ? LOCALE_CONFIG[locale] : LOCALE_CONFIG.sr;
@@ -58,6 +59,13 @@ export default function Header({ locale = "sr" }: HeaderProps) {
initCheckout();
}, [initCheckout]);
// Set language code for checkout based on current locale
useEffect(() => {
if (locale) {
setLanguageCode(locale);
}
}, [locale, setLanguageCode]);
useEffect(() => {
const handleScroll = () => {
setScrolled(window.scrollY > 50);

View File

@@ -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<string | null>(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);

View File

@@ -58,6 +58,7 @@ interface GetCheckoutResponse {
interface SaleorCheckoutStore {
checkout: Checkout | null;
checkoutToken: string | null;
languageCode: string | null;
isOpen: boolean;
isLoading: boolean;
error: string | null;
@@ -68,6 +69,7 @@ interface SaleorCheckoutStore {
updateLine: (lineId: string, quantity: number) => Promise<void>;
removeLine: (lineId: string) => Promise<void>;
setEmail: (email: string) => Promise<void>;
setLanguageCode: (languageCode: string) => void;
refreshCheckout: () => Promise<void>;
toggleCart: () => void;
openCart: () => void;
@@ -85,12 +87,13 @@ export const useSaleorCheckoutStore = create<SaleorCheckoutStore>()(
(set, get) => ({
checkout: null,
checkoutToken: null,
languageCode: null,
isOpen: false,
isLoading: false,
error: null,
initCheckout: async () => {
const { checkoutToken } = get();
const { checkoutToken, languageCode } = get();
if (checkoutToken) {
// Try to fetch existing checkout
@@ -109,7 +112,7 @@ export const useSaleorCheckoutStore = create<SaleorCheckoutStore>()(
}
}
// Create new checkout
// Create new checkout with language code
try {
const { data } = await saleorClient.mutate<CheckoutCreateResponse>({
mutation: CHECKOUT_CREATE,
@@ -117,6 +120,7 @@ export const useSaleorCheckoutStore = create<SaleorCheckoutStore>()(
input: {
channel: CHANNEL,
lines: [],
languageCode: languageCode ? languageCode.toUpperCase() : undefined,
},
},
});
@@ -294,6 +298,7 @@ export const useSaleorCheckoutStore = create<SaleorCheckoutStore>()(
openCart: () => set({ isOpen: true }),
closeCart: () => set({ isOpen: false }),
clearError: () => set({ error: null }),
setLanguageCode: (languageCode: string) => set({ languageCode }),
getLineCount: () => {
const { checkout } = get();