doqp87012 2016-06-29 04:25
浏览 80

结帐时出错 - Wordpress

I have this extremely strange error that only happens when people try to order. Guests come onto our site and add stuff to their cart. Then they proceed to go to the checkout. On checkout when they click proceed to paypal they get the following error: "We were unable to process your order, please try again.". However on reloading the page the error is gone when they try to recheckout. No plugins or themes are conflicting as I checked all of them.

I did some debugging and I noticed that the reason the error is thrown is because of the function: wp_verify_nonce() I did some further debugging and found out that during the first time the user tries to checkout the above function is called. And returns false because the nonce is different when compared to what is currently hashed. However on the second checkout the above function returns true because the nonce is correct. This means that for some reason my nonce is wrong the first time. Does anyone know why?

I'm getting this problem on the following function: process_checkout() When the following command is run:

if ( empty( $_POST['_wpnonce'] ) || ! wp_verify_nonce( $_POST['_wpnonce'], 'woocommerce-process_checkout' )) {
    WC()->session->set( 'refresh_totals', true );
    throw new Exception( __( 'We were unable to process your order, please try again.', 'woocommerce' ) );
}

I tried my best to explain my issue but does anyone know why my nonce is wrong during checkout on the first time?

  • 写回答

1条回答 默认 最新

  • dsafq2131321 2016-06-29 04:51
    关注

    The issue isn't really with wp_verify_nonce() or the code you posted.

    The way wp_nonce work is like a queue number, just like your processing number at the DMV.

    My best guess on what's happening is an extra wp_nonce being created when people checkout and wp_verify_nonce() is receiving a different one from what's expected. There's no way for me to really identify where it's happening without looking at the code base.

    If no custom code has been done for these parts then it really means there's a subtle plugin conflict with WooCommerce. It could be even a conflict with the theme.

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集