Example #1
0
function set_tax_price($item_id, $item_type_id, $price, $quantity, $sales, $tax_id, $tax_free, $price_tag = "", $sales_tag = "", $tax_price_tag = "", $tag_id = false, $comp_price = 0, $comp_tax = 0, $tax_vars = true)
{
    global $t, $settings, $tax_rates, $currency;
    $zero_price_type = get_setting_value($settings, "zero_price_type", 0);
    $zero_price_message = get_translation(get_setting_value($settings, "zero_price_message", ""));
    $tax_prices_type = get_setting_value($settings, "tax_prices_type", 0);
    $tax_prices = get_setting_value($settings, "tax_prices", 0);
    $tax_note_excl = get_translation(get_setting_value($settings, "tax_note_excl", ""));
    $tax_note_incl = get_translation(get_setting_value($settings, "tax_note", ""));
    $price_tax = get_tax_amount($tax_rates, $item_type_id, $price, $quantity, $tax_id, $tax_free, $tax_percent);
    $sales_tax = get_tax_amount($tax_rates, $item_type_id, $sales, $quantity, $tax_id, $tax_free, $tax_percent);
    $tax_amount = $price_tax;
    if ($tax_prices_type == 1) {
        $price_incl = $price + $comp_price;
        $price_excl = $price - $price_tax + $comp_price - $comp_tax;
        $sales_incl = $sales + $comp_price;
        $sales_excl = $sales - $sales_tax + $comp_price - $comp_tax;
    } else {
        $price_incl = $price + $price_tax + $comp_price + $comp_tax;
        $price_excl = $price + $comp_price;
        $sales_incl = $sales + $sales_tax + $comp_price + $comp_tax;
        $sales_excl = $sales + $comp_price;
    }
    if ($tax_prices == 0 || $tax_prices == 3) {
        $tax_price_tag = "";
    }
    // set some product settings
    $t->set_var("price_block_class", "priceBlock");
    if ($price_tag) {
        if ($tax_prices == 0 || $tax_prices == 1) {
            $product_price = $price_excl;
            $product_sales = $sales_excl;
        } else {
            $product_price = $price_incl;
            $product_sales = $sales_incl;
        }
        if ($tax_vars) {
            $t->set_var("tax_percent", $tax_percent);
            $t->set_var("tax_prices", $tax_prices);
        }
        if ($zero_price_type && $product_price == 0) {
            if ($zero_price_type == 1) {
                $t->set_var("price_block_class", "priceBlockHidden");
            }
            $t->set_var($price_tag, $zero_price_message);
            $t->set_var($price_tag . "_control", $zero_price_message);
        } else {
            $t->set_var("price_block_class", "priceBlock");
            $t->set_var($price_tag, currency_format($product_price));
            $t->set_var($price_tag . "_control", currency_format($product_price));
        }
        if ($sales_tag) {
            $t->set_var("price_block_class", "priceBlockOld");
            $t->set_var($sales_tag, currency_format($product_sales));
            $t->set_var($sales_tag . "_control", currency_format($product_sales));
            $t->set_var("you_save", currency_format($product_price - $product_sales));
        }
    }
    if ($tax_price_tag) {
        if ($tax_prices == 1) {
            $product_price = $price_incl;
            $product_sales = $sales_incl;
            $tax_note = $tax_note_incl;
        } else {
            $product_price = $price_excl;
            $product_sales = $sales_excl;
            $tax_note = $tax_note_excl;
        }
        $tax_price = $sales_tag ? $product_sales : $product_price;
        if ($tax_note) {
            $tax_note = " " . $tax_note;
        }
        if ($zero_price_type && $product_price == 0) {
            if ($tag_id) {
                $t->set_var($tax_price_tag, "<span id=\"tax_price_" . $item_id . "\"></span>");
            } else {
                $t->set_var($tax_price_tag, "");
            }
        } else {
            if ($tag_id) {
                $t->set_var($tax_price_tag, "<span id=\"tax_price_" . $item_id . "\">(" . currency_format($tax_price) . $tax_note . ")" . "</span>");
            } else {
                $t->set_var($tax_price_tag, "(" . currency_format($tax_price) . $tax_note . ")");
            }
        }
    }
    return $tax_amount;
}
Example #2
0
 if (is_array($quantities_discounts) && sizeof($quantities_discounts) > 0) {
     foreach ($quantities_discounts as $coupon_number => $coupon_info) {
         // show coupon information
         $order_coupons++;
         $coupon_id = $coupon_info["COUPON_ID"];
         $coupon_title = $coupon_info["COUPON_TITLE"];
         $item_name = $coupon_info["ITEM_NAME"];
         $discount_number = $coupon_info["DISCOUNT_NUMBER"];
         $discount_per_item = $coupon_info["DISCOUNT_PER_ITEM"];
         $discount_amount = $coupon_info["DISCOUNT_AMOUNT"];
         $item_type_id = $coupon_info["ITEM_TYPE_ID"];
         $item_tax_id = $coupon_info["TAX_ID"];
         $item_tax_free = $coupon_info["TAX_FREE"];
         $max_discount -= $discount_amount;
         // check discount tax
         $discount_tax_amount = get_tax_amount($tax_rates, $item_type_id, $discount_amount, 1, $item_tax_id, $item_tax_free, $item_tax_percent);
         $max_tax_discount -= $discount_tax_amount;
         if ($tax_prices_type == 1) {
             $discount_amount_excl_tax = $discount_amount - $discount_tax_amount;
             $discount_amount_incl_tax = $discount_amount;
         } else {
             $discount_amount_excl_tax = $discount_amount;
             $discount_amount_incl_tax = $discount_amount + $discount_tax_amount;
         }
         $coupon_title .= " (" . $item_name . ")";
         $coupon_title .= " - " . currency_format($discount_per_item) . " x " . $discount_number . "";
         $t->set_var("coupon_title", $coupon_title);
         if ($basket_item_price_total) {
             $t->set_var("discount_amount_excl_tax", "- " . currency_format($discount_amount_excl_tax));
             $t->parse("discount_amount_excl_tax_column", false);
         }
         write_to("\t\t<" . $schema_type . ":additional_image_link>" . $image_url . "</" . $schema_type . ":additional_image_link>" . $eol);
     }
 }
 //END customization
 $price = $db->f("price");
 $sales_price = $db->f("sales_price");
 $is_sales = $db->f("is_sales");
 $properties_price = $db->f("properties_price");
 $tax_id = $db->f("tax_id");
 $tax_free = $db->f("tax_free");
 if ($is_sales && $sales_price > 0) {
     $price = $sales_price;
 }
 $price += $properties_price;
 if ($google_base_tax) {
     $price_tax = get_tax_amount($tax_rates, $item_type_id, $price, 1, $tax_id, $tax_free, $tax_percent);
     if ($tax_prices_type == 1) {
         $price_incl = $price;
         $price_excl = $price - $price_tax;
     } else {
         $price_incl = $price + $price_tax;
         $price_excl = $price;
     }
     $price = $price_incl;
     write_to("\t\t<" . $schema_type . ":tax_percent>" . $tax_percent . "</" . $schema_type . ":tax_percent>" . $eol);
     write_to("\t\t<" . $schema_type . ":tax_region>" . $tax_region . "</" . $schema_type . ":tax_region>" . $eol);
 }
 write_to("\t\t<" . $schema_type . ":price>" . $price . "</" . $schema_type . ":price>" . $eol);
 $use_stock_level = $db->f("use_stock_level");
 $hide_out_of_stock = $db->f("hide_out_of_stock");
 $disable_out_of_stock = $db->f("disable_out_of_stock");
