Etheme_ajax_add_to_cart returns an HTTP 302 redirect to /checkout/ instead of a normal AJAX response

This topic has 10 replies, 3 voices, and was last updated 56 minutes ago ago by Tony Rodriguez

  • Avatar: luc
    luc
    Participant
    September 1, 2026 at 08:12

    Hi 8theme Support team,

    We’re seeing a serious performance issue on one of our WooCommerce stores that we’ve now traced to XStore Core’s own add-to-cart AJAX handler, with help from CheckoutWC’s support team who reproduced it independently. Details and evidence below — hoping you can help us pin down and fix the underlying cause.

    Site: washgiant.nl Theme: XStore XStore Core version: 5.7.7 WooCommerce version: 11.0.1 CheckoutWC version: 11.1.4 (premium checkout plugin) WordPress / PHP: latest WP, PHP 8.4

    The issue

    Every time a customer clicks “Add to cart” on a product page, the theme’s own AJAX request (action=etheme_ajax_add_to_cart, POST to admin-ajax.php) takes 5–9 seconds and returns a response of roughly 700 KB, instead of the small JSON/fragments payload we’d expect.

    We asked CheckoutWC’s support team to look into it, since the response body turned out to be the fully rendered checkout page HTML. Their engineer reproduced the issue live (as an anonymous visitor) and gave us this diagnosis:

    The etheme_ajax_add_to_cart handler responds with an HTTP 302 redirect (Location: /checkout/) instead of a normal AJAX response — as if it were handling a regular, non-AJAX form submission. Because fetch/XMLHttpRequest follow redirects transparently by default, the browser silently issues a second GET request to /checkout/ and treats that page’s full HTML as the “response” to the add-to-cart call. That’s why the response is large and slow — it’s actually a complete checkout-page load happening invisibly in the background of every add-to-cart click.

    They also checked their own code (Redirect::checkout() / Redirect::head(), which is what renders our CheckoutWC checkout page) and confirmed it behaves correctly and only runs for genuine requests to the checkout page — it isn’t what’s issuing the redirect. So this points squarely at the etheme_ajax_add_to_cart handler itself sending a 302 where it should be sending an AJAX response.

    Setting they asked us to check, now ruled out

    CheckoutWC support suspected XStore Core might be respecting WooCommerce’s native “Redirect to the cart page after successful addition” setting even on AJAX requests. We checked: this setting is unchecked/off on washgiant.nl. The redirect still happens, so it isn’t driven by that particular WooCommerce toggle — it looks like it’s either hardcoded in the handler or tied to some other setting we haven’t found yet.

    A useful comparison

    We manage a second WooCommerce store on the same stack, craftyponies.nl (also XStore + CheckoutWC). There, “Add to cart” never triggers etheme_ajax_add_to_cart at all — it uses lightweight actions (etheme_svp_cart, cpbfgf_refresh), each roughly 1–1.5 seconds and ~10 KB, with no redirect and no checkout content involved. The one clear difference between the two sites: XStore Core version.

    washgiant.nl: XStore Core 5.7.7 (affected)
    craftyponies.nl: XStore Core 5.3.13 (not affected)

    That suggests something changed in the add-to-cart handling between those two versions — possibly related to an “instant checkout” or prefetch-style feature. We weren’t able to confirm this from your public changelog, which appears not to have been updated since November 2022.

    Settings already tested on our end (no effect on the redirect/response)

    Cart widget “Content Type” (Off-Canvas / Dropdown / None)
    Cart widget “Automatically Open Canvas” toggle
    Cart widget “View Checkout Button” (disabled and republished live — no change)
    Theme Options → “Ajax add to cart” (generic AJAX-vs-reload toggle, not the cause)
    Theme Options → “Buy Now” button (disabled — not related)
    WooCommerce → “Redirect to the cart page after successful addition” (confirmed off, per above)

    What we’d like help with

    Could you help us identify why etheme_ajax_add_to_cart is issuing a 302 redirect to /checkout/ instead of a normal AJAX response, and how to disable that behavior so “Add to cart” returns a lightweight response as expected? Happy to provide site admin access, HAR files, or any further diagnostics you need.

    Thanks in advance.

    Also, I didn’t receive the purchase offer/discount shown on ThemeForest, so please refund the difference I overpaid.

    Files is visible for topic creator and
    support staff only.
    9 Answers
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    September 1, 2026 at 09:37

    Hello, luc,

    Could you please provide temporary wp-admin and FTP access? We will check what can be done to help you.
    To grant WP-Admin access, please proceed to create a new user account with an administrator role through your WordPress Dashboard. Once the account is established, you may securely transmit the username and password to us via the Private Content section designated for this purpose.

    For FTP access, we require the following details: FTP host, FTP username, FTP password, FTP port, and FTP encryption type. If you need assistance in creating these credentials, please reach out to your hosting provider who will guide you through the process.

    Best Regards,
    8Theme’s Team

    Avatar: luc
    luc
    Participant
    September 1, 2026 at 09:44

    Thanks for the reply.

    Content is visible for topic creator and
    support staff only.
    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    September 2, 2026 at 14:28

    Hello, luc,

    Thank you for providing access. We have noticed that you are using theme version 9.7.4, while the latest version is 9.7.7. We kindly request you to update the theme, core plugin, and other plugins to their latest versions. Alternatively, please grant us permission to perform the updates for you.

    Best regards,
    8Theme’s Team

    Avatar: luc
    luc
    Participant
    September 2, 2026 at 14:44

    Thanks for checking. I’ve updated the theme to the latest version (9.7.7).

    Unfortunately the issue is still present. I just re-tested live, logged out (as a real anonymous visitor), on this product page:

    https://www.washgiant.nl/shop/wasstrips/lavender-fields/

    Clicking “Add to cart” still triggers a POST to admin-ajax.php that takes about 4.5 seconds and returns a ~216 KB response. I inspected the response body again and it’s still not a normal AJAX response, it starts with and contains a fully rendered page (head, CSS, etc.), the same signature as before the update. So the redirect-to-checkout behavior in the etheme_ajax_add_to_cart handler does not appear to be fixed by the 9.7.7 update.

    To summarize where things stand:

    Theme/Core/plugins updated to the latest versions (9.7.7) — confirmed via your own check.
    Bug still reproduces exactly as described in my previous message: etheme_ajax_add_to_cart issues an HTTP 302 to /checkout/ instead of a normal AJAX response, the browser auto-follows it, and the full checkout-page HTML comes back as the “response” (+/-216 KB / 4.5s logged out; up to 724 KB logged in).
    WooCommerce’s “Redirect to the cart page after successful addition” setting is off, so that’s not the trigger.
    CheckoutWC support independently reproduced this and confirmed their own code isn’t causing it, it’s on the theme/plugin side.

    Could you take another look

    Avatar: luc
    luc
    Participant
    September 3, 2026 at 15:32

    I’ve now traced the exact mechanism and can reproduce it reliably outside of the normal button click, so I’m sharing this in case it saves your team time.
    The add-to-cart request your theme’s JS sends to admin-ajax.php is built by serializing the existing

    element. That form includes WooCommerce’s own classic (non-AJAX) fallback field add-to-cart= (the field WooCommerce uses when JavaScript is disabled and the page is simply reloaded). Your theme’s JS adds action=etheme_ajax_add_to_cart on top and posts the combined body. For example, the real request body captured from the “Lavender fields” product (ID 5800) is:

    quantity=1&add-to-cart=5800&action=etheme_ajax_add_to_cart

    admin-ajax.php boots WordPress fully, including firing the wp_loaded hook. WooCommerce core registers WC_Form_Handler::add_to_cart_action() on wp_loaded unconditionally — it doesn’t check whether the request is an AJAX call or a normal page load, it only checks whether $_REQUEST[‘add-to-cart’] is set. Because that field is present in every request your JS sends, WooCommerce core’s own handler fires first (before admin-ajax.php ever reaches its own action dispatch, which is where etheme_ajax_add_to_cart() is hooked via wp_ajax_etheme_ajax_add_to_cart), adds the product to the cart itself, queues the session notice, and issues wp_safe_redirect() + exit() to the checkout page. Your theme’s own etheme_ajax_add_to_cart() handler (in framework/woo.php) is correctly written and returns a proper small JSON response — but it never actually runs, because the request already exited earlier in the request lifecycle.

    The browser then transparently follows that 302, and the full checkout-page HTML comes back as the “response” to the add-to-cart click — that’s the 4.5–9s delay and 216–724 KB payload.

    Reproduced in isolation, without clicking the button

    Directly in the browser console, on a live product page:

    POST to admin-ajax.php with body action=etheme_ajax_add_to_cart&product_id=5800&quantity=1 (using the field name product_id instead of add-to-cart) → normal 200 response, ~12.5 KB JSON, no redirect.
    The exact same call but with the real field name your JS uses, add-to-cart=5800 instead of product_id=5800 → with fetch(…, {redirect:’manual’}) this returns {status: 0, type: “opaqueredirect”} (i.e. the server sent a 3xx); with a plain XHR (which follows redirects) the request ends at responseURL: https://www.washgiant.nl/checkout/, 723,104 bytes.

    So the presence of the add-to-cart= field name in the AJAX body is the entire trigger — nothing else needs to change to reproduce or fix this.

    Why our other site (craftyponies.nl, older XStore Core 5.3.13) isn’t affected

    There, add-to-cart uses different, lighter AJAX actions (etheme_svp_cart / cpbfgf_refresh) that apparently don’t include the add-to-cart field in their POST body, so WooCommerce core’s classic handler never triggers. This suggests something changed in how the add-to-cart form is serialized between that version and 5.7.7.

    Suggested fix

    Either stop including the add-to-cart field name when building the AJAX POST body (rename it or strip it before sending, keeping only product_id/quantity/action), or explicitly unhook WC_Form_Handler::add_to_cart_action for requests carrying action=etheme_ajax_add_to_cart. Either change should let your existing etheme_ajax_add_to_cart() handler run as intended, without touching anything else in the add-to-cart flow.

    Happy to provide anything else that helps

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    September 3, 2026 at 17:08

    Hello, luc,

    We have identified the underlying issue, which was related to the settings of the “Buy Now” button. The AJAX request did not include the XStore “Buy Now” parameter. Instead, another callback on the WooCommerce woocommerce_add_to_cart_redirect filter was altering the redirect URL to the checkout page.

    WooCommerce processes the add-to-cart parameter before the XStore AJAX callback is executed. Since the filter returned the checkout URL, WooCommerce responded with an HTTP 302 and halted execution. Consequently, the browser automatically followed the redirect and downloaded the complete checkout-page HTML instead of receiving the expected JSON fragments.

    This also clarifies why disabling WooCommerce’s “Redirect to the cart page after successful addition” option had no effect—the explicit filtered redirect URL is processed before that setting.

    We have implemented a final high-priority safeguard specifically for the etheme_ajax_add_to_cart action. This prevents any redirect callback from affecting this AJAX request, allowing it to complete normally and return the expected JSON response. Regular “Buy Now” and non-AJAX redirects remain unaffected.

    Additionally, this fix will be included in the next theme update. As the fix involves multiple files, we have already installed the next version of the theme on your site.

    Best Regards,
    8Theme’s Team

    Avatar: luc
    luc
    Participant
    September 4, 2026 at 08:46

    Hi,

    Thanks for the quick turnaround and the clear explanation!

    I’ve tested the fix live on washgiant.nl and can confirm it’s working.
    Everything looks resolved. Good to hear this will also be part of the next public theme release so we don’t need to track a custom patch.

    Thanks again for digging into this, Luc.

    Avatar: luc
    luc
    Participant
    September 4, 2026 at 08:46

    Thanks for the support! My topic “etheme_ajax_add_to_cart returns an HTTP 302 redirect to /checkout/ instead of a normal AJAX response” has been successfully resolved.

    Avatar: Tony Rodriguez
    Tony Rodriguez
    Support staff
    September 4, 2026 at 08:46

    Dear luc,

    We really appreciate your time and engagement within the WordPress & WooCommerce community

    Your feedback drives every improvement we make in XStore — helping us deliver a smoother and more flexible experience with each update.

    Your input makes a real difference.

    Topic closed.
    The 8Theme Team

  • Viewing 10 results - 1 through 10 (of 10 total)

The issue related to '‘etheme_ajax_add_to_cart returns an HTTP 302 redirect to /checkout/ instead of a normal AJAX response’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.