How to fix duplicate WooCommerce add-to-cart requests after a JavaScript regression

Custom WooCommerce product flows can break in several ways at once when theme updates, missing assets, and duplicate JavaScript handlers overlap. In one support case, users reported slow logins, unresponsive product controls, broken page alignment, and cart quantities doubling at checkout.

Freshy traced the issues to a missing custom fs-add-to-cart.js file, overlapping add-to-cart logic between that file and an existing custom.js handler, a loading-overlay script that was running in the wrong order, and an Impreza layout change that continued reserving sidebar width even when the sidebar was disabled. Freshy restored the missing script, then simplified the add-to-cart flow back to one canonical handler so a single click could no longer trigger duplicate requests.

Issue background

A WordPress ecommerce site with a custom Acumatica-connected product experience began showing several problems at the same time:

  • Customer login could take roughly 30–45 seconds.
  • Some product-page buttons appeared unresponsive.
  • Product layouts were visibly misaligned.
  • Items added to the cart could appear doubled at checkout.

The site had also received multiple plugin and theme updates shortly before the reports, including updates to WP Rocket, UpSolution Core, Slider Revolution, WPBakery Page Builder, Advanced Custom Fields, Code Snippets, Contact Form 7, Envato Market, and the active theme stack.

That made a recent regression plausible, but the final resolution required tracing the custom frontend code rather than assuming one plugin update was solely responsible.

Diagnosis

Freshy first reviewed browser console errors and the custom product-page scripts.

One obvious problem was a missing child-theme asset:

/wp-content/themes/Impreza-child/js/fs-add-to-cart.js

The file had originally been created to support the customized product controls, including add-to-cart behavior and quantity controls. It was missing even from the oldest available backup, so Freshy recreated and restored it.

After the console errors were reduced, login performance improved substantially, with testing showing the login flow completing in roughly four seconds at worst.

However, a new symptom appeared: customers reported that adding a quantity of 2 could result in 4 items at checkout.

Freshy then found the more important cart issue. Two separate JavaScript paths were handling the same add-to-cart action:

  • The existing custom.js implementation.
  • The restored fs-add-to-cart.js implementation.

Both could initiate add-to-cart behavior, which meant one customer action could result in two requests.

The duplicate logic had been partially hidden because the original custom.js flow expected a loading overlay, but the overlay script was loading in the wrong order. That caused the original handler to fail quietly in some cases while the newer handler continued working.

The site also had a separate layout regression. In Impreza, the page setting Sidebar: Do not display hid the visible sidebar but still reserved its width in the layout. As a result, content appeared left-aligned with empty space on the right.

Resolution steps

The documented fix was:

  1. Review the console and recent frontend changes. Freshy used browser errors to narrow the investigation toward missing or misordered custom JavaScript.
  2. Restore the missing fs-add-to-cart.js asset. The original custom file was recreated and uploaded to the Impreza child theme.
  3. Retest the login and product experience. With the console errors corrected, login responsiveness improved significantly and the broken product controls began working again.
  4. Investigate the doubled-cart reports separately. Freshy compared the restored add-to-cart script with the older product-page handler.
  5. Identify the duplicate AJAX paths. Both fs-add-to-cart.js and custom.js could process the same add-to-cart interaction.
  6. Choose one canonical add-to-cart handler. Freshy removed the duplicate AJAX behavior from fs-add-to-cart.js and kept the original custom.js flow as the source of truth.
  7. Fix the loading-overlay script order. The original add-to-cart UX depended on a loading overlay, but the relevant script had been loading incorrectly. Freshy corrected the order so the overlay worked as intended.
  8. Restore the intended user experience. The final flow used the original loading overlay, page reload, and success banner instead of two competing inline AJAX systems.
  9. Fix the Impreza no-sidebar layout. Custom CSS was added through the Customizer so pages configured without a sidebar used the full intended content width and remained centered.
  10. Keep the newer no-reload UX as a future option. Freshy estimated roughly 2–3 hours to make the newer inline AJAX experience the canonical implementation and clean up its visual state, but the client chose not to pursue that change at the time.

Final outcome

The immediate customer-facing issues were resolved without forcing a larger checkout rewrite.

Freshy restored the missing custom product script, removed the duplicate add-to-cart request path, fixed the loading-overlay dependency, and corrected the no-sidebar layout regression.

The resulting add-to-cart workflow returned to the more conservative original behavior: one canonical request, a loading overlay, a page reload, and a success message. That avoided the doubled quantities and the conflicting “in cart” indicators that appeared when both JavaScript systems were active.

The client elected to keep that reliable implementation rather than move immediately to the newer no-reload AJAX experience. The optional modernization work was estimated separately and left on hold.

The broader lesson is that duplicate WooCommerce cart quantities are not always caused by server-side cart logic. When a site has accumulated multiple custom frontend handlers, a single click may trigger the same action twice. Restoring missing assets is only the first step; the full event flow must be reviewed so there is one clear source of truth for each customer action.

If your WooCommerce site has duplicate cart quantities, broken custom product controls, or regressions after theme and plugin updates, contact Freshy. Our WordPress team can trace the frontend event flow, separate duplicated handlers, and restore the intended ecommerce behavior without unnecessary rewrites.