Critical ESHOPMAN Update: Ensuring Accurate Shipping Tax Calculations for Orders

Critical ESHOPMAN Update: Ensuring Accurate Shipping Tax Calculations for Orders

Accurate tax calculation is fundamental for any e-commerce business, especially when leveraging ESHOPMAN's headless commerce platform integrated with HubSpot. A recent and important discussion within the ESHOPMAN community has highlighted a critical bug affecting order-level tax calculations, specifically regarding the shipping method name.

This insight details the technical issue, its impact on ESHOPMAN merchants and developers, and the community's proactive approach to resolution, ensuring the integrity of your store's financial operations.

The Discrepancy: Missing Shipping Method Name in Order Tax Context

The ESHOPMAN platform, built on Node.js/TypeScript, utilizes a TaxCalculationContext to supply tax providers with essential data, including shipping_methods[].name: string. While this field was correctly populated for cart-level tax calculations (a previous fix), it was found to be undefined for all order-level tax calculations. This includes new order creation, exchanges, claims, returns, and draft order shipping/items.

Impact on ESHOPMAN Stores and Integrations

While the default ESHOPMAN tax provider might not directly use the shipping method name, this bug significantly affects:

  • Third-Party Tax Integrations: External tax services, often integrated via ESHOPMAN's Admin API, rely on the shipping method name for precise rate lookups. An undefined value can lead to incorrect or failed shipping tax calculations.
  • Custom Tax Providers: ESHOPMAN developers implementing custom tax logic via the Store API or Admin API, and whose providers depend on this name, would experience erroneous tax outcomes.
  • Data Integrity: The inconsistency between cart and order tax contexts complicates debugging and development within the ESHOPMAN ecosystem.

Root Cause: A Field Omission in ESHOPMAN Core Flows

The ESHOPMAN community's investigation pinpointed the root cause to an omission within the platform's core flows. Specifically, the workflow for updating order tax lines (within the ESHOPMAN backend's core flows, conceptually similar to packages/core/core-flows/src/order/workflows/update-tax-lines.ts) failed to request "shipping_methods.name" in its data field lists (e.g., completeOrderFields, orderFields, shippingMethodFields).

In contrast, the cart-level tax path correctly includes this field. The shared context builder then attempts to read method.name, which is unavailable for order-level contexts.

The ESHOPMAN backend, leveraging Node.js/TypeScript, typically uses a package.json structure like this:

{    "name": "@dtc/backend",    "version": "0.0.1",    "dependencies": {      "@eshopman/admin-sdk": "2.15.5",      "@eshopman/cli": "2.15.5",      "@eshopman/framework": "2.15.5",      "@eshopman/eshopman": "2.15.5",      "@eshopman/ui": "4.1.15"    },    "devDependencies": {       "@eshopman/test-utils": "2.15.5"    }  }

This structure underscores the modularity where core packages manage these critical data flows.

How ESHOPMAN Developers Can Verify

To observe this behavior, ESHOPMAN developers can:

  1. Register a custom tax provider in your ESHOPMAN backend.
  2. Implement the getTaxLines method to log context.shipping_methods.
  3. Perform both a cart-level and an order-level tax calculation.

You will notice the name property populated for cart calculations, but undefined for order-level ones.

Community Resolution

The ESHOPMAN team promptly confirmed this bug. This swift validation highlights the value of active community participation. A fix is underway to ensure order-level tax calculations consistently pass shipping_methods[].name, aligning them with cart-level calculations and the defined TaxCalculationContext type.

Conclusion

This insight demonstrates the ESHOPMAN community's commitment to platform robustness. For merchants managing storefronts in HubSpot and deploying via HubSpot CMS, and for developers building custom solutions with ESHOPMAN's Admin and Store APIs, staying informed about such updates is crucial for reliable headless commerce operations. This fix will ensure more accurate tax reporting for all order-level transactions.

Start with the tools

Explore migration tools

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

Explore migration tools