Open KokkieH opened 4 years ago
cc @haszari. Do you think you could take a look? It'd be nice if we could continue to support multiple versions of WooCommerce without triggering the warning.
Why this issue was closed? This warning still shows up in the error log even with the latest Jetpack version.
[11-Jan-2022 12:26:54 UTC] The WC_Abstract_Legacy_Order::get_product_from_item function is deprecated since version 4.4.0. Replace with $item->get_product().
Thanks for the report. The issue is indeed back.
I don`t use Jetpack and still my error log is full of this error
The WC_Abstract_Legacy_Order::get_product_from_item function is deprecated since version 4.4.0. Replace with $item->get_product().
Can`t figure out what it is.
@droidsheep86 Since you don't use the Jetpack plugin, you know that notice does not come from the Jetpack plugin. I would recommend that you try to search through your different WooCommerce extensions for that get_product_from_item
method referenced by the notice. Once you find which WooCommerce extension uses that code, you can contact them to let them know about the issue.
@jeherve I will do that. I just wanted to tell you that its not Jetpack related. Thanks
When will you fix this one-line bug? It was reported over a year ago...
A user reported the following error on the checkout page of their WooCommerce site after updating to v 4.4.0, and using Jetpack 8.8.2:
Deprecated: WC_Abstract_Legacy_Order::get_product_from_item is deprecated since version 4.4.0! Use $item->get_product() instead. in C:\Utilities\laragon\www\arteescorp\wp-includes\functions.php on line 4773
They traced the error to this file:
...\wp-content\plugins\jetpack\modules\woocommerce-analytics\classes\class-jetpack-woocommerce-analytics-universal.php (1 hit) Line 283: $product = $order->get_product_from_item( $order_item );
Modifying that line as follows causes the error to go away:
Line 283: $product = $order_item->get_product();
I've not been able to replicate this error on a test site running WooCommerce 4.4.1 and Jetpack 8.9, but three different users reported it, and that the proposed fix resolved it. They were not able to provide steps to replicate - the error apparently just appears on the checkout page.
The file at https://github.com/Automattic/jetpack/blob/cfaf0497e9b20c931e8ad1959008bdb03a03962d/modules/woocommerce-analytics/classes/class-jetpack-woocommerce-analytics-universal.php#L283 still references
get_product_from_item
in the current version of Jetpack.Reported via https://wordpress.org/support/topic/deprecated-wc_abstract_legacy_orderget_product_from_item-is-deprecated-since/