• Resolved mikestealth

    (@mikestealth)


    I am struggling to find a way to change the base path for WooCommerce Ajax calls (wc-ajax), if it’s even possible. Any API call made on the root path, such as /?wc-ajax=update_order_review or /?wc-ajax=wc_stripe_get_cart_details, is causing me issues. I would like to enforce the listener to use a URL with a prefix, like /prefix/?wc-ajax=update_order_review. Is this even doable? If not, why? I don’t understand why API calls are made against the root path.

    For clarification:

    This issue is causing me problems, as we have an application running in hybrid mode. The entire front-end, CLP views, PDP views, etc., are written separately from WordPress in React. However, /cart and checkout should be managed by WooCommerce itself. React is running on the same server as WordPress, and certain paths are subject to proxypass rules in Apache2. Since the homepage (/) is also subject to proxypass, it is causing the main issues. Proxypass cannot be conditioned based on query parameters, only based on the path; thus, all API calls against the root path end up on the React app instead of WooCommerce. This issue could be easily avoided if the API didn’t listen on / but on some prefixed path instead.

    Thanks for any advice.

Viewing 1 replies (of 1 total)
  • Plugin Support ckadenge (woo-hc)

    (@ckadenge)

    Hi @mikestealth,

    I understand your issue regarding WooCommerce Ajax calls and the need to change the base path. Unfortunately, WooCommerce does not provide an out-of-the-box solution to modify the base path for its Ajax calls. It was purposely designed to be on the root to ensure maximum compatibility with various server configurations and minimize potential conflicts with URL rewriting that may be set up on a site.?

    Given your unique situation, you might consider developing a custom solution. This would involve modifying the WooCommerce plugin code, which is not recommended as it could lead to issues with future updates. Alternatively, you could create a custom plugin that intercepts the requests and rewrites the URLs.

    However, these solutions require advanced knowledge of WordPress and WooCommerce development, and could potentially introduce new issues. It would be best to consult with a WordPress developer or agency for such custom development tasks.

    The WooCommerce community is filled with talented open-source developers, and many of them are active on the channels listed below:

    I hope this information helps. Please let me know if you have any other questions.

Viewing 1 replies (of 1 total)
  • The topic ‘Base path for WooCoomerce ajax calls (wc-ajax)’ is closed to new replies.