Merge pull request #15948 from woocommerce/fix/15947
Remove side-effects
This commit is contained in:
commit
05a328cd33
|
@ -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,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue