WooCommerce在结账时重写规则

时间:2012-12-01 12:33:24

标签: wordpress nginx woocommerce

我很难用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没有/ pay,并且所有字段都是空的。但它曾经重定向到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以了解重定向的原因。

“付费”页面只有Woocommerce在[woocommerce_pay]中对其进行短代码,其网址似乎如此 是的:“/ 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

1 个答案:

答案 0 :(得分:1)

我自己发现了错误,这是nginx重写规则的配置错误。具体来说,我想我得到了

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

但它应该像“基本设置”部分中的here一样