weupnorth / Order-Weight-for-WooCommerce

This WordPress plugin stores the total weight of WooCommerce orders and displays the order weight when managing orders.
https://wordpress.org/plugins/woo-order-weight/
GNU General Public License v2.0
2 stars 0 forks source link

Fix "Order properties should not be accessed directly" #7

Open lelas opened 6 years ago

lelas commented 6 years ago

File: /woo-order-weight/admin/class-woo-order-weight-admin.php

PHP notice:

[26-Jun-2018 09:22:36 UTC] PHP Notice: id was called incorrectly. Order properties should not be accessed directly. Backtrace: include('wp-admin/edit-form-advanced.php'), do_meta_boxes, WC_Meta_Box_Order_Data::output, do_action('woocommerce_admin_order_data_after_shipping_address'), WP_Hook->do_action, WP_Hook->apply_filters, Woo_Order_Weight_Admin->woo_add_weight_to_single_order, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong Please see Debugging in WordPress for more information. (This message was added in version 3.0.) in /var/www/shop/web/wp-includes/functions.php on line 4148

Change line 174 from:

print get_post_meta( $order->id, $this->woo_get_weight_meta_key(), true ) . ' ' . $this->woo_get_woocommerce_weight_unit();

To:

print get_post_meta( $order->get_id();, $this->woo_get_weight_meta_key(), true ) . ' ' . $this->woo_get_woocommerce_weight_unit();

mradulovic988 commented 2 years ago

Awesome!