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;
 }
 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_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);
 }