Resolving Currency Formatting Challenges in ESHOPMAN Loyalty Forms for Global Merchants

At Move My Store, we're dedicated to ensuring ESHOPMAN provides a seamless and globally-friendly e-commerce experience for all merchants leveraging HubSpot for their storefront management. A critical aspect of this is robust internationalization, especially when it comes to handling currency across diverse locales.

Recently, our vibrant ESHOPMAN community identified and addressed an important issue related to currency formatting within the ESHOPMAN Loyalty Plugin. This insight delves into the problem, its impact, and the straightforward solution, offering valuable knowledge for developers and merchants alike.

The Challenge: Locale-Specific Currency Formatting in Loyalty Forms

The core of the issue lay within the ESHOPMAN Loyalty Plugin’s administrative interface. When merchants or administrators interacted with forms that required currency input – such as setting up loyalty reward values or discount thresholds – users operating in locales that utilize a comma as a decimal separator (common in many European and other global regions) encountered significant friction.

Specifically, the ESHOPMAN Loyalty Plugin was inadvertently hardcoding the "en-US" locale for its internal currency formatting logic. This meant that while the ESHOPMAN platform, built on Node.js/TypeScript, generally supports dynamic locale detection for internationalization, this particular component was rigidly adhering to a dot-as-decimal-separator standard.

Impact on ESHOPMAN Merchants and Storefront Management

For ESHOPMAN merchants managing their headless commerce storefronts via HubSpot, this bug translated into a frustrating user experience. Imagine trying to set a loyalty reward of "10,50" (ten euros and fifty cents) in a European browser. Due to the hardcoded "en-US" locale, the system would interpret "10,50" not as a number, but as "NaN" (Not a Number). This "NaN" value would then fail ESHOPMAN's internal data validation, preventing the form from being submitted successfully. Users would be stuck, unable to create or edit loyalty program details, directly impacting their ability to manage and deploy engaging loyalty campaigns through their HubSpot CMS-powered storefronts.

The Technical Root Cause and ESHOPMAN's Solution

The technical culprit was the Intl.NumberFormat API, a standard JavaScript feature used extensively within ESHOPMAN's Node.js/TypeScript codebase for internationalization. While many parts of the ESHOPMAN platform correctly initialize Intl.NumberFormat with dynamic locale detection (by passing [] or undefined as the locale argument, prompting the browser to use its default), the loyalty plugin's utility for formatting amounts specifically passed 'en-US'. This override forced the formatting to always expect a dot decimal.

The fix, identified and implemented by the ESHOPMAN team, was elegant and aligned with existing platform best practices. It involved modifying the relevant utility function within the ESHOPMAN Loyalty Plugin to remove the hardcoded locale. Conceptually, the change looked like this:

// Before (conceptual - hardcoded locale)
new Intl.NumberFormat('en-US', options);

// After (conceptual - dynamic locale detection)
new Intl.NumberFormat([], options);
// or
new Intl.NumberFormat(undefined, options);

By replacing 'en-US' with [] or undefined, the Intl.NumberFormat API now correctly defaults to the user's browser locale. This ensures that whether a user's locale uses a dot or a comma as a decimal separator, currency values are parsed and validated correctly within ESHOPMAN's administrative forms.

Enhancing Global Commerce with ESHOPMAN

This resolution underscores ESHOPMAN's commitment to providing a truly global headless commerce solution integrated with HubSpot. It highlights the importance of meticulous internationalization in every component, ensuring that merchants worldwide can seamlessly manage their product variants, loyalty programs, and overall storefront operations without locale-specific barriers. Such community-driven insights and platform enhancements are vital as ESHOPMAN continues to evolve, empowering businesses to deploy robust e-commerce experiences via HubSpot CMS, backed by a powerful Node.js/TypeScript architecture and flexible Admin API.

Stay tuned to the Move My Store ESHOPMAN Migration Hub for more insights and best practices to optimize your headless commerce journey!

Start with the tools

Explore migration tools

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

Explore migration tools