function vtprd_format_amt_and_adjust_for_taxes($amt, $k = null)
{
    global $post, $wpdb, $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_setup_options, $vtprd_info;
    //error_log( print_r(  'vtprd_format_amt_and_adjust_for_taxes, Begin price= ' .$amt, true ) );
    //at a minimum, format $amt
    if (get_option('woocommerce_calc_taxes') == 'no' || vtprd_maybe_customer_tax_exempt()) {
        //v1.0.7.9
        return vtprd_format_money_element($amt);
    }
    $woocommerce_prices_include_tax = get_option('woocommerce_prices_include_tax');
    $woocommerce_tax_display_cart = get_option('woocommerce_tax_display_cart');
    if ($woocommerce_prices_include_tax == 'yes') {
        switch (true) {
            case $woocommerce_tax_display_cart == 'incl':
                $amt = vtprd_format_money_element($amt);
                break;
            case $woocommerce_tax_display_cart == 'excl':
                $product_id = $vtprd_cart->cart_items[$k]->product_id;
                $amt = vtprd_get_price_excluding_tax($product_id, $amt);
                $amt = vtprd_format_money_element($amt);
                break;
        }
    } else {
        // price does NOT include tax
        switch (true) {
            case $woocommerce_tax_display_cart == 'excl':
                $amt = vtprd_format_money_element($amt);
                break;
            case $woocommerce_tax_display_cart == 'incl':
                $qty = 1;
                $_tax = new WC_Tax();
                $product = get_product($vtprd_cart->cart_items[$k]->product_id);
                $tax_rates = $_tax->get_rates($product->get_tax_class());
                $taxes = $_tax->calc_tax($amt * $qty, $tax_rates, false);
                $tax_amount = $_tax->get_tax_total($taxes);
                $amt = round($amt * $qty + $tax_amount, absint(get_option('woocommerce_price_num_decimals')));
                $amt = vtprd_format_money_element($amt);
                break;
        }
    }
    $amt .= vtprd_maybe_load_incl_excl_vat_lit();
    return $amt;
}
function vtprd_show_product_you_save($product_id = null)
{
    global $post, $vtprd_setup_options, $vtprd_info;
    //can only be executed when WPEC version less than 3.8.9
    if (!(version_compare(strval('3.8.9'), strval(WPSC_VERSION), '>') == 1)) {
        //'==1' = 2nd value is lower
        return;
    }
    $pct = vtprd_get_single_product_you_save_pct($product_id);
    $amt = $vtprd_info['product_session_info']['product_yousave_total_amt'];
    $amt = vtprd_format_money_element($amt);
    //CUSTOM function created by CUSTOMER
    if (function_exists('custom_show_single_product_you_save')) {
        custom_show_single_product_you_save($product_id, $pct, $amt);
        return;
    }
    if ($pct) {
        ?>
				<p class="pricedisplay product_<?php 
        echo wpsc_the_product_id();
        ?>
"><?php 
        _e('You save', 'wpsc');
        ?>
: <span class="yousave" id="yousave_<?php 
        echo wpsc_the_product_id();
        ?>
"><?php 
        echo $amt;
        ?>
! (<?php 
        echo $pct;
        ?>
%)</span></p>
			<?php 
    } else {
        //original code from wpsc-single_product.php
        ?>
      
        <?php 
        if (wpsc_product_on_special()) {
            ?>
					<p class="pricedisplay product_<?php 
            echo wpsc_the_product_id();
            ?>
"><?php 
            _e('You save', 'wpsc');
            ?>
: <span class="yousave" id="yousave_<?php 
            echo wpsc_the_product_id();
            ?>
"><?php 
            echo wpsc_currency_display(wpsc_you_save('type=amount'), array('html' => false));
            ?>
! (<?php 
            echo wpsc_you_save();
            ?>
%)</span></p>
				<?php 
        }
        ?>
      
      <?php 
    }
    return;
}
 public function vtprd_show_discount_amt()
 {
     global $vtprd_rule;
     $output;
     switch ($vtprd_rule->rule_deal_info[0]['discount_applies_to']) {
         case 'each':
             $output .= '<span class="words-line"> &nbsp;&nbsp;&nbsp; -';
             $output .= __('each product ', 'vtprd');
             break;
         case 'all':
             if ($vtprd_rule->rule_template != 'C-forThePriceOf-inCart') {
                 //Don't show for  "Buy 5, get them for the price of 4/$400"
                 $output .= '<span class="words-line"> &nbsp;&nbsp;&nbsp; -';
                 $output .= __('all products', 'vtprd');
             }
             break;
         case 'cheapest':
             $output .= '<span class="words-line"> &nbsp;&nbsp;&nbsp; -';
             $output .= __('cheapest product in the group ', 'vtprd');
             break;
         case 'most_expensive':
             $output .= '<span class="words-line"> &nbsp;&nbsp;&nbsp; -';
             $output .= __('most expensive product in the group ', 'vtprd');
             break;
         default:
             break;
             /*  default:
                   $output .=  __(' discount_applies_to= ', 'vtprd');
                   $output .=  $vtprd_rule->rule_deal_info[0]['discount_applies_to'];
                   $output .=  __('end ', 'vtprd');
                 break;   */
     }
     $output .= '</span><!-- 018b --><span class="words-line"><span class="words-line-get">';
     $output .= __('* For ', 'vtprd') . '</span><!-- 018c -->';
     switch ($vtprd_rule->rule_deal_info[0]['discount_amt_type']) {
         case 'percent':
             $output .= $vtprd_rule->rule_deal_info[0]['discount_amt_count'] . __('% off', 'vtprd');
             break;
         case 'currency':
             $amt = vtprd_format_money_element($vtprd_rule->rule_deal_info[0]['discount_amt_count']);
             $output .= $amt . __(' off', 'vtprd');
             break;
         case 'fixedPrice':
             $amt = vtprd_format_money_element($vtprd_rule->rule_deal_info[0]['discount_amt_count']);
             $output .= $amt;
             break;
         case 'free':
             $output .= __('Free', 'vtprd');
             break;
         case 'forThePriceOf_Units':
         case 'forThePriceOf_Currency':
             $output .= __('the Group Price of $', 'vtprd');
             $output .= $vtprd_rule->rule_deal_info[0]['discount_amt_count'];
             break;
     }
     switch ($vtprd_rule->rule_template) {
         case 'D-storeWideSale':
         case 'D-simpleDiscount':
             $output .= '<br> &nbsp;&nbsp;&nbsp; -';
             $output .= __(' when catalog displays.', 'vtprd') . '</span><!-- 019 -->';
             //'</span><!-- 019 --> </span><!-- 019a -->';
             break;
         default:
             $output .= '<br> &nbsp;&nbsp;&nbsp; -';
             $output .= __(' when added to cart.', 'vtprd') . '</span><!-- 020 -->';
             //'</span><!-- 020 --> </span><!-- 020a -->';
             break;
     }
     return $output;
 }