Prevent notices if variation_id isn't set

It's a minor thing, but I have ran into circumstances where the `$item`
array doesn't have the `variation_id` set (namely after importing data
using another plugin). This tweak checks for the `variation_id` without
throwing a notice if the array key isn't defined.
This commit is contained in:
Dominic 2015-04-09 16:15:28 -07:00
parent 1253e75e79
commit be8e61161b
1 changed files with 2 additions and 2 deletions

View File

@ -18,9 +18,9 @@ if ( ! defined( 'ABSPATH' ) ) {
echo '<strong>' . __( 'Product ID:', 'woocommerce' ) . '</strong> ' . absint( $item['product_id'] );
if ( $item['variation_id'] && 'product_variation' === get_post_type( $item['variation_id'] ) ) {
if ( ! empty( $item['variation_id'] ) && 'product_variation' === get_post_type( $item['variation_id'] ) ) {
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] );
} elseif ( $item['variation_id'] ) {
} elseif ( ! empty( $item['variation_id'] ) ) {
echo '<br/><strong>' . __( 'Variation ID:', 'woocommerce' ) . '</strong> ' . absint( $item['variation_id'] ) . ' (' . __( 'No longer exists', 'woocommerce' ) . ')';
}