/** * Returns the price in html format. * * @access public * @param string $price (default: '') * @return string */ public function get_price_html($price = '') { $tax_display_mode = get_option('woocommerce_tax_display_shop'); $child_prices = array(); foreach ($this->get_children() as $child_id) { $child = wc_get_product($child_id); if ('' !== $child->get_price()) { $child_prices[] = 'incl' === $tax_display_mode ? wc_get_price_including_tax($child) : wc_get_price_excluding_tax($child); } } if (!empty($child_prices)) { $min_price = min($child_prices); $max_price = max($child_prices); } else { $min_price = ''; $max_price = ''; } if ('' !== $min_price) { $price = $min_price !== $max_price ? sprintf(_x('%1$s–%2$s', 'Price range: from-to', 'woocommerce'), wc_price($min_price), wc_price($max_price)) : wc_price($min_price); $is_free = 0 == $min_price && 0 == $max_price; if ($is_free) { $price = apply_filters('woocommerce_grouped_free_price_html', __('Free!', 'woocommerce'), $this); } else { $price = apply_filters('woocommerce_grouped_price_html', $price . wc_get_price_suffix($this), $this, $child_prices); } } else { $price = apply_filters('woocommerce_grouped_empty_price_html', '', $this); } return apply_filters('woocommerce_get_price_html', $price, $this); }
/** * Returns the price in html format. * @return string */ public function get_price_html($deprecated = '') { if ('' === $this->get_price()) { return apply_filters('woocommerce_empty_price_html', '', $this); } if ($this->is_on_sale()) { $price = wc_format_sale_price(wc_get_price_to_display($this, array('price' => $this->get_regular_price())), wc_get_price_to_display($this)) . wc_get_price_suffix($this); } else { $price = wc_price(wc_get_price_to_display($this)) . wc_get_price_suffix($this); } return apply_filters('woocommerce_get_price_html', $price, $this); }
/** * Returns the price in html format. * * @param string $price (default: '') * @return string */ public function get_price_html($price = '') { $prices = $this->get_variation_prices_including_taxes(); if (empty($prices['price'])) { return apply_filters('woocommerce_variable_empty_price_html', '', $this); } $min_price = current($prices['price']); $max_price = end($prices['price']); if ($min_price !== $max_price) { $price = apply_filters('woocommerce_variable_price_html', wc_format_price_range($min_price, $max_price) . wc_get_price_suffix($this), $this); } else { $price = apply_filters('woocommerce_variable_price_html', wc_price($min_price) . wc_get_price_suffix($this), $this); } return apply_filters('woocommerce_get_price_html', $price, $this); }
/** * Get the suffix to display after prices > 0. * * @deprecated 2.7.0 Use wc_get_price_suffix instead. * @param string $price to calculate, left blank to just use get_price() * @param integer $qty passed on to get_price_including_tax() or get_price_excluding_tax() * @return string */ public function get_price_suffix($price = '', $qty = 1) { wc_deprecated_function('WC_Product::get_price_suffix', '2.7', 'wc_get_price_suffix'); return wc_get_price_suffix($this, $price, $qty); }