简体   繁体   English

WooCommerce在结帐时重写规则

[英]WooCommerce rewrite rules on checkout

I'm having hard time debugging an issue with Woocommerce-powered site. 我在调试Woocommerce支持的网站的问题时遇到了困难。 When I checkout, fill in all the order fields, click on Place Order button and then there is an AJAX request to 当我结帐时,填写所有订单字段,单击“下订单”按钮,然后有一个AJAX请求

https://www.shop.com/wp-admin/admin-ajax.php https://www.shop.com/wp-admin/admin-ajax.php

which responds with success JSON: 响应成功的JSON:

{"result":"success","redirect":"https:\/\/www.shop.com\/checkout\/pay\/?key=order_50b9f4b86e75f&order=4491"}

And then the browser actually goes to https://www.shop.com/checkout/pay/?key=order_50b9f4b86e75f&order=4491 but the problem is that on this request it gets redirected back (302 redirect via headers) to /checkout without /pay, and all fields are empty. 然后浏览器实际上会转到https://www.shop.com/checkout/pay/?key=order_50b9f4b86e75f&order=4491,但问题在于,在此请求下,它被重定向回(通过标头重定向302)到/ checkout,而没有/支付,并且所有字段均为空。 But it used to redirect to default payment gateway of woocommerce which is paypal in my case. 但是它曾经重定向到woocommerce的默认支付网关,在我的案例中是paypal。 The order is actually placed and visible in admin, but user is never directed to paypal for payment. 该订单实际上是在admin中放置并可见的,但是用户永远不会被定向到Paypal进行支付。

This appeared when I switched from apache to nginx server. 当我从apache切换到nginx服务器时,这出现了。

Here is my nginx config for this site: 这是此站点的我的nginx配置:

server {
       listen 80;
       server_name shop.com www.shop.com;
       root /var/www/shop;
       index index.php;
error_log    /var/log/nginx/shop_error.log notice;
rewrite_log     on;

       location / {
                try_files $uri $uri/ /index.php;
       }
       location ~* \.(?:ico|css|js|gif|jp?g|png) {
           expires 100d;
       }

       location ~ \.php$ {
          include        fastcgi_params;
          fastcgi_pass   localhost:9000;
       }

#       include /var/www/shop/nginx.conf;

       location = /wp-config.php {
          deny all;
       }

}

server {
       listen 443;
       server_name shop.com www.shop.com;
error_log    /var/log/nginx/shop_error.log notice;
rewrite_log     on;
       root /var/www/shop;
       index index.php;

       ssl on;
       ssl_certificate /etc/nginx/sslchain.crt;
       ssl_certificate_key /etc/nginx/server.key;
       ssl_client_certificate /etc/nginx/cert.ca-bundle;

       ssl_session_timeout 5m;

       ssl_protocols SSLv3 TLSv1;
       ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
       ssl_prefer_server_ciphers on;
location / {
       try_files $uri $uri/ /index.php;
}
       #include /var/www/shop/nginx.conf;

       location ~* \.(?:ico|css|js|gif|jp?g|png) {
           expires 100d;
       }
       location ~ \.php$ {
          include        fastcgi_params;
          fastcgi_pass   localhost:9000;
       }

       location = /wp-config.php {
          deny all;
       }

}

I looked at nginx rewrite log and it correctly redirects /checkout/pay request to WP index.php, at least I think that this is correct. 我查看了nginx重写日志,它正确地将/ checkout / pay请求重定向到WP index.php,至少我认为这是正确的。

Now I'm not asking anyone to point me to exact problem. 现在,我没有要求任何人向我指出确切的问题。 Even though I'd appreciate that, but I'm trying to figure out woocommerce rewrite rules and where the script which handles /checkout/pay is and I'll try to debug it myself before the redirect to /checkout to understand why it redirects. 即使我对此表示赞赏,但我还是想弄清楚woocommerce重写规则以及处理/ checkout / pay的脚本在哪里,我将尝试在重定向到/ checkout 之前自己进行调试,以了解为什么重定向。

The "pay" page has only Woocommerce shortcode it in [woocommerce_pay] and its URL seems to be right: "/checkout/pay/" “付款”页面仅在[woocommerce_pay]中为其添加了Woocommerce短代码,并且其URL似乎是正确的:“ / checkout / pay /”

I tried to place a debug dump in functions in shortcodes/shortcode-pay.php and nothing happens, so it gets redirected before that? 我试图将调试转储放置在shortcodes / shortcode-pay.php中的函数中,但没有任何反应,因此在此之前将其重定向?

Any cache plugins are turned off now. 现在已关闭所有缓存插件。 Here is the list of all active plugins at the moment: 这是目前所有活动插件的列表:

akismet
debug-bar
gravityforms
secure-wordpress
tinymce-advanced
vslider
woocommerce
woocommerce-compare-products
woocommerce-custom-product-tabs-lite
woocommerce-debug-bar
woocommerce-delivery-notes
woocommerce-fedex
woocommerce-gateway-paypal-advanced
woocommerce-gravityforms-product-addons
woocommerce-product-bundles
woocommerce-usps
woocommerce-USPS
woodojo
woodojo-downloads
woosidebars
wordpress-importer
wordpress-seo
wp-dbmanager

I found the error myself, it was wrong config of nginx rewrite rules. 我自己发现了错误,这是nginx重写规则的配置错误。 Specifically, I think I got 具体来说,我认为

location / {
   try_files $uri $uri/ /index.php
}

But it should have been like here in "Abridged basic setup" section 但这应该像“精简基本设置”部分中的此处所示

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM