我很难调试 Woocommerce 支持的网站的问题。当我结帐时,填写所有订单字段,单击“下订单”按钮,然后有一个 AJAX 请求
https://www.shop.com/wp-admin/admin-ajax.php
以成功 JSON 响应:
{"result":"success","redirect":"https:\/\/www.shop.com\/checkout\/pay\/?key=order_50b9f4b86e75f&order=4491"}
然后浏览器实际上转到https://www.shop.com/checkout/pay/?key=order_50b9f4b86e75f&order=4491但问题是在此请求中它被重定向回(302 通过标头重定向)到 /checkout 没有 /付款,所有字段为空。但它曾经重定向到 woocommerce 的默认支付网关,在我的例子中是 paypal。订单实际上已下达并在管理员中可见,但用户永远不会被定向到贝宝付款。
当我从 apache 切换到 nginx 服务器时出现这种情况。
这是我为这个站点配置的 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;
}
}
我查看了 nginx 重写日志,它正确地将 /checkout/pay 请求重定向到 WP index.php,至少我认为这是正确的。
现在我不要求任何人指出我确切的问题。即使我很感激,但我正在尝试找出 woocommerce 重写规则以及处理 /checkout/pay 的脚本在哪里,我会在重定向到 /checkout之前尝试自己调试它以了解它重定向的原因.
“支付”页面在 [woocommerce_pay] 中只有 Woocommerce 短代码,其 URL 似乎是正确的:“/checkout/pay/”
我试图在 shortcodes/shortcode-pay.php 中的函数中放置调试转储,但没有任何反应,所以在此之前它会被重定向?
现在所有缓存插件都已关闭。以下是目前所有活动插件的列表:
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