コード例 #1
9
 /**
  * Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
  *
  * @deprecated 2.7.0 Use wc_get_price_to_display 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_display_price($price = '', $qty = 1)
 {
     wc_deprecated_function('WC_Product::get_display_price', '2.7', 'wc_get_price_to_display');
     return wc_get_price_to_display($this, array('qty' => $qty, 'price' => $price));
 }
コード例 #2
0
 /**
  * Returns an array of data for a variation. Used in the add to cart form.
  * @since  2.4.0
  * @param  WC_Product $variation Variation product object or ID
  * @return array
  */
 public function get_available_variation($variation)
 {
     if (is_numeric($variation)) {
         $variation = wc_get_product($variation);
     }
     return apply_filters('woocommerce_available_variation', array_merge($variation->get_data(), array('attributes' => $variation->get_variation_attributes(), 'image' => wc_get_product_attachment_props($variation->get_image_id()), 'weight_html' => wc_format_weight($variation->get_weight()), 'dimensions_html' => wc_format_dimensions($variation->get_dimensions(false)), 'price_html' => apply_filters('woocommerce_show_variation_price', $variation->get_price() === "" || $this->get_variation_price('min') !== $this->get_variation_price('max'), $this, $variation) ? '<span class="price">' . $variation->get_price_html() . '</span>' : '', 'availability_html' => wc_get_stock_html($variation), 'variation_id' => $variation->get_id(), 'variation_is_visible' => $variation->variation_is_visible(), 'variation_is_active' => $variation->variation_is_active(), 'is_purchasable' => $variation->is_purchasable(), 'display_price' => wc_get_price_to_display($variation), 'display_regular_price' => wc_get_price_to_display($variation, array('price' => $variation->get_regular_price())), 'dimensions' => wc_format_dimensions($variation->get_dimensions(false)), 'min_qty' => 1, 'max_qty' => $variation->backorders_allowed() ? '' : $variation->get_stock_quantity(), 'backorders_allowed' => $variation->backorders_allowed(), 'is_in_stock' => $variation->is_in_stock(), 'is_downloadable' => $variation->is_downloadable(), 'is_virtual' => $variation->is_virtual(), 'is_sold_individually' => $variation->is_sold_individually() ? 'yes' : 'no', 'variation_description' => $variation->get_description())), $this, $variation);
 }
コード例 #3
0
 /**
  * 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);
 }