Only get purchase note if product exists

Fixes #10726
This commit is contained in:
Mike Jolley 2016-04-19 11:10:18 +01:00
parent cfedab0d74
commit 3ff10a4ce2
1 changed files with 7 additions and 8 deletions

View File

@ -13,7 +13,7 @@
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.3
* @version 2.6.0
*/
if ( ! defined( 'ABSPATH' ) ) {
@ -37,15 +37,14 @@ $show_customer_details = is_user_logged_in() && $order->get_user_id() === get_cu
<?php
foreach( $order->get_items() as $item_id => $item ) {
$product = apply_filters( 'woocommerce_order_item_product', $order->get_product_from_item( $item ), $item );
$purchase_note = get_post_meta( $product->id, '_purchase_note', true );
wc_get_template( 'order/order-details-item.php', array(
'order' => $order,
'item_id' => $item_id,
'item' => $item,
'show_purchase_note' => $show_purchase_note,
'purchase_note' => $purchase_note,
'product' => $product,
'order' => $order,
'item_id' => $item_id,
'item' => $item,
'show_purchase_note' => $show_purchase_note,
'purchase_note' => $product ? get_post_meta( $product->id, '_purchase_note', true ) : '',
'product' => $product,
) );
}
?>