Warm tip: This article is reproduced from serverfault.com, please click

wooCommerce ajax submission to same checkout page does not work

发布于 2017-10-16 06:18:39

Upon updating wooCommerce to latest version, the checkout page https://my_website.com/checkout/ now does not submit to the same page (i.e. /checkout/ page) instead it submits to the root url (https://my_website.com/?wc-ajax=checkout).

Is there a possible workaround or solution when placing orders to restore the original behavior which is submitting orders to: (https://my_website.com/checkout/?wc-ajax=checkout)?

Questioner
Abdullah Barrak
Viewed
0
Abdullah Barrak 2017-10-16 16:12:03

Turns out that the issue is caused by a recent change maid in latest wooCommerce version by using home_page for all ajax request in the shop.

https://github.com/woocommerce/woocommerce/commit/fbe6db5c02077a548eb1a386076d59261017145f#diff-133db5662c51f5686d87611121a05a3b

Workaround:

Restore previous implementation by changing line 35 in includes/class-wc-ajax.php file ( inside get_endpoint function):

return esc_url_raw( apply_filters( 'woocommerce_ajax_get_endpoint', add_query_arg( 'wc-ajax', $request, remove_query_arg( array( 'remove_item', 'add-to-cart', 'added-to-cart' ), home_url( wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ), $request ) );