本文整理汇总了PHP中WC_Product::get_price_including_tax方法的典型用法代码示例。如果您正苦于以下问题:PHP WC_Product::get_price_including_tax方法的具体用法?PHP WC_Product::get_price_including_tax怎么用?PHP WC_Product::get_price_including_tax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WC_Product
的用法示例。
在下文中一共展示了WC_Product::get_price_including_tax方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_product_display_price
/**
* Calculates bundled product prices incl. or excl. tax depending on the 'woocommerce_tax_display_shop' setting.
*
* @param WC_Product $product the product
* @param double $price the product price
* @return double modified product price incl. or excl. tax
*/
public static function get_product_display_price($product, $price)
{
if (!$price) {
return $price;
}
if (get_option('woocommerce_tax_display_shop') === 'excl') {
$product_price = $product->get_price_excluding_tax(1, $price);
} else {
$product_price = $product->get_price_including_tax(1, $price);
}
return $product_price;
}
示例2: get_product_display_price
/**
* Returns the price including or excluding tax, based on the 'woocommerce_tax_display_shop' setting.
* Should be safe to remove when we drop WC 2.2 compatibility
*
* @param WC_Product $product the product object
* @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 static function get_product_display_price($product, $price = '', $qty = 1)
{
if (SV_WC_Plugin_Compatibility::is_wc_version_gte_2_3()) {
return $product->get_display_price($price, $qty);
} else {
if ($price === '') {
$price = $product->get_price();
}
$tax_display_mode = get_option('woocommerce_tax_display_shop');
$display_price = $tax_display_mode == 'incl' ? $product->get_price_including_tax($qty, $price) : $product->get_price_excluding_tax($qty, $price);
return $display_price;
}
}
示例3: woocs_product
function woocs_product($ID, $attr, $currency = true)
{
if (class_exists('WC_Product')) {
$product = new WC_Product($ID);
if ($attr == 'price_tax_inc') {
$p = round($product->get_price_including_tax(), 2);
} elseif ($attr == 'get_price_excluding_tax') {
$p = round($product->get_price_excluding_tax(), 2);
} elseif ($attr == 'get_price') {
$p = round($product->get_price(), 2);
} elseif ($attr == 'get_sale_price') {
$p = round($product->get_sale_price(), 2);
} elseif ($attr == 'get_regular_price') {
$p = round($product->get_regular_price(), 2);
} elseif ($attr == 'get_price_html') {
$p = strip_tags($product->get_price_html());
} elseif ($attr == 'is_in_stock') {
$p = $product->is_in_stock();
}
}
return $p;
}
示例4: get_product_subtotal
/**
* Get the product row subtotal.
*
* Gets the tax etc to avoid rounding issues.
*
* When on the checkout (review order), this will get the subtotal based on the customer's tax rate rather than the base rate.
*
* @param WC_Product $_product
* @param int $quantity
* @return string formatted price
*/
public function get_product_subtotal($_product, $quantity)
{
$price = $_product->get_price();
$taxable = $_product->is_taxable();
// Taxable
if ($taxable) {
if ($this->tax_display_cart == 'excl') {
$row_price = $_product->get_price_excluding_tax($quantity);
$product_subtotal = wc_price($row_price);
if ($this->prices_include_tax && $this->tax_total > 0) {
$product_subtotal .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
} else {
$row_price = $_product->get_price_including_tax($quantity);
$product_subtotal = wc_price($row_price);
if (!$this->prices_include_tax && $this->tax_total > 0) {
$product_subtotal .= ' <small class="tax_label">' . WC()->countries->inc_tax_or_vat() . '</small>';
}
}
// Non-taxable
} else {
$row_price = $price * $quantity;
$product_subtotal = wc_price($row_price);
}
return apply_filters('woocommerce_cart_product_subtotal', $product_subtotal, $_product, $quantity, $this);
}
示例5: get_composite_price_including_tax
/**
* Get min/max composite price including tax.
*
* @return double
*/
public function get_composite_price_including_tax($min_or_max = 'min')
{
if ($this->is_priced_per_product()) {
if (!$this->is_synced()) {
$this->sync_composite();
}
$property = $min_or_max . '_composite_price_incl_tax';
if ($this->{$property} !== false) {
return $this->{$property};
}
$price = $min_or_max === 'min' ? $this->min_composite_price : $this->max_composite_price;
if ($price) {
$this->{$property} = $this->get_price_including_tax(1, $this->get_base_price());
foreach ($this->price_index['price'][$min_or_max] as $component_id => $product_id) {
$component_data = $this->get_component_data($component_id);
$item_qty = $component_data['optional'] === 'yes' && $min_or_max === 'min' ? 0 : $component_data['quantity_' . $min_or_max];
if ($item_qty) {
$composited_product = $this->get_composited_product($component_id, $product_id);
$this->{$property} += $item_qty * $composited_product->get_price_including_tax($min_or_max);
}
}
$price = $this->{$property};
}
} else {
$price = parent::get_price_including_tax(1, parent::get_price());
}
return $price;
}
示例6:
/**
* Calculates bundled product prices incl. or excl. tax depending on the 'woocommerce_tax_display_shop' setting.
*
* @param WC_Product $product the product
* @param double $price the product price
* @return double modified product price incl. or excl. tax
*/
function get_product_price_incl_or_excl_tax($product, $price)
{
if ($price == 0) {
return $price;
}
if ($this->wc_option_tax_display_shop == 'excl') {
$product_price = $product->get_price_excluding_tax(1, $price);
} else {
$product_price = $product->get_price_including_tax(1, $price);
}
return $product_price;
}
示例7: get_quotelist_product_price
/**
* Get the product row price per item.
*
* @param WC_Product $_product
* @return string formatted price
*/
function get_quotelist_product_price($_product)
{
if (get_option('woocommerce_display_cart_prices_excluding_tax') == 'yes') {
$product_price = $_product->get_price_excluding_tax();
} else {
$product_price = $_product->get_price_including_tax();
}
//return array($product_price,apply_filters( 'woocommerce_cart_product_price', wc_price( $product_price ), $_product ));
return (double) $product_price;
}
示例8: get_composited_product_price
/**
* Get the shop price of a product incl or excl tax, depending on the 'woocommerce_tax_display_shop' setting.
*
* @param WC_Product $product
* @param double $price
* @return double
*/
public function get_composited_product_price($product, $price = '')
{
if ($price === '') {
$price = $product->get_price();
}
if ($this->wc_option_tax_display_shop === 'excl') {
$product_price = $product->get_price_excluding_tax(1, $price);
} else {
$product_price = $product->get_price_including_tax(1, $price);
}
return $product_price;
}
示例9: get_min_bundle_price_incl_tax
/**
* Getter for min_bundle_price_incl_tax.
*
* @return double
*/
public function get_min_bundle_price_incl_tax()
{
if ($this->is_priced_per_product()) {
if (!$this->is_synced()) {
$this->sync_bundle();
}
$price = $this->min_bundle_price_incl_tax;
} else {
$price = parent::get_price_including_tax(1, parent::get_price());
}
return $price;
}
示例10: get_bundle_price_including_tax
/**
* Bundle price including tax.
*
* @return double
*/
public function get_bundle_price_including_tax($min_or_max = 'min')
{
if ($this->is_priced_per_product()) {
if (!$this->is_synced()) {
$this->sync_bundle();
}
$property = $min_or_max . '_bundle_price_incl_tax';
if ($this->{$property} !== false) {
return $this->{$property};
}
$price = $min_or_max === 'min' ? $this->min_bundle_price : $this->max_bundle_price;
if ($price) {
$this->{$property} = $this->get_price_including_tax(1, $this->get_base_price());
foreach ($this->bundled_items as $bundled_item) {
$bundled_item_qty = $this->bundled_quantities_index[$min_or_max][$bundled_item->item_id];
if ($bundled_item_qty) {
$this->{$property} = $this->{$property} + $bundled_item_qty * $bundled_item->get_bundled_item_price_including_tax($min_or_max);
}
}
$price = $this->{$property};
}
} else {
$price = parent::get_price_including_tax(1, parent::get_price());
}
return $price;
}
示例11: on_price_html
/**
* Adjust discounted product price HTML
*
* @since 1.3.0
* @param string $html
* @param WC_Product $product
* @return float|string
*/
public function on_price_html($html, $product)
{
/**
* Controls whether or not member prices should use discount format when displayed
*
* @since 1.3.0
* @param bool $use_discount_format Defaults to true
*/
if (!apply_filters('wc_memberships_member_prices_use_discount_format', true)) {
return $html;
}
$tax_display_mode = get_option('woocommerce_tax_display_shop');
$this->disable_price_adjustments();
$base_price = 'incl' == $tax_display_mode ? $product->get_price_including_tax() : $product->get_price_excluding_tax();
$product_id = $product->is_type('variation') ? $product->variation_id : $product->id;
$this->enable_price_adjustments();
if (!$this->has_discounted_price($base_price, $product_id)) {
return $html;
}
/**
* Controls whether or not member prices should display sale prices as well
*
* @since 1.3.0
* @param bool $display_sale_price Defaults to false
*/
$display_sale_price = apply_filters('wc_memberships_member_prices_display_sale_price', false);
add_filter('woocommerce_get_variation_prices_hash', array($this, 'nonmember_variation_prices_hash'), 10, 3);
if (!$display_sale_price) {
add_filter('woocommerce_product_is_on_sale', array($this, 'disable_sale_price'));
}
$this->disable_price_adjustments();
$this->disable_price_html_adjustments();
$_html = $product->get_price_html();
$this->enable_price_adjustments();
$this->enable_price_html_adjustments();
remove_filter('woocommerce_get_variation_prices_hash', array($this, 'nonmember_variation_prices_hash'));
if (!$display_sale_price) {
remove_filter('woocommerce_product_is_on_sale', array($this, 'disable_sale_price'));
}
if ($html != $_html) {
$html = '<del>' . $_html . '</del> <ins> ' . $html . '</ins>';
}
return $html;
}
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:52,代码来源:class-wc-memberships-member-discounts.php
示例12: get_composited_product_price
/**
* Get the shop price of a product incl or excl tax, depending on the 'woocommerce_tax_display_shop' setting.
*
* @param WC_Product $product
* @param double $price
* @return double
*/
public function get_composited_product_price($product, $price = '')
{
if (!$price) {
return $price;
}
if (wc_cp_tax_display_shop() === 'excl') {
$product_price = $product->get_price_excluding_tax(1, $price);
} else {
$product_price = $product->get_price_including_tax(1, $price);
}
return $product_price;
}
示例13: insert_meta_tags
//.........这里部分代码省略.........
if (trim($this->post->post_excerpt) != '') {
//If there's an excerpt that's what we'll use
$fb_desc = trim($this->post->post_excerpt);
} else {
//If not we grab it from the content
$fb_desc = trim($this->post->post_content);
}
if (intval($this->options['fb_image_show']) == 1 || intval($this->options['fb_image_show_schema']) == 1 || intval($this->options['fb_image_show_twitter']) == 1) {
$thumbdone = false;
if (intval($this->options['fb_image_use_featured']) == 1) {
//Featured
if ($id_attachment = get_post_thumbnail_id($this->post->ID)) {
//There's a featured/thumbnail image for this listing
$fb_image = wp_get_attachment_url($id_attachment, false);
$thumbdone = true;
} else {
}
}
if (!$thumbdone) {
//Main image loaded
if ($thumbnail_id = wpbdp_listings_api()->get_thumbnail_id($this->post->ID)) {
$fb_image = wp_get_attachment_url($thumbnail_id, false);
$thumbdone = true;
}
}
}
}
}
// WooCommerce
if ($webdados_fb->is_woocommerce_active() && is_product()) {
$fb_type = 'product';
$product = new WC_Product($post->ID);
//Price
$fb_additional_tags['property']['og_price_amount'] = array($product->get_price_including_tax());
if (function_exists('get_woocommerce_currency')) {
$fb_additional_tags['property']['og_price_currency'] = array(get_woocommerce_currency());
}
$fb_additional_tags['name']['twitter_label1'] = array(__('Price', 'wd-fb-og'));
if (function_exists('get_woocommerce_currency')) {
$fb_additional_tags['name']['twitter_data1'] = array($product->get_price_including_tax() . ' ' . get_woocommerce_currency());
}
//Additional product images?
if (intval($this->options['fb_image_show']) == 1 && $this->options['fb_wc_useproductgallery'] == 1) {
if ($attachment_ids = $product->get_gallery_attachment_ids()) {
foreach ($attachment_ids as $attachment_id) {
if ($image_link = wp_get_attachment_url($attachment_id)) {
if (trim($image_link) != '') {
$fb_image_additional[] = array('fb_image' => trim($image_link), 'png_overlay' => intval($this->options['fb_wc_usepg_png_overlay']) ? true : false);
}
}
}
}
}
}
} else {
//Other pages - Defaults
$fb_title = esc_attr(wp_strip_all_tags(stripslashes(get_bloginfo('name')), true));
$fb_url = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
//Not really canonical but will work for now
$fb_image = trim($this->options['fb_image']);
$this->options['fb_article_sections_show'] = 0;
$this->options['fb_article_dates_show'] = 0;
$this->options['fb_author_show'] = 0;
$this->options['fb_author_show_meta'] = 0;
$this->options['fb_author_show_linkrelgp'] = 0;
$this->options['fb_author_show_twitter'] = 0;