0
votes

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

1 Answers

3
votes

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.