/**
     * 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> &mdash; <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);
    }
 /**
  * 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);
 }
 /**
  * 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);
 }
 /**
  * Add this page to settings.
  */
 public function add_settings_page($pages)
 {
     if (wc_tax_enabled()) {
         return parent::add_settings_page($pages);
     } else {
         return $pages;
     }
 }
 /**
  * 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;
 }
Example #6
0
			<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>
 /**
  * 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();
 }
 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;
 }
 /**
  * Are prices inclusive of tax?
  *
  * @return bool
  */
 function wc_prices_include_tax()
 {
     return wc_tax_enabled() && get_option('woocommerce_prices_include_tax') === 'yes';
 }
 /**
  * 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();
 }
 /**
  * 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);
 }
Example #12
0
	</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)) {
    /**
     * Output the metabox
     */
    public static function output($post)
    {
        global $post, $thepostid;
        wp_nonce_field('woocommerce_save_data', 'woocommerce_meta_nonce');
        $thepostid = $post->ID;
        if ($terms = wp_get_object_terms($post->ID, 'product_type')) {
            $product_type = sanitize_title(current($terms)->name);
        } else {
            $product_type = apply_filters('default_product_type', 'simple');
        }
        $product_type_selector = apply_filters('product_type_selector', array('simple' => __('Simple product', 'woocommerce'), 'grouped' => __('Grouped product', 'woocommerce'), 'external' => __('External/Affiliate product', 'woocommerce'), 'variable' => __('Variable product', 'woocommerce')), $product_type);
        $type_box = '<label for="product-type"><select id="product-type" name="product-type"><optgroup label="' . __('Product Type', 'woocommerce') . '">';
        foreach ($product_type_selector as $value => $label) {
            $type_box .= '<option value="' . esc_attr($value) . '" ' . selected($product_type, $value, false) . '>' . esc_html($label) . '</option>';
        }
        $type_box .= '</optgroup></select></label>';
        $product_type_options = apply_filters('product_type_options', array('virtual' => array('id' => '_virtual', 'wrapper_class' => 'show_if_simple', 'label' => __('Virtual', 'woocommerce'), 'description' => __('Virtual products are intangible and aren\'t shipped.', 'woocommerce'), 'default' => 'no'), 'downloadable' => array('id' => '_downloadable', 'wrapper_class' => 'show_if_simple', 'label' => __('Downloadable', 'woocommerce'), 'description' => __('Downloadable products give access to a file upon purchase.', 'woocommerce'), 'default' => 'no')));
        foreach ($product_type_options as $key => $option) {
            $selected_value = get_post_meta($post->ID, '_' . $key, true);
            if ('' == $selected_value && isset($option['default'])) {
                $selected_value = $option['default'];
            }
            $type_box .= '<label for="' . esc_attr($option['id']) . '" class="' . esc_attr($option['wrapper_class']) . ' tips" data-tip="' . esc_attr($option['description']) . '">' . esc_html($option['label']) . ': <input type="checkbox" name="' . esc_attr($option['id']) . '" id="' . esc_attr($option['id']) . '" ' . checked($selected_value, 'yes', false) . ' /></label>';
        }
        ?>
		<div class="panel-wrap product_data">

			<span class="type_box"> &mdash; <?php 
        echo $type_box;
        ?>
</span>

			<ul class="product_data_tabs wc-tabs" style="display:none;">
				<?php 
        $product_data_tabs = apply_filters('woocommerce_product_data_tabs', array('general' => array('label' => __('General', 'woocommerce'), 'target' => 'general_product_data', 'class' => array('hide_if_grouped')), 'inventory' => array('label' => __('Inventory', 'woocommerce'), 'target' => 'inventory_product_data', 'class' => array('show_if_simple', 'show_if_variable', 'show_if_grouped')), 'shipping' => array('label' => __('Shipping', 'woocommerce'), 'target' => 'shipping_product_data', 'class' => array('hide_if_virtual', 'hide_if_grouped', 'hide_if_external')), 'linked_product' => array('label' => __('Linked Products', 'woocommerce'), 'target' => 'linked_product_data', 'class' => array()), 'attribute' => array('label' => __('Attributes', 'woocommerce'), 'target' => 'product_attributes', 'class' => array()), 'variations' => array('label' => __('Variations', 'woocommerce'), 'target' => 'variable_product_options', 'class' => array('variations_tab', 'show_if_variable')), 'advanced' => array('label' => __('Advanced', 'woocommerce'), 'target' => 'advanced_product_data', 'class' => array())));
        foreach ($product_data_tabs as $key => $tab) {
            ?>
<li class="<?php 
            echo $key;
            ?>
_options <?php 
            echo $key;
            ?>
_tab <?php 
            echo implode(' ', $tab['class']);
            ?>
">
							<a href="#<?php 
            echo $tab['target'];
            ?>
"><?php 
            echo esc_html($tab['label']);
            ?>
</a>
						</li><?php 
        }
        do_action('woocommerce_product_write_panel_tabs');
        ?>
			</ul>
			<div id="general_product_data" class="panel woocommerce_options_panel"><?php 
        echo '<div class="options_group hide_if_grouped">';
        // SKU
        if (wc_product_sku_enabled()) {
            woocommerce_wp_text_input(array('id' => '_sku', 'label' => '<abbr title="' . __('Stock Keeping Unit', 'woocommerce') . '">' . __('SKU', 'woocommerce') . '</abbr>', 'desc_tip' => 'true', 'description' => __('SKU refers to a Stock-keeping unit, a unique identifier for each distinct product and service that can be purchased.', 'woocommerce')));
        } else {
            echo '<input type="hidden" name="_sku" value="' . esc_attr(get_post_meta($thepostid, '_sku', true)) . '" />';
        }
        do_action('woocommerce_product_options_sku');
        echo '</div>';
        echo '<div class="options_group show_if_external">';
        // External URL
        woocommerce_wp_text_input(array('id' => '_product_url', 'label' => __('Product URL', 'woocommerce'), 'placeholder' => 'http://', 'description' => __('Enter the external URL to the product.', 'woocommerce')));
        // Button text
        woocommerce_wp_text_input(array('id' => '_button_text', 'label' => __('Button text', 'woocommerce'), 'placeholder' => _x('Buy product', 'placeholder', 'woocommerce'), 'description' => __('This text will be shown on the button linking to the external product.', 'woocommerce')));
        echo '</div>';
        echo '<div class="options_group pricing show_if_simple show_if_external">';
        // Price
        woocommerce_wp_text_input(array('id' => '_regular_price', 'label' => __('Regular Price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'data_type' => 'price'));
        // Special Price
        woocommerce_wp_text_input(array('id' => '_sale_price', 'data_type' => 'price', 'label' => __('Sale Price', 'woocommerce') . ' (' . get_woocommerce_currency_symbol() . ')', 'description' => '<a href="#" class="sale_schedule">' . __('Schedule', 'woocommerce') . '</a>'));
        // Special Price date range
        $sale_price_dates_from = ($date = get_post_meta($thepostid, '_sale_price_dates_from', true)) ? date_i18n('Y-m-d', $date) : '';
        $sale_price_dates_to = ($date = get_post_meta($thepostid, '_sale_price_dates_to', true)) ? date_i18n('Y-m-d', $date) : '';
        echo '<p class="form-field sale_price_dates_fields">
								<label for="_sale_price_dates_from">' . __('Sale Price Dates', 'woocommerce') . '</label>
								<input type="text" class="short" name="_sale_price_dates_from" id="_sale_price_dates_from" value="' . esc_attr($sale_price_dates_from) . '" placeholder="' . _x('From&hellip;', 'placeholder', 'woocommerce') . ' YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<input type="text" class="short" name="_sale_price_dates_to" id="_sale_price_dates_to" value="' . esc_attr($sale_price_dates_to) . '" placeholder="' . _x('To&hellip;', 'placeholder', 'woocommerce') . '  YYYY-MM-DD" maxlength="10" pattern="[0-9]{4}-(0[1-9]|1[012])-(0[1-9]|1[0-9]|2[0-9]|3[01])" />
								<a href="#" class="cancel_sale_schedule">' . __('Cancel', 'woocommerce') . '</a>
								<img class="help_tip" style="margin-top: 21px;" data-tip="' . __('The sale will end at the beginning of the set date.', 'woocommerce') . '" src="' . esc_url(WC()->plugin_url()) . '/assets/images/help.png" height="16" width="16" />
							</p>';
        do_action('woocommerce_product_options_pricing');
        echo '</div>';
        echo '<div class="options_group show_if_downloadable">';
        ?>
					<div class="form-field downloadable_files">
						<label><?php 
        _e('Downloadable Files', 'woocommerce');
        ?>
:</label>
						<table class="widefat">
							<thead>
								<tr>
									<th class="sort">&nbsp;</th>
									<th><?php 
        _e('Name', 'woocommerce');
        ?>
 <span class="tips" data-tip="<?php 
        _e('This is the name of the download shown to the customer.', 'woocommerce');
        ?>
">[?]</span></th>
									<th colspan="2"><?php 
        _e('File URL', 'woocommerce');
        ?>
 <span class="tips" data-tip="<?php 
        _e('This is the URL or absolute path to the file which customers will get access to. URLs entered here should already be encoded.', 'woocommerce');
        ?>
">[?]</span></th>
									<th>&nbsp;</th>
								</tr>
							</thead>
							<tbody>
								<?php 
        $downloadable_files = get_post_meta($post->ID, '_downloadable_files', true);
        if ($downloadable_files) {
            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')));
            do_action('woocommerce_product_options_stock_fields');
            echo '</div>';
        }
        // Stock status
        woocommerce_wp_select(array('id' => '_stock_status', 'wrapper_class' => 'hide_if_variable', 'label' => __('Stock status', 'woocommerce'), 'options' => array('instock' => __('In stock', 'woocommerce'), 'outofstock' => __('Out of stock', 'woocommerce')), 'desc_tip' => true, 'description' => __('Controls whether or not the product is listed as "in stock" or "out of stock" on the frontend.', 'woocommerce')));
        do_action('woocommerce_product_options_stock_status');
        echo '</div>';
        echo '<div class="options_group show_if_simple show_if_variable">';
        // Individual product
        woocommerce_wp_checkbox(array('id' => '_sold_individually', 'wrapper_class' => 'show_if_simple show_if_variable', 'label' => __('Sold Individually', 'woocommerce'), 'description' => __('Enable this to only allow one of this item to be bought in a single order', 'woocommerce')));
        do_action('woocommerce_product_options_sold_individually');
        echo '</div>';
        do_action('woocommerce_product_options_inventory_product_data');
        ?>

			</div>

			<div id="shipping_product_data" class="panel woocommerce_options_panel">

				<?php 
        echo '<div class="options_group">';
        // Weight
        if (wc_product_weight_enabled()) {
            woocommerce_wp_text_input(array('id' => '_weight', 'label' => __('Weight', 'woocommerce') . ' (' . get_option('woocommerce_weight_unit') . ')', 'placeholder' => wc_format_localized_decimal(0), 'desc_tip' => 'true', 'description' => __('Weight in decimal form', 'woocommerce'), 'type' => 'text', 'data_type' => 'decimal'));
        }
        // Size fields
        if (wc_product_dimensions_enabled()) {
            ?>
<p class="form-field dimensions_field">
							<label for="product_length"><?php 
            echo __('Dimensions', 'woocommerce') . ' (' . get_option('woocommerce_dimension_unit') . ')';
            ?>
</label>
							<span class="wrap">
								<input id="product_length" placeholder="<?php 
            _e('Length', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_length" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_length', true)));
            ?>
" />
								<input placeholder="<?php 
            _e('Width', 'woocommerce');
            ?>
" class="input-text wc_input_decimal" size="6" type="text" name="_width" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_width', true)));
            ?>
" />
								<input placeholder="<?php 
            _e('Height', 'woocommerce');
            ?>
" class="input-text wc_input_decimal last" size="6" type="text" name="_height" value="<?php 
            echo esc_attr(wc_format_localized_decimal(get_post_meta($thepostid, '_height', true)));
            ?>
" />
							</span>
							<img class="help_tip" data-tip="<?php 
            esc_attr_e('LxWxH in decimal form', 'woocommerce');
            ?>
" src="<?php 
            echo esc_url(WC()->plugin_url());
            ?>
/assets/images/help.png" height="16" width="16" />
						</p><?php 
        }
        do_action('woocommerce_product_options_dimensions');
        echo '</div>';
        echo '<div class="options_group">';
        // Shipping Class
        $classes = get_the_terms($thepostid, 'product_shipping_class');
        if ($classes && !is_wp_error($classes)) {
            $current_shipping_class = current($classes)->term_id;
        } else {
            $current_shipping_class = '';
        }
        $args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('No shipping class', 'woocommerce'), 'name' => 'product_shipping_class', 'id' => 'product_shipping_class', 'selected' => $current_shipping_class, 'class' => 'select short');
        ?>
<p class="form-field dimensions_field"><label for="product_shipping_class"><?php 
        _e('Shipping class', 'woocommerce');
        ?>
</label> <?php 
        wp_dropdown_categories($args);
        ?>
 <img class="help_tip" data-tip="<?php 
        esc_attr_e('Shipping classes are used by certain shipping methods to group similar products.', 'woocommerce');
        ?>
" src="<?php 
        echo esc_url(WC()->plugin_url());
        ?>
/assets/images/help.png" height="16" width="16" /></p><?php 
        do_action('woocommerce_product_options_shipping');
        echo '</div>';
        ?>

			</div>

			<div id="product_attributes" class="panel wc-metaboxes-wrapper">
				<div class="product_attributes wc-metaboxes">

					<?php 
        global $wc_product_attributes;
        // Array of defined attribute taxonomies
        $attribute_taxonomies = wc_get_attribute_taxonomies();
        // Product attributes - taxonomies and custom, ordered, with visibility and variation attributes set
        $attributes = maybe_unserialize(get_post_meta($thepostid, '_product_attributes', true));
        // Output All Set Attributes
        if (!empty($attributes)) {
            $attribute_keys = array_keys($attributes);
            $attribute_total = sizeof($attribute_keys);
            for ($i = 0; $i < $attribute_total; $i++) {
                $attribute = $attributes[$attribute_keys[$i]];
                $position = empty($attribute['position']) ? 0 : absint($attribute['position']);
                $taxonomy = '';
                $metabox_class = array();
                if ($attribute['is_taxonomy']) {
                    $taxonomy = $attribute['name'];
                    if (!taxonomy_exists($taxonomy)) {
                        continue;
                    }
                    $attribute_taxonomy = $wc_product_attributes[$taxonomy];
                    $metabox_class[] = 'taxonomy';
                    $metabox_class[] = $taxonomy;
                    $attribute_label = wc_attribute_label($taxonomy);
                } else {
                    $attribute_label = apply_filters('woocommerce_attribute_label', $attribute['name'], $attribute['name']);
                }
                include 'views/html-product-attribute.php';
            }
        }
        ?>
				</div>

				<p class="toolbar">
					<button type="button" class="button button-primary add_attribute"><?php 
        _e('Add', 'woocommerce');
        ?>
</button>
					<select name="attribute_taxonomy" class="attribute_taxonomy">
						<option value=""><?php 
        _e('Custom product attribute', 'woocommerce');
        ?>
</option>
						<?php 
        if ($attribute_taxonomies) {
            foreach ($attribute_taxonomies as $tax) {
                $attribute_taxonomy_name = wc_attribute_taxonomy_name($tax->attribute_name);
                $label = $tax->attribute_label ? $tax->attribute_label : $tax->attribute_name;
                echo '<option value="' . esc_attr($attribute_taxonomy_name) . '">' . esc_html($label) . '</option>';
            }
        }
        ?>
					</select>

					<button type="button" class="button save_attributes"><?php 
        _e('Save attributes', 'woocommerce');
        ?>
</button>
				</p>
				<?php 
        do_action('woocommerce_product_options_attributes');
        ?>
			</div>
			<div id="linked_product_data" class="panel woocommerce_options_panel">

				<div class="options_group">

					<p class="form-field">
						<label for="upsell_ids"><?php 
        _e('Up-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="upsell_ids" name="upsell_ids" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_upsell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name()));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<p class="form-field">
						<label for="crosssell_ids"><?php 
        _e('Cross-Sells', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="crosssell_ids" name="crosssell_ids" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $product_ids = array_filter(array_map('absint', (array) get_post_meta($post->ID, '_crosssell_ids', true)));
        $json_ids = array();
        foreach ($product_ids as $product_id) {
            $product = wc_get_product($product_id);
            if (is_object($product)) {
                $json_ids[$product_id] = wp_kses_post(html_entity_decode($product->get_formatted_name()));
            }
        }
        echo esc_attr(json_encode($json_ids));
        ?>
" value="<?php 
        echo implode(',', array_keys($json_ids));
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Cross-sells are products which you promote in the cart, based on the current product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>
				</div>

				<div class="options_group grouping show_if_simple show_if_external">

					<p class="form-field">
						<label for="parent_id"><?php 
        _e('Grouping', 'woocommerce');
        ?>
</label>
						<input type="hidden" class="wc-product-search" style="width: 50%;" id="parent_id" name="parent_id" data-placeholder="<?php 
        _e('Search for a product&hellip;', 'woocommerce');
        ?>
" data-action="woocommerce_json_search_grouped_products" data-allow_clear="true" data-multiple="false" data-exclude="<?php 
        echo intval($post->ID);
        ?>
" data-selected="<?php 
        $parent_id = absint($post->post_parent);
        if ($parent_id) {
            $parent = wc_get_product($parent_id);
            if (is_object($parent)) {
                $parent_title = wp_kses_post(html_entity_decode($parent->get_formatted_name()));
            }
            echo esc_attr($parent_title);
        }
        ?>
" value="<?php 
        echo $parent_id ? $parent_id : '';
        ?>
" /> <img class="help_tip" data-tip='<?php 
        _e('Set this option to make this product part of a grouped product.', 'woocommerce');
        ?>
' src="<?php 
        echo WC()->plugin_url();
        ?>
/assets/images/help.png" height="16" width="16" />
					</p>

					<?php 
        woocommerce_wp_hidden_input(array('id' => 'previous_parent_id', 'value' => absint($post->post_parent)));
        do_action('woocommerce_product_options_grouping');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_related');
        ?>
			</div>

			<div id="advanced_product_data" class="panel woocommerce_options_panel">

				<div class="options_group hide_if_external">
					<?php 
        // Purchase note
        woocommerce_wp_textarea_input(array('id' => '_purchase_note', 'label' => __('Purchase Note', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Enter an optional note to send the customer after purchase.', 'woocommerce')));
        ?>
				</div>

				<div class="options_group">
					<?php 
        // menu_order
        woocommerce_wp_text_input(array('id' => 'menu_order', 'label' => __('Menu order', 'woocommerce'), 'desc_tip' => 'true', 'description' => __('Custom ordering position.', 'woocommerce'), 'value' => intval($post->menu_order), 'type' => 'number', 'custom_attributes' => array('step' => '1')));
        ?>
				</div>

				<div class="options_group reviews">
					<?php 
        woocommerce_wp_checkbox(array('id' => 'comment_status', 'label' => __('Enable reviews', 'woocommerce'), 'cbvalue' => 'open', 'value' => esc_attr($post->comment_status)));
        do_action('woocommerce_product_options_reviews');
        ?>
				</div>

				<?php 
        do_action('woocommerce_product_options_advanced');
        ?>

			</div>

			<?php 
        self::output_variations();
        do_action('woocommerce_product_data_panels');
        do_action('woocommerce_product_write_panels');
        // _deprecated
        ?>

			<div class="clear"></div>

		</div>
		<?php 
    }
Example #14
0
do_action('woocommerce_admin_order_item_values', null, $refund, absint($refund->id));
?>

	<td class="item_cost" width="1%">&nbsp;</td>
	<td class="quantity" width="1%">&nbsp;</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>
Example #15
0
" />
			</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()));
 /**
  * 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();
     }
 }
Example #17
0
 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);
 }
/**
 * 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);
}
Example #19
0
 /**
  * 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);
 }
 /**
  * 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;
 }
 /**
  * Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.
  *
  * @since 2.2
  * @param  bool $and_taxes Calc taxes if true.
  * @return float calculated grand total.
  */
 public function calculate_totals($and_taxes = true)
 {
     $cart_subtotal = 0;
     $cart_total = 0;
     $fee_total = 0;
     $cart_subtotal_tax = 0;
     $cart_total_tax = 0;
     if ($and_taxes && wc_tax_enabled()) {
         $this->calculate_taxes();
     }
     // line items
     foreach ($this->get_items() as $item) {
         $cart_subtotal += $item->get_subtotal();
         $cart_total += $item->get_total();
         $cart_subtotal_tax += $item->get_subtotal_tax();
         $cart_total_tax += $item->get_total_tax();
     }
     $this->calculate_shipping();
     foreach ($this->get_fees() as $item) {
         $fee_total += $item->get_total();
     }
     $grand_total = round($cart_total + $fee_total + $this->get_shipping_total() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals());
     $this->set_discount_total($cart_subtotal - $cart_total);
     $this->set_discount_tax($cart_subtotal_tax - $cart_total_tax);
     $this->set_total($grand_total);
     $this->save();
     return $grand_total;
 }
 /**
  * Create a scheduled order
  * @param  string $payment_date
  * @param  int $original_order_id
  */
 public static function create_order($payment_date, $original_order_id, $payment_number, $item, $status = '')
 {
     $original_order = wc_get_order($original_order_id);
     $new_order = wc_create_order(array('status' => $status, 'customer_id' => $original_order->get_user_id(), 'customer_note' => $original_order->customer_note, 'created_via' => 'wc_deposits'));
     if (is_wp_error($new_order)) {
         $original_order->add_order_note(sprintf(__('Error: Unable to create follow up payment (%s)', 'woocommerce-deposits'), $scheduled_order->get_error_message()));
     } else {
         $new_order->set_address(array('first_name' => $original_order->billing_first_name, 'last_name' => $original_order->billing_last_name, 'company' => $original_order->billing_company, 'address_1' => $original_order->billing_address_1, 'address_2' => $original_order->billing_address_2, 'city' => $original_order->billing_city, 'state' => $original_order->billing_state, 'postcode' => $original_order->billing_postcode, 'country' => $original_order->billing_country, 'email' => $original_order->billing_email, 'phone' => $original_order->billing_phone), 'billing');
         $new_order->set_address(array('first_name' => $original_order->shipping_first_name, 'last_name' => $original_order->shipping_last_name, 'company' => $original_order->shipping_company, 'address_1' => $original_order->shipping_address_1, 'address_2' => $original_order->shipping_address_2, 'city' => $original_order->shipping_city, 'state' => $original_order->shipping_state, 'postcode' => $original_order->shipping_postcode, 'country' => $original_order->shipping_country), 'shipping');
         // Handle items
         $item_id = $new_order->add_product($item['product'], $item['qty'], array('totals' => array('subtotal' => $item['amount'], 'total' => $item['amount'], 'subtotal_tax' => 0, 'tax' => 0)));
         woocommerce_add_order_item_meta($item_id, '_original_order_id', $original_order_id);
         wc_update_order_item($item_id, array('order_item_name' => sprintf(__('Payment #%d for %s'), $payment_number, $item['product']->get_title())));
         $new_order->calculate_totals(wc_tax_enabled());
         // Set future date and parent
         $new_order_post = array('ID' => $new_order->id, 'post_date' => date('Y-m-d H:i:s', $payment_date), 'post_parent' => $original_order_id);
         wp_update_post($new_order_post);
         do_action('woocommerce_deposits_create_order', $new_order->id);
         return $new_order->id;
     }
 }
				</div>
			<?php 
}
?>
			<div>
				<p class="form-row hide_if_variation_virtual form-row-full"><label><?php 
_e('Shipping class:', 'woocommerce');
?>
</label> <?php 
$args = array('taxonomy' => 'product_shipping_class', 'hide_empty' => 0, 'show_option_none' => __('Same as parent', 'woocommerce'), 'name' => 'variable_shipping_class[' . $loop . ']', 'id' => '', 'selected' => isset($shipping_class) ? esc_attr($shipping_class) : '', 'echo' => 0);
echo wp_dropdown_categories($args);
?>
</p>
				<p class="form-row form-row-full">
					<?php 
if (wc_tax_enabled()) {
    ?>
					<label><?php 
    _e('Tax class:', 'woocommerce');
    ?>
</label>
					<select name="variable_tax_class[<?php 
    echo $loop;
    ?>
]">
						<option value="parent" <?php 
    selected(is_null($_tax_class), true);
    ?>
><?php 
    _e('Same as parent', 'woocommerce');
    ?>
/**
 * Get order total html including inc tax if needed
 *
 * @access public
 */
function wc_cart_totals_order_total_html()
{
    $value = '<strong>' . WC()->cart->get_total() . '</strong> ';
    // If prices are tax inclusive, show taxes here
    if (wc_tax_enabled() && WC()->cart->tax_display_cart == 'incl') {
        $tax_string_array = array();
        if (get_option('woocommerce_tax_total_display') == 'itemized') {
            foreach (WC()->cart->get_tax_totals() as $code => $tax) {
                $tax_string_array[] = sprintf('%s %s', $tax->formatted_amount, $tax->label);
            }
        } else {
            $tax_string_array[] = sprintf('%s %s', wc_price(WC()->cart->get_taxes_total(true, true)), WC()->countries->tax_or_vat());
        }
        if (!empty($tax_string_array)) {
            $value .= '<small class="includes_tax">' . sprintf(__('(Includes %s)', 'woocommerce'), implode(', ', $tax_string_array)) . '</small>';
        }
    }
    echo apply_filters('woocommerce_cart_totals_order_total_html', $value);
}
 /**
  * Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.
  *
  * @since 2.2
  * @param  $and_taxes bool Calc taxes if true
  * @return float calculated grand total
  */
 public function calculate_totals($and_taxes = true)
 {
     $cart_subtotal = 0;
     $cart_total = 0;
     $fee_total = 0;
     $cart_subtotal_tax = 0;
     $cart_total_tax = 0;
     if ($and_taxes && wc_tax_enabled()) {
         $this->calculate_taxes();
     }
     // line items
     foreach ($this->get_items() as $item) {
         $cart_subtotal += wc_format_decimal(isset($item['line_subtotal']) ? $item['line_subtotal'] : 0);
         $cart_total += wc_format_decimal(isset($item['line_total']) ? $item['line_total'] : 0);
         $cart_subtotal_tax += wc_format_decimal(isset($item['line_subtotal_tax']) ? $item['line_subtotal_tax'] : 0);
         $cart_total_tax += wc_format_decimal(isset($item['line_tax']) ? $item['line_tax'] : 0);
     }
     $this->calculate_shipping();
     foreach ($this->get_fees() as $item) {
         $fee_total += $item['line_total'];
     }
     $this->set_total($cart_subtotal - $cart_total, 'cart_discount');
     $this->set_total($cart_subtotal_tax - $cart_total_tax, 'cart_discount_tax');
     $grand_total = round($cart_total + $fee_total + $this->get_total_shipping() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals());
     $this->set_total($grand_total, 'total');
     return $grand_total;
 }
 /**
  * Get totals for display on pages and in emails.
  *
  * @return array
  */
 public function get_order_item_totals($tax_display = '')
 {
     if (!$tax_display) {
         $tax_display = $this->tax_display_cart;
     }
     $total_rows = array();
     if ($subtotal = $this->get_subtotal_to_display(false, $tax_display)) {
         $total_rows['cart_subtotal'] = array('label' => __('Subtotal:', 'woocommerce'), 'value' => $subtotal);
     }
     if ($this->get_total_discount() > 0) {
         $total_rows['discount'] = array('label' => __('Discount:', 'woocommerce'), 'value' => '-' . $this->get_discount_to_display());
     }
     if ($this->get_shipping_method()) {
         $total_rows['shipping'] = array('label' => __('Shipping:', 'woocommerce'), 'value' => $this->get_shipping_to_display());
     }
     if ($fees = $this->get_fees()) {
         foreach ($fees as $id => $fee) {
             if (apply_filters('woocommerce_get_order_item_totals_excl_free_fees', $fee['line_total'] + $fee['line_tax'] == 0, $id)) {
                 continue;
             }
             if ('excl' == $tax_display) {
                 $total_rows['fee_' . $id] = array('label' => $fee['name'] . ':', 'value' => wc_price($fee['line_total'], array('currency' => $this->get_order_currency())));
             } else {
                 $total_rows['fee_' . $id] = array('label' => $fee['name'] . ':', 'value' => wc_price($fee['line_total'] + $fee['line_tax'], array('currency' => $this->get_order_currency())));
             }
         }
     }
     // Tax for tax exclusive prices
     if ('excl' == $tax_display) {
         if (get_option('woocommerce_tax_total_display') == 'itemized') {
             foreach ($this->get_tax_totals() as $code => $tax) {
                 $total_rows[sanitize_title($code)] = array('label' => $tax->label . ':', 'value' => $tax->formatted_amount);
             }
         } else {
             $total_rows['tax'] = array('label' => WC()->countries->tax_or_vat() . ':', 'value' => wc_price($this->get_total_tax(), array('currency' => $this->get_order_currency())));
         }
     }
     if ($this->get_total() > 0 && $this->payment_method_title) {
         $total_rows['payment_method'] = array('label' => __('Payment Method:', 'woocommerce'), 'value' => $this->payment_method_title);
     }
     // Order total display
     $order_total = $this->get_total();
     $total_refunded = $this->get_total_refunded();
     $total_string = '';
     $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 ? 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_string_array[] = sprintf('%s %s', wc_price($this->get_total_tax() - $this->get_total_tax_refunded(), 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) {
         $total_string = '<del>' . strip_tags($this->get_formatted_order_total()) . '</del> <ins>';
         $total_string .= wc_price($order_total - $total_refunded, array('currency' => $this->get_order_currency()));
         $total_string .= $tax_string;
         $total_string .= '</ins>';
     } else {
         $total_string = $this->get_formatted_order_total() . $tax_string;
     }
     $total_rows['order_total'] = array('label' => __('Total:', 'woocommerce'), 'value' => $total_string);
     return apply_filters('woocommerce_get_order_item_totals', $total_rows, $this);
 }
Example #27
0
			<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() && WC()->cart->tax_display_cart === 'excl') {
    ?>
			<?php 
    if (get_option('woocommerce_tax_total_display') === 'itemized') {
        ?>
				<?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>
</button>
		<?php 
} else {
    ?>
			<span class="description tips" data-tip="<?php 
    esc_attr_e('To edit this order change the status back to "Pending"', 'woocommerce');
    ?>
"><?php 
    _e('This order has been paid for and is no longer editable', 'woocommerce');
    ?>
</span>
		<?php 
}
?>
		<?php 
if (wc_tax_enabled() && $order->is_editable()) {
    ?>
			<button type="button" class="button add-order-tax"><?php 
    _e('Add Tax', 'woocommerce');
    ?>
</button>
		<?php 
}
?>
		<?php 
if (0 < $order->get_total() - $order->get_total_refunded() || 0 < absint($order->get_item_count() - $order->get_item_count_refunded())) {
    ?>
			<button type="button" class="button refund-items"><?php 
    _e('Refund', 'woocommerce');
    ?>
</button>
Example #29
0
	</tbody>
	<tfoot>
	<?php 
$has_refund = false;
if ($total_refunded = $order->get_total_refunded()) {
    $has_refund = true;
}
if ($totals = $order->get_order_item_totals()) {
    foreach ($totals as $key => $total) {
        $value = $total['value'];
        // Check for refund
        if ($has_refund && $key === 'order_total') {
            $refunded_tax_del = '';
            $refunded_tax_ins = '';
            // Tax for inclusive prices
            if (wc_tax_enabled() && 'incl' == $order->tax_display_cart) {
                $tax_del_array = array();
                $tax_ins_array = array();
                if ('itemized' == get_option('woocommerce_tax_total_display')) {
                    foreach ($order->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 - $order->get_total_tax_refunded_by_rate_id($tax->rate_id), array('currency' => $order->get_order_currency())), $tax->label);
                    }
                } else {
                    $tax_del_array[] = sprintf('%s %s', wc_price($order->get_total_tax(), array('currency' => $order->get_order_currency())), WC()->countries->tax_or_vat());
                    $tax_ins_array[] = sprintf('%s %s', wc_price($order->get_total_tax() - $order->get_total_tax_refunded(), array('currency' => $order->get_order_currency())), WC()->countries->tax_or_vat());
                }
                if (!empty($tax_del_array)) {
                    $refunded_tax_del .= ' ' . sprintf(__('(Includes %s)', 'woocommerce'), implode(', ', $tax_del_array));
                }
                if (!empty($tax_ins_array)) {
<?php

/**
 * Shows an order item
 *
 * @var object $item The item being displayed
 * @var int $item_id The id of the item being displayed
 */
if (!defined('ABSPATH')) {
    exit;
}
$product_link = $_product ? admin_url('post.php?post=' . absint($_product->id) . '&action=edit') : '';
$thumbnail = $_product ? apply_filters('woocommerce_admin_order_item_thumbnail', $_product->get_image('thumbnail', array('title' => ''), false), $item_id, $item) : '';
$tax_data = empty($legacy_order) && wc_tax_enabled() ? maybe_unserialize(isset($item['line_tax_data']) ? $item['line_tax_data'] : '') : false;
$item_total = isset($item['line_total']) ? esc_attr(wc_format_localized_price($item['line_total'])) : '';
$item_subtotal = isset($item['line_subtotal']) ? esc_attr(wc_format_localized_price($item['line_subtotal'])) : '';
?>
<tr class="item <?php 
echo apply_filters('woocommerce_admin_html_order_item_class', !empty($class) ? $class : '', $item);
?>
" data-order_item_id="<?php 
echo $item_id;
?>
">
	<td class="thumb">
		<?php 
echo '<div class="wc-order-item-thumbnail">' . wp_kses_post($thumbnail) . '</div>';
?>
	</td>
	<td class="name" data-sort-value="<?php 
echo esc_attr($item['name']);