public function on_display_cart_item_price_html($html, $cart_item, $cart_item_key)
 {
     if ($this->is_cart_item_discounted($cart_item)) {
         $_product = $cart_item['data'];
         if (function_exists('get_product')) {
             $price_adjusted = get_option('woocommerce_tax_display_cart') == 'excl' ? $_product->get_price_excluding_tax() : $_product->get_price_including_tax();
             $price_base = $cart_item['discounts']['display_price'];
         } else {
             if (get_option('woocommerce_display_cart_prices_excluding_tax') == 'yes') {
                 $price_adjusted = $cart_item['data']->get_price_excluding_tax();
                 $price_base = $cart_item['discounts']['display_price'];
             } else {
                 $price_adjusted = $cart_item['data']->get_price();
                 $price_base = $cart_item['discounts']['display_price'];
             }
         }
         if (!empty($price_adjusted) || $price_adjusted === 0 || $price_adjusted === 0.0) {
             if (apply_filters('wc_dynamic_pricing_use_discount_format', true)) {
                 $html = '<del>' . WC_Dynamic_Pricing_Compatibility::wc_price($price_base) . '</del><ins> ' . WC_Dynamic_Pricing_Compatibility::wc_price($price_adjusted) . '</ins>';
             } else {
                 $html = '<span class="amount">' . WC_Dynamic_Pricing_Compatibility::wc_price($price_adjusted) . '</span>';
             }
         }
     }
     return $html;
 }
    public function on_product_write_panel_tabs()
    {
        if (WC_Dynamic_Pricing_Compatibility::is_wc_version_gte_2_3()) {
            ?>
			<li class="pricing_tab dynamic_pricing_options dynamic_pricing_options_23"><a href="#dynamic_pricing_data"><?php 
            _e('Dynamic Pricing', 'wc_pricing');
            ?>
</a></li>

		<?php 
        } elseif (WC_Dynamic_Pricing_Compatibility::is_wc_version_gte_2_1()) {
            ?>
	
			<li class="pricing_tab dynamic_pricing_options dynamic_pricing_options_21"><a href="#dynamic_pricing_data"><?php 
            _e('Dynamic Pricing', 'wc_pricing');
            ?>
</a></li>
		<?php 
        } else {
            ?>
			<li class="pricing_tab dynamic_pricing_options"><a href="#dynamic_pricing_data"><?php 
            _e('Dynamic Pricing', 'wc_pricing');
            ?>
</a></li>

		<?php 
        }
    }
 public function on_display_cart_item_price_html($html, $cart_item, $cart_item_key)
 {
     if ($this->is_cart_item_discounted($cart_item)) {
         $_product = $cart_item['data'];
         if (function_exists('get_product')) {
             if (isset($cart_item['is_deposit']) && $cart_item['is_deposit']) {
                 $price_to_calculate = isset($cart_item['discounts']) ? $cart_item['discounts']['price_adjusted'] : $cart_item['data']->get_price();
             } else {
                 //Just use the price from the product, it has already been set during cart_loaded_from_session.
                 $price_to_calculate = $cart_item['data']->price;
             }
             $price_adjusted = get_option('woocommerce_tax_display_cart') == 'excl' ? $_product->get_price_excluding_tax(1, $price_to_calculate) : $_product->get_price_including_tax(1, $price_to_calculate);
             $price_base = $cart_item['discounts']['display_price'];
         } else {
             if (get_option('woocommerce_display_cart_prices_excluding_tax') == 'yes') {
                 $price_adjusted = $cart_item['data']->get_price_excluding_tax();
                 $price_base = $cart_item['discounts']['display_price'];
             } else {
                 $price_adjusted = $cart_item['data']->get_price();
                 $price_base = $cart_item['discounts']['display_price'];
             }
         }
         if (!empty($price_adjusted) || $price_adjusted === 0 || $price_adjusted === 0.0) {
             if (apply_filters('wc_dynamic_pricing_use_discount_format', true)) {
                 $html = '<del>' . WC_Dynamic_Pricing_Compatibility::wc_price($price_base) . '</del><ins> ' . WC_Dynamic_Pricing_Compatibility::wc_price($price_adjusted) . '</ins>';
             } else {
                 $html = '<span class="amount">' . WC_Dynamic_Pricing_Compatibility::wc_price($price_adjusted) . '</span>';
             }
         }
     }
     return $html;
 }
 protected function get_quantity_to_compare($cart_item, $collector)
 {
     global $woocommerce_pricing, $woocommerce;
     $quantity = 0;
     switch ($collector['type']) {
         case 'cart_item':
             $quantity = $cart_item['quantity'];
             break;
         case 'cat':
             if (isset($collector['args']) && isset($collector['args']['cats']) && is_array($collector['args']['cats'])) {
                 $quantity = 0;
                 if (isset($collector['args']) && isset($collector['args']['cats']) && is_array($collector['args']['cats'])) {
                     $temp_cart = WC_Dynamic_Pricing_Compatibility::WC()->cart->cart_contents;
                     foreach ($temp_cart as $lck => $cart_item) {
                         if (is_object_in_term($cart_item['product_id'], 'product_cat', $collector['args']['cats'])) {
                             if (apply_filters('woocommerce_dynamic_pricing_count_categories_for_cart_item', true, $cart_item, $lck)) {
                                 $quantity += (int) $cart_item['quantity'];
                             }
                         }
                     }
                 }
             }
             break;
         case 'product':
             if (WC_Dynamic_Pricing_Counter::get_product_count($cart_item['product_id'])) {
                 $quantity += WC_Dynamic_Pricing_Counter::get_product_count($cart_item['product_id']);
             }
             break;
         case 'variation':
             if (WC_Dynamic_Pricing_Counter::get_variation_count($cart_item['variation_id'])) {
                 $quantity += WC_Dynamic_Pricing_Counter::get_variation_count($cart_item['variation_id']);
             }
             break;
     }
     return $quantity;
 }
 public function on_price_html($html, $_product)
 {
     remove_filter('woocommerce_get_price', array($this, 'on_get_price'), 10, 2);
     $from = strstr($html, __('From', 'woocommerce')) !== false ? ' ' . __('From', 'woocommerce') . ' ' : ' ';
     $discount_price = false;
     $id = isset($_product->variation_id) ? $_product->variation_id : $_product->id;
     if (apply_filters('wc_dynamic_pricing_get_use_sale_price', true, $_product)) {
         $working_price = $_product->get_price();
     } else {
         $working_price = $_product->get_regular_price();
     }
     $tax_display_mode = get_option('woocommerce_tax_display_shop');
     $base_price = $tax_display_mode == 'incl' ? $_product->get_price_including_tax(1, $working_price) : $_product->get_price_excluding_tax(1, $working_price);
     foreach ($this->modules as $module) {
         if ($module->module_type == 'simple') {
             //Make sure we are using the price that was just discounted.
             $working_price = $discount_price ? $discount_price : $base_price;
             $working_price = $module->get_product_working_price($working_price, $_product);
             if (floatval($working_price)) {
                 $discount_price = $module->get_discounted_price_for_shop($_product, $working_price);
                 if ($discount_price && $discount_price != $base_price) {
                     $display_price = $discount_price;
                     if (apply_filters('wc_dynamic_pricing_use_discount_format', true)) {
                         if ($_product->is_type('variable')) {
                             $from = '<span class="from">' . _x('From:', 'min_price', 'woocommerce') . ' </span>';
                         }
                         $html = '<del>' . WC_Dynamic_Pricing_Compatibility::wc_price($base_price) . '</del><ins> ' . $from . WC_Dynamic_Pricing_Compatibility::wc_price($display_price) . '</ins>';
                     } else {
                         if ($_product->is_type('variable')) {
                             $from = '<span class="from">' . _x('From:', 'min_price', 'woocommerce') . ' </span>';
                         }
                         $html = $from . WC_Dynamic_Pricing_Compatibility::wc_price($display_price);
                     }
                     $html .= $_product->get_price_suffix();
                 } elseif ($discount_price === 0 || $discount_price === 0.0) {
                     $html = $_product->get_price_html_from_to($_product->regular_price, __('Free!', 'woocommerce'));
                 }
             }
         }
     }
     $this->discounted_products[$id] = $discount_price ? $discount_price : $base_price;
     add_filter('woocommerce_get_price', array($this, 'on_get_price'), 10, 2);
     return apply_filters('wc_dynamic_pricing_price_html', $html, $_product);
 }