public function vtprd_show_price_save_amount()
 {
     //error_log( print_r(  'Function begin - vtprd_show_price_save_amount', true ) );
     global $vtprd_setup_options, $vtprd_info;
     if (get_option('woocommerce_calc_taxes') == 'yes') {
         //suffix gets added automatically, blank if no suffix provided ...
         $woocommerce_tax_display_shop = get_option('woocommerce_tax_display_shop');
         if (get_option('woocommerce_prices_include_tax') == 'yes') {
             switch (true) {
                 case vtprd_maybe_customer_tax_exempt():
                     $price_contents = $vtprd_info['product_session_info']['product_catalog_yousave_total_amt_excl_tax_woo'];
                     break;
                 case $woocommerce_tax_display_shop == 'incl':
                     $price_contents = $vtprd_info['product_session_info']['product_yousave_total_amt'];
                     break;
                 case $woocommerce_tax_display_shop == 'excl':
                     $price_contents = $vtprd_info['product_session_info']['product_catalog_yousave_total_amt_excl_tax_woo'];
                     break;
             }
         } else {
             switch (true) {
                 case vtprd_maybe_customer_tax_exempt():
                     $price_contents = $vtprd_info['product_session_info']['product_yousave_total_amt'];
                     break;
                 case $woocommerce_tax_display_shop == 'incl':
                     $price_contents = $vtprd_info['product_session_info']['product_catalog_yousave_total_amt_incl_tax_woo'];
                     break;
                 case $woocommerce_tax_display_shop == 'excl':
                     $price_contents = $vtprd_info['product_session_info']['product_yousave_total_amt'];
                     break;
             }
         }
     } else {
         $price_contents = $vtprd_info['product_session_info']['product_yousave_total_amt'];
     }
     $price_contents = wc_price($price_contents);
     return $price_contents;
 }
Esempio n. 2
0
function vtprd_get_price_including_tax_forced($product_id, $price, $product)
{
    global $post, $wpdb, $woocommerce, $vtprd_cart, $vtprd_cart_item, $vtprd_setup_options, $vtprd_info;
    //error_log( print_r(  'vtprd_get_price_including_tax_forced, Begin price= ' .$price .' Product= ' .$product_id , true ) );
    //changed $this->  to  $product->
    //use $discount_price as basi
    $qty = 1;
    $_tax = new WC_Tax();
    if ($product->is_taxable()) {
        if (get_option('woocommerce_prices_include_tax') === 'no') {
            $tax_rates = $_tax->get_rates($product->get_tax_class());
            $taxes = $_tax->calc_tax($price * $qty, $tax_rates, false);
            $tax_amount = $_tax->get_tax_total($taxes);
            $price = round($price * $qty + $tax_amount, absint(get_option('woocommerce_price_num_decimals')));
        } else {
            $tax_rates = $_tax->get_rates($product->get_tax_class());
            $base_tax_rates = $_tax->get_shop_base_rate($product->tax_class);
            //	if ( ! empty( $woocommerce->customer ) && $woocommerce->customer->is_vat_exempt() ) {   //v1.0.7.5
            if (vtprd_maybe_customer_tax_exempt()) {
                //v1.0.7.9
                $base_taxes = $_tax->calc_tax($price * $qty, $base_tax_rates, true);
                $base_tax_amount = array_sum($base_taxes);
                $price = round($price * $qty - $base_tax_amount, absint(get_option('woocommerce_price_num_decimals')));
            } elseif ($tax_rates !== $base_tax_rates) {
                $base_taxes = $_tax->calc_tax($price * $qty, $base_tax_rates, true);
                $modded_taxes = $_tax->calc_tax($price * $qty - array_sum($base_taxes), $tax_rates, false);
                $price = round($price * $qty - array_sum($base_taxes) + array_sum($modded_taxes), absint(get_option('woocommerce_price_num_decimals')));
            } else {
                $taxes = $_tax->calc_tax($price * $qty, $tax_rates, false);
                $tax_amount = $_tax->get_tax_total($taxes);
                $price = round($price * $qty + $tax_amount, absint(get_option('woocommerce_price_num_decimals')));
            }
        }
    } else {
        $price = $price * $qty;
    }
    return $price;
}