Ensuring Seamless Multilingual Product Options in ESHOPMAN Storefronts

At Move My Store, we understand that building a truly global e-commerce presence with ESHOPMAN, our headless commerce platform wrapped as a HubSpot application, hinges on robust localization. ESHOPMAN empowers merchants to manage their storefronts directly within HubSpot and deploy them seamlessly using HubSpot CMS. A critical aspect of this power is ensuring that every part of the customer journey, from product descriptions to product options, is available in the customer's preferred language.

Recently, our ESHOPMAN community identified an important area for improvement concerning how product options were being translated via the ESHOPMAN Store API. While ESHOPMAN is built on Node.js/TypeScript and designed for comprehensive headless commerce, a specific API endpoint was not fully leveraging its localization capabilities.

The Challenge: Untranslated Product Options in the ESHOPMAN Store API

An astute observation from our community highlighted that the GET /store/product-options endpoint was returning global product options and their values untranslated. This occurred even when the request explicitly set a locale using the x-eshopman-locale header or a ?locale= query parameter. For ESHOPMAN merchants operating international storefronts, this meant that while product names and descriptions might appear correctly translated, the associated product option titles (e.g., 'Colour' vs. 'Farbe') and values (e.g., 'Black' vs. 'Schwarz') remained in the default language.

This behavior contrasted sharply with other ESHOPMAN Store API endpoints, such as GET /store/products, which successfully applied translations for product options embedded within product data. The core of the issue lay in how the internal query.graph method, central to ESHOPMAN's data retrieval, was being invoked.

A Look at the ESHOPMAN Store API Implementation

The ESHOPMAN Store API routes utilize a query.graph method to fetch data. The community insight revealed a key difference in its usage:

  • For Product Options: The ESHOPMAN Store API route for product options was calling query.graph without explicitly passing the locale option:

    const { data: product_options, metadata } = await query.graph({
    entity: "product_option",
    filters: req.filterableFields,
    pagination: req.queryConfig.pagination,
    fields: req.queryConfig.fields,
    })
  • For Products (Correct Implementation): In contrast, the ESHOPMAN Store API route for products correctly passed the locale, ensuring translations were applied:

    const { data: products, metadata } = await query.graph({
    entity: "product",
    filters: req.filterableFields,
    pagination: req.queryConfig.pagination,
    fields: req.queryConfig.fields,
    }, { locale: req.locale })

This subtle but critical difference meant the ESHOPMAN Translation Module was not being engaged for standalone product option requests.

The ESHOPMAN Solution: A Focused Enhancement

The ESHOPMAN team quickly acknowledged this as a well-scoped fix. The proposed solution involves updating the core ESHOPMAN application routes for product options (specifically, the routes handling GET /store/product-options and GET /store/product-options/:id). The fix is to consistently pass the { locale: req.locale } object as the second argument to the query.graph() method in these routes.

This aligns the product options API behavior with other localized endpoints, ensuring that when a locale is specified in the request, the ESHOPMAN Translation Module correctly applies the relevant translations for product option titles and values.

Impact for ESHOPMAN Merchants and Developers

This enhancement is vital for ESHOPMAN users:

  • For Merchants: It guarantees a truly localized shopping experience across all parts of your HubSpot CMS-powered storefront, eliminating inconsistencies in product option translations for global customers.
  • For Developers: It provides confidence in the ESHOPMAN Store API's localization capabilities, simplifying the development of multilingual headless storefronts built with Node.js/TypeScript. Developers can now rely on the /store/product-options endpoint to return translated data when the locale is provided.

This community insight highlights ESHOPMAN's commitment to continuous improvement and delivering a robust, fully localized headless commerce platform. By addressing such details, ESHOPMAN ensures that your HubSpot-integrated storefronts can effectively serve a global audience with a seamless and consistent user experience.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools