تابع ووکامرسی wc_get_price_excluding_tax دریافت قیمت بدون احتساب مالیات

تابع ووکامرسی wc_get_price_excluding_tax – دریافت قیمت بدون احتساب مالیات
Syntax – سینتکس
(float) wc_get_price_excluding_tax( (WC_Product) $product, (array) $args = array() );
Parameters – پارامتر ها (2)
- 1- $product (WC_Product)
- 2- $args (array)
Usage – نحوه استفاده
if ( !function_exists( 'wc_get_price_excluding_tax' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php';
}
// The product.
$product = null;
// The args.
$args = array();
// NOTICE! Understand what this does before running.
$result = wc_get_price_excluding_tax($product, $args);
Defined – محل تعریف
/includes/wc-product-functions.php
function wc_get_price_excluding_tax( $product, $args = array() ) {
$args = wp_parse_args( $args, array(
'qty' => '',
'price' => '',
) );
$price = '' !== $args['price'] ? max( 0.0, (float) $args['price'] ) : $product->get_price();
$qty = '' !== $args['qty'] ? max( 0.0, (float) $args['qty'] ) : 1;
if ( '' === $price ) {
return '';
} elseif ( empty( $qty ) ) {
return 0.0;
}
if ( $product->is_taxable() && wc_prices_include_tax() ) {
$tax_rates = WC_Tax::get_base_tax_rates( $product->get_tax_class( 'unfiltered' ) );
$taxes = WC_Tax::calc_tax( $price * $qty, $tax_rates, true );
$price = WC_Tax::round( $price * $qty - array_sum( $taxes ) );
} else {
$price = $price * $qty;
}
return apply_filters( 'woocommerce_get_price_excluding_tax', $price, $qty, $product );
}
versions – نسخه ها
از نسخه : 3.0.0
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر