payment_method called incorrectly

I have a problem with a plugin for my payments methods!
WordPress 4.9.8
WooCommerce 3.4.5
Error from Debug.log: [04-Nov-2018 16:53:14 UTC] PHP Notice: Η payment_method called incorrectly. Order properties should not be accessed directly. Backtrace: require(‘wp-blog-header.php’), wp, WP->main, do_action_ref_array, WP_Hook->do_action, WP_Hook->apply_filters, alphabank_message, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see the page Debugging in WordPress for more informations. (This message was added to Version. 3.0.) in /home/mariar/public_html/wp-includes/functions.php on line 4161

and the code from the plugin

function alphabank_message() {
$order_id = absint(get_query_var(‘order-received’));
$order = new WC_Order($order_id);
$payment_method = $order->payment_method;

if (is_order_received_page() && ( ‘alphabank_gateway’ == $payment_method )) {

$alphabank_message = get_post_meta($order_id, ‘_alphabank_message’, true);
$message = $alphabank_message[‘message’];
$message_type = $alphabank_message[‘message_type’];

delete_post_meta($order_id, ‘_alphabank_message’);

if (!empty($alphabank_message)) {
wc_add_notice($message, $message_type);

Read more here:: payment_method called incorrectly

Leave a Reply

Your email address will not be published. Required fields are marked *