Ensure attributes exist

This commit is contained in:
Mike Jolley 2014-02-28 15:42:12 +00:00 committed by Coen Jacobs
parent f683c29e66
commit 10190ab177
2 changed files with 9 additions and 2 deletions

View File

@ -511,7 +511,11 @@ class WC_Cart {
} else {
$value = apply_filters( 'woocommerce_variation_option_name', $value );
$product_attributes = $cart_item['data']->get_attributes();
$label = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', urldecode( $name ) ) ]['name'] );
if ( isset( $product_attributes[ str_replace( 'attribute_', '', urldecode( $name ) ) ] ) ) {
$label = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', urldecode( $name ) ) ]['name'] );
} else {
$label = $name;
}
}
$item_data[] = array(

View File

@ -61,7 +61,10 @@ class WC_Order_Item_Meta {
// If we have a product, and its not a term, try to find its non-sanitized name
} elseif ( $this->product ) {
$product_attributes = $this->product->get_attributes();
$meta_key = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', urldecode( $meta_key ) ) ]['name'] );
if ( isset( $product_attributes[ str_replace( 'attribute_', '', urldecode( $meta_key ) ) ] ) ) {
$meta_key = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', urldecode( $meta_key ) ) ]['name'] );
}
}
if ( $flat )