Ensure product exists before getting title. Closes #4916

This commit is contained in:
Mike Jolley 2014-02-25 14:48:55 +00:00
parent 9a52c5dd43
commit e73aa65440
1 changed files with 5 additions and 1 deletions

View File

@ -149,7 +149,11 @@ class WC_Report_Sales_By_Product extends WC_Admin_Report {
foreach ( $this->product_ids as $product_id ) {
$product = get_product( $product_id );
$this->product_ids_titles[] = $product->get_formatted_name();
if ( $product ) {
$this->product_ids_titles[] = $product->get_formatted_name();
} else {
$this->product_ids_titles[] = '#' . $product_id;
}
}
echo '<p>' . ' <strong>' . implode( ', ', $this->product_ids_titles ) . '</strong></p>';