本文整理汇总了PHP中wc_tax_enabled函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_tax_enabled函数的具体用法?PHP wc_tax_enabled怎么用?PHP wc_tax_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_tax_enabled函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_woocommerce_totals
/**
* Return the order totals listing
*/
public function get_woocommerce_totals()
{
// get totals and remove the semicolon
$totals = apply_filters('wpo_wcpdf_raw_order_totals', $this->export->order->get_order_item_totals(), $this->export->order);
// remove the colon for every label
foreach ($totals as $key => $total) {
$label = $total['label'];
$colon = strrpos($label, ':');
if ($colon !== false) {
$label = substr_replace($label, '', $colon, 1);
}
$totals[$key]['label'] = $label;
}
// WC2.4 fix order_total for refunded orders
if (version_compare(WOOCOMMERCE_VERSION, '2.4', '>=') && isset($totals['order_total'])) {
$tax_display = $this->export->order->tax_display_cart;
$totals['order_total']['value'] = wc_price($this->export->order->get_total(), array('currency' => $this->export->order->get_order_currency()));
$order_total = $this->export->order->get_total();
$tax_string = '';
// Tax for inclusive prices
if (wc_tax_enabled() && 'incl' == $tax_display) {
$tax_string_array = array();
if ('itemized' == get_option('woocommerce_tax_total_display')) {
foreach ($this->export->order->get_tax_totals() as $code => $tax) {
$tax_amount = $tax->formatted_amount;
$tax_string_array[] = sprintf('%s %s', $tax_amount, $tax->label);
}
} else {
$tax_string_array[] = sprintf('%s %s', wc_price($this->export->order->get_total_tax() - $this->export->order->get_total_tax_refunded(), array('currency' => $this->export->order->get_order_currency())), WC()->countries->tax_or_vat());
}
if (!empty($tax_string_array)) {
$tax_string = ' ' . sprintf(__('(Includes %s)', 'woocommerce'), implode(', ', $tax_string_array));
}
}
$totals['order_total']['value'] .= $tax_string;
}
return apply_filters('wpo_wcpdf_woocommerce_totals', $totals, $this->export->order);
}
开发者ID:congkv,项目名称:wordpress,代码行数:41,代码来源:woocommerce-pdf-invoices-packingslips.php
示例2: get_formatted_order_total
/**
* Gets order total - formatted for display.
*
* @return string
*/
public function get_formatted_order_total($tax_display = '', $display_refunded = true)
{
$formatted_total = wc_price($this->get_total(), array('currency' => $this->get_order_currency()));
$order_total = $this->get_total();
$total_refunded = $this->get_total_refunded();
$tax_string = '';
// Tax for inclusive prices
if (wc_tax_enabled() && 'incl' == $tax_display) {
$tax_string_array = array();
if ('itemized' == get_option('woocommerce_tax_total_display')) {
foreach ($this->get_tax_totals() as $code => $tax) {
$tax_amount = $total_refunded && $display_refunded ? wc_price(WC_Tax::round($tax->amount - $this->get_total_tax_refunded_by_rate_id($tax->rate_id)), array('currency' => $this->get_order_currency())) : $tax->formatted_amount;
$tax_string_array[] = sprintf('%s %s', $tax_amount, $tax->label);
}
} else {
$tax_amount = $total_refunded && $display_refunded ? $this->get_total_tax() - $this->get_total_tax_refunded() : $this->get_total_tax();
$tax_string_array[] = sprintf('%s %s', wc_price($tax_amount, array('currency' => $this->get_order_currency())), WC()->countries->tax_or_vat());
}
if (!empty($tax_string_array)) {
$tax_string = ' ' . sprintf(__('(Includes %s)', 'woocommerce'), implode(', ', $tax_string_array));
}
}
if ($total_refunded && $display_refunded) {
$formatted_total = '<del>' . strip_tags($formatted_total) . '</del> <ins>' . wc_price($order_total - $total_refunded, array('currency' => $this->get_order_currency())) . $tax_string . '</ins>';
} else {
$formatted_total .= $tax_string;
}
return apply_filters('woocommerce_get_formatted_order_total', $formatted_total, $this);
}
开发者ID:magicdustwebsites,项目名称:woocommerce,代码行数:34,代码来源:class-wc-order.php
示例3: add_settings_page
/**
* Add this page to settings.
*/
public function add_settings_page($pages)
{
if (wc_tax_enabled()) {
return parent::add_settings_page($pages);
} else {
return $pages;
}
}
开发者ID:Korkey128k,项目名称:woocommerce,代码行数:11,代码来源:class-wc-settings-tax.php
示例4: widget
/**
* Output widget.
*
* @see WP_Widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
global $wp, $wp_the_query;
if (!is_post_type_archive('product') && !is_tax(get_object_taxonomies('product'))) {
return;
}
if (!$wp_the_query->post_count) {
return;
}
$min_price = isset($_GET['min_price']) ? esc_attr($_GET['min_price']) : '';
$max_price = isset($_GET['max_price']) ? esc_attr($_GET['max_price']) : '';
wp_enqueue_script('wc-price-slider');
// Find min and max price in current result set
$prices = $this->get_filtered_price();
$min = floor($prices->min_price);
$max = ceil($prices->max_price);
if ($min === $max) {
return;
}
$this->widget_start($args, $instance);
if ('' === get_option('permalink_structure')) {
$form_action = remove_query_arg(array('page', 'paged'), add_query_arg($wp->query_string, '', home_url($wp->request)));
} else {
$form_action = preg_replace('%\\/page/[0-9]+%', '', home_url(trailingslashit($wp->request)));
}
/**
* Adjust max if the store taxes are not displayed how they are stored.
* Min is left alone because the product may not be taxable.
* Kicks in when prices excluding tax are displayed including tax.
*/
if (wc_tax_enabled() && 'incl' === get_option('woocommerce_tax_display_shop') && !wc_prices_include_tax()) {
$tax_classes = array_merge(array(''), WC_Tax::get_tax_classes());
$class_max = $max;
foreach ($tax_classes as $tax_class) {
if ($tax_rates = WC_Tax::get_rates($tax_class)) {
$class_max = $max + WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($max, $tax_rates));
}
}
$max = $class_max;
}
echo '<form method="get" action="' . esc_url($form_action) . '">
<div class="price_slider_wrapper">
<div class="price_slider" style="display:none;"></div>
<div class="price_slider_amount">
<input type="text" id="min_price" name="min_price" value="' . esc_attr($min_price) . '" data-min="' . esc_attr(apply_filters('woocommerce_price_filter_widget_min_amount', $min)) . '" placeholder="' . esc_attr__('Min price', 'woocommerce') . '" />
<input type="text" id="max_price" name="max_price" value="' . esc_attr($max_price) . '" data-max="' . esc_attr(apply_filters('woocommerce_price_filter_widget_max_amount', $max)) . '" placeholder="' . esc_attr__('Max price', 'woocommerce') . '" />
<button type="submit" class="button">' . __('Filter', 'woocommerce') . '</button>
<div class="price_label" style="display:none;">
' . __('Price:', 'woocommerce') . ' <span class="from"></span> — <span class="to"></span>
</div>
' . wc_query_string_form_fields(null, array('min_price', 'max_price'), '', true) . '
<div class="clear"></div>
</div>
</div>
</form>';
$this->widget_end($args);
}
开发者ID:shivapoudel,项目名称:woocommerce,代码行数:65,代码来源:class-wc-widget-price-filter.php
示例5: get_reports
/**
* Returns the definitions for the reports to show in admin.
*
* @return array
*/
public static function get_reports()
{
$reports = array('orders' => array('title' => __('Orders', 'woocommerce'), 'reports' => array("sales_by_date" => array('title' => __('Sales by date', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "sales_by_product" => array('title' => __('Sales by product', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "sales_by_category" => array('title' => __('Sales by category', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "coupon_usage" => array('title' => __('Coupons by date', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')))), 'customers' => array('title' => __('Customers', 'woocommerce'), 'reports' => array("customers" => array('title' => __('Customers vs. Guests', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "customer_list" => array('title' => __('Customer List', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')))), 'stock' => array('title' => __('Stock', 'woocommerce'), 'reports' => array("low_in_stock" => array('title' => __('Low in stock', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "out_of_stock" => array('title' => __('Out of stock', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "most_stocked" => array('title' => __('Most Stocked', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')))));
if (wc_tax_enabled()) {
$reports['taxes'] = array('title' => __('Taxes', 'woocommerce'), 'reports' => array("taxes_by_code" => array('title' => __('Taxes by code', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report')), "taxes_by_date" => array('title' => __('Taxes by date', 'woocommerce'), 'description' => '', 'hide_title' => true, 'callback' => array(__CLASS__, 'get_report'))));
}
$reports = apply_filters('woocommerce_admin_reports', $reports);
$reports = apply_filters('woocommerce_reports_charts', $reports);
// Backwards compat
foreach ($reports as $key => $report_group) {
if (isset($reports[$key]['charts'])) {
$reports[$key]['reports'] = $reports[$key]['charts'];
}
foreach ($reports[$key]['reports'] as $report_key => $report) {
if (isset($reports[$key]['reports'][$report_key]['function'])) {
$reports[$key]['reports'][$report_key]['callback'] = $reports[$key]['reports'][$report_key]['function'];
}
}
}
return $reports;
}
开发者ID:bitoncoin,项目名称:woocommerce,代码行数:26,代码来源:class-wc-admin-reports.php
示例6: esc_html
<tr class="fee">
<th><?php
echo esc_html($fee->name);
?>
</th>
<td><?php
wc_cart_totals_fee_html($fee);
?>
</td>
</tr>
<?php
}
?>
<?php
if (wc_tax_enabled() && 'excl' === WC()->cart->tax_display_cart) {
?>
<?php
if ('itemized' === get_option('woocommerce_tax_total_display')) {
?>
<?php
foreach (WC()->cart->get_tax_totals() as $code => $tax) {
?>
<tr class="tax-rate tax-rate-<?php
echo sanitize_title($code);
?>
">
<th><?php
echo esc_html($tax->label);
?>
</th>
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:31,代码来源:review-order.php
示例7: is_taxable
/**
* Whether or not we need to calculate tax on top of the shipping rate.
* @return boolean
*/
public function is_taxable()
{
return wc_tax_enabled() && 'taxable' === $this->tax_status && !WC()->customer->is_vat_exempt();
}
开发者ID:jesusmarket,项目名称:jesusmarket,代码行数:8,代码来源:abstract-wc-shipping-method.php
示例8: get_columns_count
private function get_columns_count($taxes_count)
{
$columns_count = 4;
if ($this->template_options['bewpi_show_sku']) {
$columns_count++;
}
if ($this->template_options['bewpi_show_tax'] && wc_tax_enabled() && empty($legacy_order)) {
$columns_count += $taxes_count;
}
return $columns_count;
}
开发者ID:setasss,项目名称:woocommerce-pdf-invoices,代码行数:11,代码来源:abstract-bewpi-invoice.php
示例9: wc_prices_include_tax
/**
* Are prices inclusive of tax?
*
* @return bool
*/
function wc_prices_include_tax()
{
return wc_tax_enabled() && get_option('woocommerce_prices_include_tax') === 'yes';
}
开发者ID:abcode619,项目名称:wpstuff,代码行数:9,代码来源:wc-conditional-functions.php
示例10: price_filter_meta_query
/**
* Return a meta query for filtering by price.
* @return array
*/
private function price_filter_meta_query()
{
if (isset($_GET['max_price']) || isset($_GET['min_price'])) {
$min = isset($_GET['min_price']) ? floatval($_GET['min_price']) : 0;
$max = isset($_GET['max_price']) ? floatval($_GET['max_price']) : 9999999999.0;
/**
* Adjust if the store taxes are not displayed how they are stored.
* Max is left alone because the filter was already increased.
* Kicks in when prices excluding tax are displayed including tax.
*/
if (wc_tax_enabled() && 'incl' === get_option('woocommerce_tax_display_shop') && !wc_prices_include_tax()) {
$tax_classes = array_merge(array(''), WC_Tax::get_tax_classes());
$class_min = $min;
foreach ($tax_classes as $tax_class) {
if ($tax_rates = WC_Tax::get_rates($tax_class)) {
$class_min = $min - WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($min, $tax_rates));
}
}
$min = $class_min;
}
return array('key' => '_price', 'value' => array($min, $max), 'compare' => 'BETWEEN', 'type' => 'DECIMAL', 'price_filter' => true);
}
return array();
}
开发者ID:seriusokhatsky,项目名称:woocommerce,代码行数:28,代码来源:class-wc-query.php
示例11: is_taxable
/**
* Returns whether or not the product is taxable.
*
* @return bool
*/
public function is_taxable()
{
$taxable = $this->tax_status == 'taxable' && wc_tax_enabled() ? true : false;
return apply_filters('woocommerce_product_is_taxable', $taxable, $this);
}
开发者ID:nathanielks,项目名称:woocommerce,代码行数:10,代码来源:abstract-wc-product.php
示例12: foreach
</tbody>
<tfoot>
<?php
$has_refund = false;
if ($total_refunded = $subscription->get_total_refunded()) {
$has_refund = true;
}
if ($totals = $subscription->get_order_item_totals()) {
foreach ($totals as $key => $total) {
$value = $total['value'];
// Check for refund
if ($has_refund && 'order_total' === $key) {
$refunded_tax_del = '';
$refunded_tax_ins = '';
// Tax for inclusive prices
if (wc_tax_enabled() && 'incl' == $subscription->tax_display_cart) {
$tax_del_array = array();
$tax_ins_array = array();
if ('itemized' == get_option('woocommerce_tax_total_display')) {
foreach ($subscription->get_tax_totals() as $code => $tax) {
$tax_del_array[] = sprintf('%s %s', $tax->formatted_amount, $tax->label);
$tax_ins_array[] = sprintf('%s %s', wc_price($tax->amount - $subscription->get_total_tax_refunded_by_rate_id($tax->rate_id), array('currency' => $subscription->get_order_currency())), $tax->label);
}
} else {
$tax_del_array[] = sprintf('%s %s', wc_price($subscription->get_total_tax(), array('currency' => $subscription->get_order_currency())), WC()->countries->tax_or_vat());
$tax_ins_array[] = sprintf('%s %s', wc_price($subscription->get_total_tax() - $subscription->get_total_tax_refunded(), array('currency' => $subscription->get_order_currency())), WC()->countries->tax_or_vat());
}
if (!empty($tax_del_array)) {
$refunded_tax_del .= ' ' . sprintf(_x('(Includes %s)', 'includes tax', 'woocommerce-subscriptions'), implode(', ', $tax_del_array));
}
if (!empty($tax_ins_array)) {
开发者ID:swaroop42,项目名称:RockRose,代码行数:31,代码来源:view-subscription.php
示例13: output
//.........这里部分代码省略.........
foreach ($downloadable_files as $key => $file) {
include 'views/html-product-download.php';
}
}
?>
</tbody>
<tfoot>
<tr>
<th colspan="5">
<a href="#" class="button insert" data-row="<?php
$file = array('file' => '', 'name' => '');
ob_start();
include 'views/html-product-download.php';
echo esc_attr(ob_get_clean());
?>
"><?php
_e('Add File', 'woocommerce');
?>
</a>
</th>
</tr>
</tfoot>
</table>
</div>
<?php
// Download Limit
woocommerce_wp_text_input(array('id' => '_download_limit', 'label' => __('Download Limit', 'woocommerce'), 'placeholder' => __('Unlimited', 'woocommerce'), 'description' => __('Leave blank for unlimited re-downloads.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')));
// Expirey
woocommerce_wp_text_input(array('id' => '_download_expiry', 'label' => __('Download Expiry', 'woocommerce'), 'placeholder' => __('Never', 'woocommerce'), 'description' => __('Enter the number of days before a download link expires, or leave blank.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => '1', 'min' => '0')));
// Download Type
woocommerce_wp_select(array('id' => '_download_type', 'label' => __('Download Type', 'woocommerce'), 'description' => sprintf(__('Choose a download type - this controls the <a href="%s">schema</a>.', 'woocommerce'), 'http://schema.org/'), 'options' => array('' => __('Standard Product', 'woocommerce'), 'application' => __('Application/Software', 'woocommerce'), 'music' => __('Music', 'woocommerce'))));
do_action('woocommerce_product_options_downloads');
echo '</div>';
if (wc_tax_enabled()) {
echo '<div class="options_group show_if_simple show_if_external show_if_variable">';
// Tax
woocommerce_wp_select(array('id' => '_tax_status', 'label' => __('Tax Status', 'woocommerce'), 'options' => array('taxable' => __('Taxable', 'woocommerce'), 'shipping' => __('Shipping only', 'woocommerce'), 'none' => _x('None', 'Tax status', 'woocommerce'))));
$tax_classes = WC_Tax::get_tax_classes();
$classes_options = array();
$classes_options[''] = __('Standard', 'woocommerce');
if (!empty($tax_classes)) {
foreach ($tax_classes as $class) {
$classes_options[sanitize_title($class)] = esc_html($class);
}
}
woocommerce_wp_select(array('id' => '_tax_class', 'label' => __('Tax Class', 'woocommerce'), 'options' => $classes_options));
do_action('woocommerce_product_options_tax');
echo '</div>';
}
do_action('woocommerce_product_options_general_product_data');
?>
</div>
<div id="inventory_product_data" class="panel woocommerce_options_panel">
<?php
echo '<div class="options_group">';
if ('yes' == get_option('woocommerce_manage_stock')) {
// manage stock
woocommerce_wp_checkbox(array('id' => '_manage_stock', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Manage stock?', 'woocommerce'), 'description' => __('Enable stock management at product level', 'woocommerce')));
do_action('woocommerce_product_options_stock');
echo '<div class="stock_fields show_if_simple show_if_variable">';
// Stock
woocommerce_wp_text_input(array('id' => '_stock', 'label' => __('Stock Qty', 'woocommerce'), 'desc_tip' => true, 'description' => __('Stock quantity. If this is a variable product this value will be used to control stock for all variations, unless you define stock at variation level.', 'woocommerce'), 'type' => 'number', 'custom_attributes' => array('step' => 'any'), 'data_type' => 'stock'));
// Backorders?
woocommerce_wp_select(array('id' => '_backorders', 'label' => __('Allow Backorders?', 'woocommerce'), 'options' => array('no' => __('Do not allow', 'woocommerce'), 'notify' => __('Allow, but notify customer', 'woocommerce'), 'yes' => __('Allow', 'woocommerce')), 'desc_tip' => true, 'description' => __('If managing stock, this controls whether or not backorders are allowed. If enabled, stock quantity can go below 0.', 'woocommerce')));
开发者ID:WordCommerce,项目名称:woocommerce,代码行数:67,代码来源:class-wc-meta-box-product-data.php
示例14: do_action
do_action('woocommerce_admin_order_item_values', null, $refund, absint($refund->id));
?>
<td class="item_cost" width="1%"> </td>
<td class="quantity" width="1%"> </td>
<td class="line_cost" width="1%">
<div class="view">
<?php
echo wc_price('-' . $refund->get_refund_amount());
?>
</div>
</td>
<?php
if ((!isset($legacy_order) || !$legacy_order) && wc_tax_enabled()) {
for ($i = 0; $i < count($order_taxes); $i++) {
?>
<td class="line_tax" width="1%"></td>
<?php
}
}
?>
<td class="wc-order-edit-line-item">
<div class="wc-order-edit-line-item-actions">
<a class="delete_refund" href="#"></a>
</div>
</td>
开发者ID:slavic18,项目名称:cats,代码行数:31,代码来源:html-order-refund.php
示例15: absint
" />
</div>
</div>
<div class="refund" style="display: none;">
<input type="text" name="refund_line_total[<?php
echo absint($item_id);
?>
]" placeholder="<?php
echo wc_format_localized_price(0);
?>
" class="refund_line_total wc_input_price" />
</div>
</td>
<?php
if (empty($legacy_order) && wc_tax_enabled()) {
$line_tax_data = isset($item['line_tax_data']) ? $item['line_tax_data'] : '';
$tax_data = maybe_unserialize($line_tax_data);
foreach ($order_taxes as $tax_item) {
$tax_item_id = $tax_item['rate_id'];
$tax_item_total = isset($tax_data['total'][$tax_item_id]) ? $tax_data['total'][$tax_item_id] : '';
$tax_item_subtotal = isset($tax_data['subtotal'][$tax_item_id]) ? $tax_data['subtotal'][$tax_item_id] : '';
?>
<td class="line_tax" width="1%">
<div class="view">
<?php
if ('' != $tax_item_total) {
if (isset($tax_item_subtotal) && $tax_item_subtotal != $tax_item_total) {
echo '<del>' . wc_price(wc_round_tax_total($tax_item_subtotal), array('currency' => $order->get_order_currency())) . '</del> ';
}
echo wc_price(wc_round_tax_total($tax_item_total), array('currency' => $order->get_order_currency()));
开发者ID:ayoayco,项目名称:upbeat,代码行数:31,代码来源:html-order-item.php
示例16: getPriceRange
/**
* Get Price Range for given product ids.
* If filtered is true then return price range for filtered products,
* otherwise return price range for all products.
*
* @param boolean $filtered
* @return array
*/
public function getPriceRange($filtered = true)
{
if ($filtered === true) {
$price_range = $this->filteredProductsPriceRange();
} else {
$price_range = $this->unfilteredProductsPriceRange();
}
if (sizeof($price_range) > 2) {
$min = $max = false;
foreach ($price_range as $price) {
if ($min === false || $min > (int) $price) {
$min = floor($price);
}
if ($max === false || $max < (int) $price) {
$max = ceil($price);
}
}
// if tax enabled and shop page shows price including tax
if (wc_tax_enabled() && 'incl' === get_option('woocommerce_tax_display_shop') && !wc_prices_include_tax()) {
$tax_classes = array_merge(array(''), WC_Tax::get_tax_classes());
foreach ($tax_classes as $tax_class) {
$tax_rates = WC_Tax::get_rates($tax_class);
$class_min = $min + WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($min, $tax_rates));
$class_max = $max + WC_Tax::get_tax_total(WC_Tax::calc_exclusive_tax($max, $tax_rates));
$min = $max = false;
if ($min === false || $min > (int) $class_min) {
$min = floor($class_min);
}
if ($max === false || $max < (int) $class_max) {
$max = ceil($class_max);
}
}
}
// if WooCommerce Currency Switcher plugin is activated
if (class_exists('WOOCS')) {
$woocs = new WOOCS();
$chosen_currency = $woocs->get_woocommerce_currency();
$currencies = $woocs->get_currencies();
if (sizeof($currencies) > 0) {
foreach ($currencies as $currency) {
if ($currency['name'] == $chosen_currency) {
$rate = $currency['rate'];
}
}
$min = floor($min * $rate);
$max = ceil($max * $rate);
}
}
if ($min == $max) {
// empty array
return array();
} else {
// array with min and max values
return array($min, $max);
}
} else {
// empty array
return array();
}
}
开发者ID:shamimmoeen,项目名称:wc-ajax-product-filter,代码行数:68,代码来源:wcapf.php
示例17: wc_price
public function wc_price($price, $args = array())
{
$decimals = 2;
extract(apply_filters('wc_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => $this->decimal_sep, 'thousand_separator' => $this->thousands_sep, 'decimals' => $decimals, 'price_format' => $this->woocommerce_price_format()))));
//***
$currencies = $this->get_currencies();
if (isset($currencies[$currency])) {
if ($currencies[$currency]['hide_cents']) {
$decimals = 0;
}
}
//***
$negative = $price < 0;
$price = apply_filters('raw_woocommerce_price', floatval($negative ? $price * -1 : $price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $decimals, $decimal_separator, $thousand_separator), $price, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, get_woocommerce_currency_symbol($currency), $price);
$return = '<span class="woocs_amount">' . $formatted_price . '</span>';
if ($ex_tax_label && wc_tax_enabled()) {
$return .= ' <small class="tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:Inteleck,项目名称:hwc,代码行数:25,代码来源:index.php
示例18: wc_price
/**
* Format the price with a currency symbol.
*
* @param float $price
* @param array $args (default: array())
* @return string
*/
function wc_price($price, $args = array())
{
extract(apply_filters('wc_price_args', wp_parse_args($args, array('ex_tax_label' => false, 'currency' => '', 'decimal_separator' => wc_get_price_decimal_separator(), 'thousand_separator' => wc_get_price_thousand_separator(), 'decimals' => wc_get_price_decimals(), 'price_format' => get_woocommerce_price_format()))));
$negative = $price < 0;
$price = apply_filters('raw_woocommerce_price', floatval($negative ? $price * -1 : $price));
$price = apply_filters('formatted_woocommerce_price', number_format($price, $decimals, $decimal_separator, $thousand_separator), $price, $decimals, $decimal_separator, $thousand_separator);
if (apply_filters('woocommerce_price_trim_zeros', false) && $decimals > 0) {
$price = wc_trim_zeros($price);
}
$formatted_price = ($negative ? '-' : '') . sprintf($price_format, '<span class="woocommerce-Price-currencySymbol">' . get_woocommerce_currency_symbol($currency) . '</span>', $price);
$return = '<span class="woocommerce-Price-amount amount">' . $formatted_price . '</span>';
if ($ex_tax_label && wc_tax_enabled()) {
$return .= ' <small class="woocommerce-Price-taxLabel tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
return apply_filters('wc_price', $return, $price, $args);
}
开发者ID:coderkevin,项目名称:woocommerce,代码行数:23,代码来源:wc-formatting-functions.php
示例19: get_discounted_price
/**
* Function to apply discounts to a product and get the discounted price (before tax is applied).
*
* @param mixed $values
* @param mixed $price
* @param bool $add_totals (default: false)
* @return float price
*/
public function get_discounted_price($values, $price, $add_totals = false)
{
if (!$price) {
return $price;
}
$undiscounted_price = $price;
if (!empty($this->coupons)) {
$product = $values['data'];
foreach ($this->coupons as $code => $coupon) {
if ($coupon->is_valid() && ($coupon->is_valid_for_product($product, $values) || $coupon->is_valid_for_cart())) {
$discount_amount = $coupon->get_discount_amount('yes' === get_option('woocommerce_calc_discounts_sequentially', 'no') ? $price : $undiscounted_price, $values, true);
$discount_amount = min($price, $discount_amount);
$price = max($price - $discount_amount, 0);
// Store the totals for DISPLAY in the cart
if ($add_totals) {
$total_discount = $discount_amount * $values['quantity'];
$total_discount_tax = 0;
if (wc_tax_enabled()) {
$tax_rates = WC_Tax::get_rates($product->get_tax_class());
$taxes = WC_Tax::calc_tax($discount_amount, $tax_rates, $this->prices_include_tax);
$total_discount_tax = WC_Tax::get_tax_total($taxes) * $values['quantity'];
$total_discount = $this->prices_include_tax ? $total_discount - $total_discount_tax : $total_discount;
$this->discount_cart_tax += $total_discount_tax;
}
$this->discount_cart += $total_discount;
$this->increase_coupon_discount_amount($code, $total_discount, $total_discount_tax);
$this->increase_coupon_applied_count($code, $values['quantity']);
}
}
// If the price is 0, we can stop going through coupons because there is nothing more to discount for this product.
if (0 >= $price) {
break;
}
}
}
return apply_filters('woocommerce_get_discounted_price', $price, $values, $this);
}
开发者ID:WPprodigy,项目名称:woocommerce,代码行数:45,代码来源:class-wc-cart.php
示例20: get_line_item_args
/**
* Get line item args for paypal request
* @param WC_Order $order
* @return array
*/
protected function get_line_item_args($order)
{
/**
* Try passing a line item per product if supported
*/
if ((!wc_tax_enabled() || !wc_prices_include_tax()) && $this->prepare_line_items($order)) {
$line_item_args = $this->get_line_items();
$line_item_args['tax_cart'] = $this->number_format($order->get_total_tax(), $order);
if ($order->get_total_discount() > 0) {
$line_item_args['discount_amount_cart'] = $this->round($order->get_total_discount(), $order);
}
/**
* Send order as a single item
*
* For shipping, we longer use shipping_1 because paypal ignores it if *any* shipping rules are within paypal, and paypal ignores anything over 5 digits (999.99 is the max)
*/
} else {
$this->delete_line_items();
$all_items_name = $this->get_order_item_names($order);
$this->add_line_item($all_items_name ? $all_items_name : __('Order', 'woocommerce'), 1, $this->number_format($order->get_total() - $this->round($order->get_total_shipping() + $order->get_shipping_tax(), $order), $order), $order->get_order_number());
$this->add_line_item(sprintf(__('Shipping via %s', 'woocommerce'), ucwords($order->get_shipping_method())), 1, $this->number_format($order->get_total_shipping() + $order->get_shipping_tax(), $order));
$line_item_args = $this->get_line_items();
}
return $line_item_args;
}
开发者ID:slavic18,项目名称:cats,代码行数:30,代码来源:class-wc-gateway-paypal-request.php
注:本文中的wc_tax_enabled函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论