取消付款后更改WooCommerce重定向URL

发布于 2025-02-01 07:39:08 字数 620 浏览 2 评论 0 原文

我注意到我的WooCommerce结帐过程在取消付款后不会将客户返回到结帐页面,而是将其重定向到主页。

细节: 我使用一个WordPress网站,客户可以通过PayPal,CreditCard等付款等。PayPal和我的CreditCard设置都要求网站重定向到外部网站以进行付款,并且付款完成后,客户将被定向回订单。 - 接收页。这一切都很好。

但是,如果外部网站上的客户(例如paypal.com)决定击中“取消付款”,他将带有这样的URL回到主页:

我使用所有插件禁用和默认主题检查了我的网站,同一件事也发生了。它似乎是WooCommerce标准设置的一部分。

我已经搜索了一个解决方案,但没有找到任何解决方案。有人可以将我指向正确的方向吗?

I noticed that my Woocommerce checkout process does not return the customer to the checkout page after a payment is cancelled, instead he is redirected to the home page.

Specifics:
I use a Wordpress site where a customer can pay with Paypal, creditcard etc. Both Paypal and my creditcard setup require the website to redirect to an external site to do the payment and when the payment is complete, the customer is directed back to the order-received page. This is all working fine.

But if the customer on the external site (Paypal.com for example) decides to hit the "cancel payment" he arrives back to the home page with a URL like this: https://example.com/?cancel_order=true&order=wc_order_oEYInB5bC3mCo&order_id=225487&redirect&_wpnonce=99cfb8ef9f

I checked my site with all plugins disabled and default theme and the same thing happens. It seems to be part of Woocommerce standard setup.

I have searched for a solution but did not find anything about this. Can someone point me in the right direction?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌伤ぢ 2025-02-08 07:39:08

我在WooCommerce支持论坛上发布了同样的问题,并获得了解决该错误的帮助(尽管他们确实告诉我在Sandbox Fresh安装中,此问题没有发生)。

这是为我解决的代码段:

add_action('woocommerce_cancelled_order','lenura_redirect_to_home');
 function lenura_redirect_to_home() {
    wp_redirect(home_url( '/checkout/' )); // REDIRECT PATH
 }

如果其他任何人都遇到了这一点。

I posted this same question on the woocommerce support forum and received assistance to fix the bug (though they did tell me that in the sandbox fresh installation this problem was not occuring).

Here is the code snippet which resolved it for me:

add_action('woocommerce_cancelled_order','lenura_redirect_to_home');
 function lenura_redirect_to_home() {
    wp_redirect(home_url( '/checkout/' )); // REDIRECT PATH
 }

In case anyone else is running into this.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文