本文整理汇总了PHP中wc_tax_enabled函数的典型用法代码示例。如果您正苦于以下问题:PHP wc_tax_enabled函数的具体用法?PHP wc_tax_enabled怎么用?PHP wc_tax_enabled使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wc_tax_enabled函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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;
}
示例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>
示例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();
}
示例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;
}
示例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';
}
示例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();
}
示例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);
}
示例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)) {
示例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')));
示例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>
示例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()));