dream3323 2017-08-03 13:18
浏览 121

Woo commerce checkout页面:状态调用不正确。 不应直接访问订单属性

Im running WordPress 4.8, Woocommerce 3.1.1, WooCommerce Subscriptions 2.2.10. When I select payment method BACS on the Checkout page I get the following error:

PHP message: status was called incorrectly. Order properties should not be accessed directly. Backtrace:

require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), do_action('template_redirect'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WC_AJAX::do_wc_ajax, do_action('wc_ajax_checkout'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Checkout->process_order_payment, WC_Gateway_BACS->process_payment, WC_Order->update_status, WC_Order->save, WC_Order->status_transition, do_action('woocommerce_order_status_pending_to_on-hold'), WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WC_Emails::send_transactional_email, do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, call_user_func_array, WC_Email_New_Order->trigger, WC_Email->get_content, WC_Email_New_Order->get_content_html, wc_get_template_html, wc_get_template, include('/plugins/woocommerce/templates/emails/admin" ```

while reading response header from upstream.

Does anyone know what is causing the error and how do I resolve it? I'm running Twenty Seventeen default theme.

  • 写回答

1条回答 默认 最新

  • dqqpf32897 2017-09-29 16:22
    关注

    Somewhere in the checkout function there is a direct access to property status of $order meaning there is something like this $order->status in the code.

    This is changed and not allowed anymore in version 3.0 of woocommerce.

    Try changing it to something like:

    $orderStatus = get_post_meta($order_id, '_status', true);
    

    check this related issue

    You have to figure out how the meta_key in the post_meta table of your database is called for the order status and replace it as the second argument in the get_post_meta function (i assumed it is called _status).

    I had the same problem for another plugin and for an other property, $order->payment_method and when I changed it to

    $payment_method = get_post_meta($order_id, '_payment_method', true);
    

    it worked and no more notice messages appeared.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