Product::price_range()
Summary
No summary available.Source
File: src/BigCommerce/Post_Types/Product/Product.php
public function price_range() { $original_price = $this->get_property( 'price' ); /** * Filter the price range data for a product * * @param array $prices The price range meta for the product * @param Product $product The product object */ $prices = apply_filters( 'bigcommerce/product/price_range/data', get_post_meta( $this->post_id, self::PRICE_RANGE_META_KEY, true ), $this ); $low = isset( $prices['price']['min'] ) ? $prices['price']['min'] : 0; $high = isset( $prices['price']['max'] ) ? $prices['price']['max'] : 0; if ( $original_price && $original_price < $low ) { $low = $original_price; } if ( $original_price && $original_price > $high ) { $high = $original_price; } if ( $low == $high ) { $range = $this->format_currency( $low, __( 'Free', 'bigcommerce' ) ); } else { $range = sprintf( _x( '%s - %s', 'price range low to high', 'bigcommerce' ), $this->format_currency( $low, __( 'Free', 'bigcommerce' ) ), $this->format_currency( $high, __( 'Free', 'bigcommerce' ) ) ); } /** * Filter the formatted price range for a product * * @param string $range The formatted price range * @param Product $product The product object * @param array $prices The price range meta for the product */ return apply_filters( 'bigcommerce/product/price_range/formatted', $range, $this, $prices ); }