Merge pull request #15948 from woocommerce/fix/15947

Remove side-effects
This commit is contained in:
Mike Jolley 2017-07-04 11:27:20 +01:00 committed by GitHub
commit 05a328cd33
1 changed files with 5 additions and 3 deletions

View File

@ -217,14 +217,16 @@ class WC_Structured_Data {
if ( $product->is_type( 'variable' ) ) {
$prices = $product->get_variation_prices();
$lowest = reset( $prices['price'] );
$highest = end( $prices['price'] );
if ( current( $prices['price'] ) === end( $prices['price'] ) ) {
if ( $lowest === $highest ) {
$markup_offer['price'] = wc_format_decimal( $product->get_price(), wc_get_price_decimals() );
} else {
$markup_offer['priceSpecification'] = array(
'price' => wc_format_decimal( $product->get_price(), wc_get_price_decimals() ),
'minPrice' => wc_format_decimal( current( $prices['price'] ), wc_get_price_decimals() ),
'maxPrice' => wc_format_decimal( end( $prices['price'] ), wc_get_price_decimals() ),
'minPrice' => wc_format_decimal( $lowest, wc_get_price_decimals() ),
'maxPrice' => wc_format_decimal( $highest, wc_get_price_decimals() ),
'priceCurrency' => $currency,
);
}