Example #4
0
            $shipping_taxable = $row_shipping_taxable;
            if ($shipping_taxable) {
                $shipping_taxable_value = $shipping_cost;
            }
        }
    }
}
$t->set_var("shipping_control", $shipping_control);
$t->set_var("shipping_methods", $shipping_methods);
$t->set_var("shipping_taxable_value", $shipping_taxable_value);
// todo delete
if ($shipping_cost > 0) {
    // get taxes for selected shipping and add it to total values
    $shipping_tax_id = 0;
    $shipping_tax_free = $shipping_taxable ? 0 : 1;
    $shipping_tax_values = get_tax_amount($tax_rates, "shipping", $shipping_cost, 1, $shipping_tax_id, $shipping_tax_free, $shipping_tax_percent, "", 2);
    $shipping_tax_total = add_tax_values($tax_rates, $shipping_tax_values, "shipping");
}
// #12 - calculate the tax
if ($tax_available) {
    // get taxes sums for further calculations
    $taxes_sum = 0;
    $discount_tax_sum = $total_discount_tax;
    foreach ($tax_rates as $tax_id => $tax_info) {
        $tax_cost = isset($tax_info["tax_total"]) ? $tax_info["tax_total"] : 0;
        $taxes_sum += va_round($tax_cost, $currency["decimals"]);
    }
    $taxes_param = "";
    $tax_number = 0;
    foreach ($tax_rates as $tax_id => $tax_info) {
        $tax_number++;