Do not FATAL on $product->has_file

This commit is contained in:
Gregory Karpinsky 2015-06-29 09:08:16 -04:00
parent eae15e9d72
commit 9094bb0662
1 changed files with 7 additions and 0 deletions

View File

@ -2104,6 +2104,13 @@ abstract class WC_Abstract_Order {
$product_id = $item['variation_id'] > 0 ? $item['variation_id'] : $item['product_id'];
$product = wc_get_product( $product_id );
if ( ! $product ) {
/**
* $product can be `false`. Example: checking an old order, when a product or variation has been deleted
* @see \WC_Product_Factory::get_product
*/
return array();
}
$download_ids = $wpdb->get_col( $wpdb->prepare("
SELECT download_id
FROM {$wpdb->prefix}woocommerce_downloadable_product_permissions