Automattic\WooCommerce\Internal\ProductFeed\Mapping
UcpProductMapper::build_price_range
Build the price range from Store API prices.
price_range is only set for variable products whose variations differ in price; everything else is a single price.
Method of the class: UcpProductMapper{}
No Hooks.
Returns
array.
Usage
// private - for code of main (parent) class only $result = $this->build_price_range( $prices, $currency ): array;
- $prices(array) (required)
- Store API
pricesdata. - $currency(string) (required)
- ISO 4217 currency code.
UcpProductMapper::build_price_range() UcpProductMapper::build price range code WC 11.3.0
private function build_price_range( $prices, string $currency ): array {
$range = $prices['price_range'] ?? null;
if ( is_array( $range ) ) {
return array(
'min' => $this->price( $range['min_amount'], $currency ),
'max' => $this->price( $range['max_amount'], $currency ),
);
}
return array(
'min' => $this->price( $prices['price'], $currency ),
'max' => $this->price( $prices['price'], $currency ),
);
}