All Topics
WooCommerce add-on: Fatal error if order contains a removed product
Hey,
I got this error message:
Fatal error: Uncaught Error: Call to a member function get_weight() on bool in /path/to/wp-content/plugins/ac-addon-woocommerce/classes/Column/ShopOrder/TotalWeight.php:37
when listing an order that contained a removed product (permanently removed, not in trash).
I did a quick fix in your function get_raw_value to avoid the fatal error:
Before:
$weight = (int) $item->get_quantity() * (float) $item->get_product()->get_weight();
$total_weight += $weight;
After:
if ( $item['product_id'] > 0 ) {
$weight = (int) $item->get_quantity() * (float) $item->get_product()->get_weight();
$total_weight += $weight;
}
I hope that you’ll fix this issue in the next version.
Many thanks!
You must be logged in to reply to this topic.