Prevent error if variation doesn't exist.

This commit is contained in:
Mike Jolley 2013-12-03 14:54:09 +00:00
parent a8444eb567
commit 1ec8b82f69
1 changed files with 7 additions and 2 deletions

View File

@ -212,8 +212,13 @@ class WC_Product_Variable extends WC_Product {
if ( $display ) {
$variation = $this->get_child( $variation_id );
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$price = $tax_display_mode == 'incl' ? $variation->get_price_including_tax() : $variation->get_price_excluding_tax();
if ( $variation ) {
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
$price = $tax_display_mode == 'incl' ? $variation->get_price_including_tax() : $variation->get_price_excluding_tax();
} else {
$price = '';
}
} else {
$price = get_post_meta( $variation_id, '_price', true );
}