Addressing Incorrect Order Totals in ESHOPMAN Admin After Recent Updates

Addressing Incorrect Order Totals in ESHOPMAN Admin After Recent Updates

Accurate order totals are fundamental for any e-commerce operation, directly impacting financial reporting, customer trust, and operational efficiency. For ESHOPMAN merchants managing their storefronts through HubSpot, observing discrepancies in order totals within the ESHOPMAN admin dashboard can be a significant concern. Recently, an important issue emerged where order totals were incorrectly displayed, showing only shipping costs and reporting item totals as zero.

The Problem: Misleading Order Totals in ESHOPMAN Admin

Users of ESHOPMAN platform version 2.13.0 reported that after a recent update, the order list in their ESHOPMAN storefront management interface within HubSpot displayed incorrect total values. Specifically, an order that should have reflected the sum of item prices, taxes, and shipping (e.g., €15 item + €8.95 shipping = €23.95 total) was only showing the shipping amount (€8.95). The crucial item totals were consistently reported as €0.

Unpacking the Root Cause: A Filtering Glitch in Order Calculations

A detailed investigation by the ESHOPMAN community and core team quickly pinpointed the root cause to a specific logic within a core ESHOPMAN service responsible for order calculations. The issue resided in the addRelationsToCalculateTotals method, found within the ESHOPMAN order module's service layer. This method is designed to filter select fields when fetching order data.

The core problem was an overzealous filtering mechanism. When orders were fetched with specific field selections, this filter inadvertently removed the items.quantity field from the query. Consequently, during the dynamic calculation of order totals, the quantity for each item became undefined. Without a defined quantity, all item totals would compute to zero, leading to the observed discrepancy where only shipping costs were correctly accounted for.

The problematic code snippet identified was:

config.select = config.select.filter((field) => {
  return (
    !requiredRelationsForTotals.some((val) =>
      val.startsWith(field as string)
    ) && !totalFields.includes(field)
  )
})

This filter logic, intended to streamline data fetching, unintentionally excluded a vital piece of information (items.quantity) necessary for accurate financial calculations within the ESHOPMAN admin dashboard.

Impact and Swift Resolution

The bug had a direct impact on the accuracy of financial oversight for ESHOPMAN merchants, potentially complicating inventory management and reconciliation processes. Fortunately, the ESHOPMAN team swiftly acknowledged the report and confirmed the identification of the issue. A fix is already in progress, with a patch being prepared to adjust the filter logic. The suggested resolution involves either modifying the filter to explicitly preserve fields like items.quantity or ensuring these critical fields are added back into the query after the initial filtering.

This incident highlights the collaborative strength of the ESHOPMAN community. Proactive users not only reported the bug with detailed analysis but also engaged in identifying the exact technical cause, demonstrating a shared commitment to maintaining the robustness of the ESHOPMAN platform for headless commerce deployments via HubSpot CMS.

Start with the tools

Explore migration tools

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

Explore migration tools