function calculate_price($products_price, $products_tax, $quantity = 1, $rate = "", $pid = "") { global $currency; if (is_numeric($pid)) { $dbres = tep_db_query("select categories_id from products_to_categories where products_id='" . $pid . "'"); $row = tep_db_fetch_array($dbres); $cat_id = (int) $row['categories_id']; if ($cat_id == 23) { return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity; } } if ($rate == "") { $rate = get_price_rate($_SESSION['customer_id']); } if (get_price_group_name($_SESSION['customer_id']) == "Interior Designer") { $dbres = tep_db_query("select dn_price from products where products_id='{$pid}'"); $row = tep_db_fetch_array($dbres); if ((double) $row['dn_price'] > 0) { $products_price = $row['dn_price']; $rate = "100"; } } return ceil(tep_add_tax($products_price * $rate / 100, $products_tax)) * $quantity; // return tep_round(tep_add_tax(($products_price*$rate)/100, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity; }
function calculate_credit($amount) { global $order; $od_amount = 0; $table_cost = preg_split("/[:,]/", MODULE_LEV_DISCOUNT_TABLE); for ($i = 0; $i < count($table_cost); $i += 2) { if ($amount >= $table_cost[$i]) { $od_pc = $table_cost[$i + 1]; } } // Calculate tax reduction if necessary if ($this->calculate_tax == true) { // Calculate main tax reduction $tod_amount = tep_round($order->info['tax'] * 10, 2) / 10 * $od_pc / 100; $order->info['tax'] = $order->info['tax'] - $tod_amount; // Calculate tax group deductions reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $god_amount = tep_round($value * 10, 2) / 10 * $od_pc / 100; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } if (!isset($tod_amount)) { $tod_amount = 0; } $od_amount = tep_round($amount * 10, 2) / 10 * $od_pc / 100; /////////////////////////////////////////////////////////////////////////////////////////////////////// // added by maestro to avoid rounding up issue and possibly causing 1 penny miscalculation in discount $parts = explode(".", $od_amount); $od_amount = $parts[0] . '.' . substr($parts[1], 0, 2); /////////////////////////////////////////////////////////////////////////////////////////////////////// $od_amount = $od_amount + $tod_amount; return $od_amount; }
function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency; if (empty($currency_type)) { $currency_type = $currency; } $sign = ''; if ($number < 0) { $sign = '-'; $number = abs($number); } if ($calculate_currency_value == true) { $rate = tep_not_null($currency_value) ? $currency_value : $this->currencies[$currency_type]['value']; if (SHOP_ID == 16) { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, 2), 2, $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right']; } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . ($this->currencies[$currency_type]['decimal_places'] == '1' ? '0' : '') . $this->currencies[$currency_type]['symbol_right']; } // if the selected currency is in the european euro-conversion and the default currency is euro, // the currency will displayed in the national currency and euro currency if (DEFAULT_CURRENCY == 'EUR' && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD')) { $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>'; } } else { $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . ($this->currencies[$currency_type]['decimal_places'] == '1' ? '0' : '') . $this->currencies[$currency_type]['symbol_right']; } $format_string = $sign . $format_string; return $format_string; }
function displayPrice($price, $tax_class_id, $quantity = 1) { global $osC_Tax; $price = tep_round($price, $this->currencies[DEFAULT_CURRENCY]['decimal_places']); if (DISPLAY_PRICE_WITH_TAX == 'true' && $tax_class_id > 0) { $price += tep_round($price * ($osC_Tax->getTaxRate($tax_class_id) / 100), $this->currencies[DEFAULT_CURRENCY]['decimal_places']); } return $this->format($price * $quantity); }
function format_raw($number, $currency_code = '', $currency_value = '') { global $currencies; if (empty($currency_code) || !$currencies->is_set($currency_code)) { $currency_code = $_SESSION['currency']; } if (empty($currency_value) || !is_numeric($currency_value)) { $currency_value = $currencies->currencies[$currency_code]['value']; } return number_format(tep_round($number * $currency_value, $currencies->currencies[$currency_code]['decimal_places']), $currencies->currencies[$currency_code]['decimal_places'], '.', ''); }
function format_raw($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { if (empty($currency_type)) { $currency_type = $_SESSION['currency']; } if ($calculate_currency_value == true) { $rate = tep_not_null($currency_value) ? $currency_value : $this->currencies[$currency_type]['value']; $format_string = number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], '.', ''); } else { $format_string = number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], '.', ''); } return $format_string; }
function calculate_discount($amount) { global $cart; $od_amount = 0; if (MODULE_QTY_DISCOUNT_DISABLE_WITH_COUPON == 'true' && (isset($_SESSION['cc_id']) && tep_not_null($_SESSION['cc_id']))) { return $od_amount; } if (is_object($cart)) { $qty_discount = $this->calculate_rate($cart->count_contents()); } else { $qty_discount = 0; } if ($qty_discount > 0) { if (MODULE_QTY_DISCOUNT_RATE_TYPE == 'percentage') { $od_amount = tep_round($amount * 10 / 10 * ($qty_discount / 100), 2); } else { $od_amount = tep_round($qty_discount * 10 / 10, 2); } } return $od_amount; }
function process_button() { global $HTTP_POST_VARS, $currencies, $currency, $order, $languages_id; $process_button_string = tep_draw_hidden_field('sid', MODULE_PAYMENT_2CHECKOUT_LOGIN) . tep_draw_hidden_field('total', number_format($order->info['total'], 2)) . tep_draw_hidden_field('cart_order_id', date('YmdHis')) . tep_draw_hidden_field('fixed', 'Y') . tep_draw_hidden_field('card_holder_name', $order->billing['firstname'] . ' ' . $order->billing['lastname']) . tep_draw_hidden_field('street_address', $order->billing['street_address']) . tep_draw_hidden_field('city', $order->billing['city']) . tep_draw_hidden_field('state', $order->billing['state']) . tep_draw_hidden_field('zip', $order->billing['postcode']) . tep_draw_hidden_field('country', $order->billing['country']['title']) . tep_draw_hidden_field('email', $order->customer['email_address']) . tep_draw_hidden_field('phone', $order->customer['telephone']) . tep_draw_hidden_field('ship_street_address', $order->delivery['street_address']) . tep_draw_hidden_field('ship_city', $order->delivery['city']) . tep_draw_hidden_field('ship_state', $order->delivery['state']) . tep_draw_hidden_field('ship_zip', $order->delivery['postcode']) . tep_draw_hidden_field('ship_country', $order->delivery['country']['title']); for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $process_button_string .= tep_draw_hidden_field('c_prod_' . ($i + 1), (int) $order->products[$i]['id'] . ',' . (int) $order->products[$i]['qty']) . tep_draw_hidden_field('c_name_' . ($i + 1), $order->products[$i]['name']) . tep_draw_hidden_field('c_description_' . ($i + 1), $order->products[$i]['name']) . tep_draw_hidden_field('c_price_' . ($i + 1), tep_round(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $currencies->currencies[$currency]['decimal_places'])); } $process_button_string .= tep_draw_hidden_field('id_type', '1'); if (MODULE_PAYMENT_2CHECKOUT_TESTMODE == 'Test') { $process_button_string .= tep_draw_hidden_field('demo', 'Y'); } $process_button_string .= tep_draw_hidden_field('return_url', tep_href_link(FILENAME_SHOPPING_CART)); $lang_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where languages_id = '" . (int) $languages_id . "'"); $lang = tep_db_fetch_array($lang_query); switch (strtolower($lang['code'])) { case 'es': $process_button_string .= tep_draw_hidden_field('lang', 'sp'); break; } $process_button_string .= tep_draw_hidden_field('cart_brand_name', 'oscommerce') . tep_draw_hidden_field('cart_version_name', PROJECT_VERSION); return $process_button_string; }
function quote($method = '') { global $order, $cart, $shipping_weight, $currencies, $currency; $shipping_cost = 0; if (empty($order->delivery['postcode'])) { $this->quotes['error'] = MODULE_SHIPPING_BELPOSTBN_ERROR_NO_ZIPCODE_FOUND; // $shipping_method = MODULE_SHIPPING_BELPOSTBN_ERROR_NO_ZIPCODE_FOUND; } else { $total_sum = tep_round($cart->total * $currencies->currencies[$currency]['value'], $currencies->currencies[$currency]['decimal_places']); $base_shipping = str_replace(',', '.', MODULE_SHIPPING_BELPOSTBN_COST); $shipping_cost = ceil($shipping_weight * 1000 / 500) * $base_shipping; $eval_cost = str_replace(',', '.', MODULE_SHIPPING_BELPOSTBN_EVAL_COST); $add_cost = str_replace(',', '.', MODULE_SHIPPING_BELPOSTBN_ADDITIONAL_COST); $risk_cost = trim(str_replace('%', '', str_replace(',', '.', MODULE_SHIPPING_BELPOSTBN_RISK_COST))); $transfer_cost = trim(str_replace('%', '', str_replace(',', '.', MODULE_SHIPPING_BELPOSTBN_TRANSFER_COST))); if ((double) $eval_cost > 0) { $shipping_cost += $total_sum * $eval_cost; } if ((double) $add_cost > 0) { $shipping_cost += $add_cost; } if ((double) $risk_cost > 0) { $shipping_cost += $total_sum * $risk_cost / 100; } if ((double) $transfer_cost > 0) { $shipping_cost += $total_sum * $transfer_cost / 100; } $shipping_method = sprintf(MODULE_SHIPPING_BELPOSTBN_TEXT_WEIGHT, $shipping_weight); } if ($shipping_cost > 0) { $shipping_cost = round($shipping_cost / 50) * 50; $shipping_cost = $shipping_cost / $currencies->currencies[$currency]['value']; } $this->quotes['id'] = $this->code; $this->quotes['module'] = MODULE_SHIPPING_BELPOSTBN_TEXT_TITLE; $this->quotes['methods'] = array(array('id' => $this->code, 'title' => $shipping_method, 'cost' => $shipping_cost)); return $this->quotes; }
function get_currency_value($amount, $currency_info) { $format_string = number_format(tep_round($amount, $currency_info['decimal_places']), $currency_info['decimal_places'], $currency_info['decimal_point'], $currency_info['thousands_point']) . $currency_info['symbol_right']; return $format_string; }
function tep_calculate_tax($price, $tax) { global $currencies; return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); }
$affiliate_sales_raw = "select count(*) as count, sum(affiliate_value) as total, sum(affiliate_payment) as payment from " . TABLE_AFFILIATE_SALES . " "; $affiliate_sales_query = tep_db_query($affiliate_sales_raw); $affiliate_sales = tep_db_fetch_array($affiliate_sales_query); $affiliate_clickthroughs_raw = "select count(*) as count from " . TABLE_AFFILIATE_CLICKTHROUGHS . " "; $affiliate_clickthroughs_query = tep_db_query($affiliate_clickthroughs_raw); $affiliate_clickthroughs = tep_db_fetch_array($affiliate_clickthroughs_query); $affiliate_clickthroughs = $affiliate_clickthroughs['count']; $affiliate_transactions = $affiliate_sales['count']; if ($affiliate_transactions > 0) { $affiliate_conversions = tep_round($affiliate_transactions / $affiliate_clickthroughs, 6) . "%"; } else { $affiliate_conversions = "n/a"; } $affiliate_amount = $affiliate_sales['total']; if ($affiliate_transactions > 0) { $affiliate_average = tep_round($affiliate_amount / $affiliate_transactions, 2); } else { $affiliate_average = "n/a"; } $affiliate_commission = $affiliate_sales['payment']; $affiliates_raw = "select count(*) as count from " . TABLE_AFFILIATE . ""; $affiliates_raw_query = tep_db_query($affiliates_raw); $affiliates_raw = tep_db_fetch_array($affiliates_raw_query); $affiliate_number = $affiliates_raw['count']; $heading = array(); $contents = array(); $heading[] = array('params' => 'class="menuBoxHeading"', 'text' => BOX_TITLE_AFFILIATES); $contents[] = array('params' => 'class="infoBox"', 'text' => BOX_ENTRY_AFFILIATES . ' ' . $affiliate_number . '<br>' . BOX_ENTRY_CONVERSION . ' ' . $affiliate_conversions . '<br>' . BOX_ENTRY_COMMISSION . ' ' . $currencies->display_price($affiliate_commission, '')); $box = new box(); echo $box->menuBox($heading, $contents); echo '<br>';
<td align="right" class="dataTableContent"><?php echo TEXT_AVERAGE; ?> </td> <td align="left" class="dataTableContent"><?php echo $currencies->display_price($affiliate_average, ''); ?> </td> </tr> <tr> <td align="right" class="dataTableContent"><?php echo TEXT_COMMISSION_RATE; ?> </td> <td align="left" class="dataTableContent"><?php echo tep_round(AFFILIATE_PERCENT, 2) . ' %'; ?> </td> <td align="right" nowrap class="dataTableContent"><b><?php echo TEXT_COMMISSION; ?> </b></td> <td align="left" class="dataTableContent"><b><?php echo $currencies->display_price($affiliate_commission, ''); ?> </b></td> </tr> <tr> <td align="right" class="dataTableContent" colspan="4" style="padding:15px 0 15px 0; border-top:solid 1px #e5e5e5"><?php echo '<a href="' . tep_href_link(FILENAME_AFFILIATE_BANNERS, '') . '">' . tep_image_button('button_affiliate_banners.gif', IMAGE_BANNERS) . '</a> <a href="' . tep_href_link(FILENAME_AFFILIATE_CLICKS, '') . '">' . tep_image_button('button_affiliate_clickthroughs.gif', IMAGE_CLICKTHROUGHS) . '</a> <a href="' . tep_href_link(FILENAME_AFFILIATE_SALES, '') . '">' . tep_image_button('button_affiliate_sales.gif', IMAGE_SALES) . '</a>'; ?>
function calculate_credit($amount) { global $customer_id, $order, $cc_id; //$cc_id = $_SESSION['cc_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. $od_amount = 0; if (isset($cc_id)) { $coupon_query = tep_db_query("select coupon_code from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) != 0) { $coupon_result = tep_db_fetch_array($coupon_query); $this->coupon_code = $coupon_result['coupon_code']; $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code = '" . $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); $c_deduct = $get_result['coupon_amount']; if ($get_result['coupon_type'] == 'P' && $get_result['restrict_to_products']) { $this->percent = number_format($c_deduct) . '% ('; } else { if ($get_result['coupon_type'] == 'P') { $this->percent = number_format($c_deduct) . '%'; } else { if ($get_result['restrict_to_products']) { $this->percent = ' ('; } } } // Calcul de l'affichage du coupon if ($get_result['coupon_type'] == 'S') { $c_deduct = $order->info['shipping_cost']; } //Calcul du coupon si celui ci est > 0 avec les frais d'envoie if ($get_result['coupon_type'] == 'S' && $get_result['coupon_amount'] > 0) { $c_deduct = $order->info['shipping_cost'] + $get_result['coupon_amount']; } if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) { if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { for ($i = 0; $i < sizeof($order->products); $i++) { if ($get_result['restrict_to_products']) { $pr_ids = preg_split("/[,]/", $get_result['restrict_to_products']); for ($ii = 0; $ii < count($pr_ids); $ii++) { if ($pr_ids[$ii] == tep_get_prid($order->products[$i]['id'])) { if ($get_result['coupon_type'] == 'P') { /* Fixes to Gift Voucher module 5.03 ================================= Submitted by Rob Cote, robc@traininghott.com original code: $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; */ //$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pr_c = $order->products[$i]['final_price'] * $order->products[$i]['qty']; $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100; $od_amount = $od_amount + $pod_amount; $this->percent .= tep_get_products_name($order->products[$i]['id']) . ', '; } else { $this->percent .= tep_get_products_name($order->products[$i]['id']) . ', '; $od_amount = $c_deduct; } } } } else { $cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']); for ($i = 0; $i < sizeof($order->products); $i++) { $my_path = tep_get_product_path(tep_get_prid($order->products[$i]['id'])); $sub_cat_ids = preg_split("/[_]/", $my_path); for ($iii = 0; $iii < count($sub_cat_ids); $iii++) { for ($ii = 0; $ii < count($cat_ids); $ii++) { if ($sub_cat_ids[$iii] == $cat_ids[$ii]) { if ($get_result['coupon_type'] == 'P') { /* Category Restriction Fix to Gift Voucher module 5.04 Date: August 3, 2003 ================================= Nick Stanko of UkiDev.com, nick@ukidev.com original code: $od_amount = round($amount*10)/10*$c_deduct/100; $pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pod_amount = round($pr_c*10)/10*$c_deduct/100; */ //$od_amount = round($amount*10)/10*$c_deduct/100; //$pr_c = $order->products[$i]['final_price']*$order->products[$i]['qty']; $pr_c = $this->product_price(tep_get_prid($order->products[$i]['id'])); //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT! // Fix for bug that causes to deduct the coupon amount from the shipping costs. $pr_c = $this->product_price($order->products[$i]['id']); $pod_amount = round($pr_c * 10) / 10 * $c_deduct / 100; $od_amount = $od_amount + $pod_amount; continue 3; // v5.13a Tanaka 2005-4-30: to prevent double counting of a product discount } else { $od_amount = $c_deduct; continue 3; // Tanaka 2005-4-30: to prevent double counting of a product discount } } } } } } } } else { if ($get_result['coupon_type'] != 'P') { $od_amount = $c_deduct; } else { $od_amount = $amount * $get_result['coupon_amount'] / 100; } } if ($get_result['coupon_type'] == 'P' && $get_result['restrict_to_products']) { $this->percent = substr($this->percent, 0, -2); $this->percent .= ')'; } else { if (strlen($this->percent) > 2 && $get_result['restrict_to_products']) { $this->percent = substr($this->percent, 0, -2); $this->percent .= ')'; } } } } if ($od_amount > $amount) { $od_amount = $amount; } } return tep_round($od_amount, 2); }
function tep_get_price_with_tax($products_price, $products_tax, $default_currency, $calculate_currency_value = true) { $price = tep_round(tep_add_tax($products_price, $products_tax, true), $default_currency['decimal_places']); if ($calculate_currency_value) { $format_string = number_format($price * $default_currency['value'], $default_currency['decimal_places'], $default_currency['decimal_point'], $default_currency['thousands_point']); } else { $format_string = number_format($price, $default_currency['decimal_places'], $default_currency['decimal_point'], $default_currency['thousands_point']); } return $format_string; }
function calculate_price($products_price, $products_tax, $quantity = 1) { return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$_SESSION['currency']]['decimal_places']) * $quantity; }
$temp_array = array(); while (list(, $field_id) = each($fields)) { switch ($field_id) { case 'products_model': $temp_array[] = $product_info['products_model']; break; case 'products_name': $temp_array[] = html_entity_decode($product_info['products_name'], ENT_QUOTES); break; case 'authors_name': $author_info_query = tep_db_query("select authors_name from " . TABLE_AUTHORS . " where authors_id = '" . $product_info['authors_id'] . "' and language_id = '" . (int) $languages_id . "'"); $author_info = tep_db_fetch_array($author_info_query); $temp_array[] = html_entity_decode($author_info['authors_name'], ENT_QUOTES); break; case 'products_price': $temp_array[] = tep_round($product_info['products_price'] * $currencies->currencies[$currency]['value'], $currencies->currencies[$currency]['decimal_places']); break; case 'manufacturers_name': $manufacturer_info_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . $product_info['manufacturers_id'] . "' and languages_id = '" . (int) $languages_id . "'"); $manufacturer_info = tep_db_fetch_array($manufacturer_info_query); $temp_array[] = html_entity_decode($manufacturer_info['manufacturers_name'], ENT_QUOTES); break; case 'series_name': $serie_info_query = tep_db_query("select series_name from " . TABLE_SERIES . " where series_id = '" . $product_info['series_id'] . "' and language_id = '" . (int) $languages_id . "'"); $serie_info = tep_db_fetch_array($serie_info_query); $temp_array[] = html_entity_decode($serie_info['series_name'], ENT_QUOTES); break; case 'products_pages_count': $temp_array[] = (int) $product_info['products_pages_count'] > 0 ? (int) $product_info['products_pages_count'] : ''; break; case 'products_year':
function calculate_tax_deduction($amount, $od_amount, $method) { global $order; switch ($method) { case 'Standard': $ratio1 = tep_round($od_amount / $amount, 2); $tod_amount = 0; reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = tep_get_tax_rate_from_desc($key); $total_net += $tax_rate * $order->info['tax_groups'][$key]; } if ($od_amount > $total_net) { $od_amount = $total_net; } reset($order->info['tax_groups']); while (list($key, $value) = each($order->info['tax_groups'])) { $tax_rate = tep_get_tax_rate_from_desc($key); $net = $tax_rate * $order->info['tax_groups'][$key]; if ($net > 0) { $god_amount = $order->info['tax_groups'][$key] * $ratio1; $tod_amount += $god_amount; $order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount; } } $order->info['tax'] -= $tod_amount; $order->info['total'] -= $tod_amount; break; case 'Credit Note': $tax_rate = tep_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_desc = tep_get_tax_description($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']); $tod_amount = $this->deduction / (100 + $tax_rate) * $tax_rate; $order->info['tax_groups'][$tax_desc] -= $tod_amount; // $order->info['total'] -= $tod_amount; //// ????? Strider break; default: } return $tod_amount; }
echo '0'; } break; case 'products_prices_gross': //product price $tax_rates_post = isset($_POST['tax_rates']) ? $_POST['tax_rates'] : ''; if (tep_not_null($value_post) && tep_not_null($tax_rates_post)) { $values = json_decode(stripslashes($value_post)); $tax_rates_obj = (array) json_decode(stripslashes($tax_rates_post)); $tax_rates = array(); foreach ($tax_rates_obj as $txok => $toxv) { $tax_rates[$txok] = $toxv; } foreach ($values as $key => $val) { $fin = $val / ($tax_rates[$key] / 100 + 1); $fin = tep_round($fin, 4); $sql_data_array = array('products_price' => (double) tep_db_prepare_input($fin), 'products_last_modified' => 'now()'); tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int) $key . "'"); } echo '1'; } else { echo '0'; } break; case 'products_weight': //product weight if (tep_not_null($product_id_post)) { if (tep_not_null($value_post)) { if (is_numeric($value_post)) { $sql_data_array = array('products_weight' => (double) tep_db_prepare_input($value_post), 'products_last_modified' => 'now()'); if (tep_db_perform(TABLE_PRODUCTS, $sql_data_array, 'update', "products_id = '" . (int) $product_id_post . "'")) {
function tep_calculate_tax($price, $tax) { global $currencies, $currency; return tep_round($price * $tax / 100, $currencies->currencies[$currency]['decimal_places']); }
} $orders_id = substr($orders_id, 0, -1) . ")"; // Set the Sales to Temp State (it may happen that an order happend while billing) $sql = "UPDATE " . TABLE_AFFILIATE_SALES . " \n set affiliate_billing_status=99 \n where affiliate_id='" . $affiliate_payment['affiliate_id'] . "' \n and affiliate_orders_id in " . $orders_id . " \n "; tep_db_query($sql); // Get Sum of payment (Could have changed since last selects); $sql = "\n SELECT sum(affiliate_payment) as affiliate_payment\n FROM " . TABLE_AFFILIATE_SALES . " \n WHERE affiliate_id='" . $affiliate_payment['affiliate_id'] . "' and affiliate_billing_status=99 \n "; $affiliate_billing_query = tep_db_query($sql); $affiliate_billing = tep_db_fetch_array($affiliate_billing_query); // Get affiliate Informations $sql = "\n SELECT a.*, c.countries_id, c.countries_name, c.countries_iso_code_2, c.countries_iso_code_3, c.address_format_id \n from " . TABLE_AFFILIATE . " a \n left join " . TABLE_ZONES . " z on (a.affiliate_zone_id = z.zone_id) \n left join " . TABLE_COUNTRIES . " c on (a.affiliate_country_id = c.countries_id)\n WHERE affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' \n "; $affiliate_query = tep_db_query($sql); $affiliate = tep_db_fetch_array($affiliate_query); // Get need tax informations for the affiliate $affiliate_tax_rate = tep_get_affiliate_tax_rate(AFFILIATE_TAX_ID, $affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id']); $affiliate_tax = tep_round($affiliate_billing['affiliate_payment'] * $affiliate_tax_rate / 100, 2); // Netto-Provision $affiliate_payment_total = $affiliate_billing['affiliate_payment'] + $affiliate_tax; // Bill the order $affiliate['affiliate_state'] = tep_get_zone_code($affiliate['affiliate_country_id'], $affiliate['affiliate_zone_id'], $affiliate['affiliate_state']); $sql_data_array = array('affiliate_id' => $affiliate_payment['affiliate_id'], 'affiliate_payment' => $affiliate_billing['affiliate_payment'], 'affiliate_payment_tax' => $affiliate_tax, 'affiliate_payment_total' => $affiliate_payment_total, 'affiliate_payment_date' => 'now()', 'affiliate_payment_status' => '0', 'affiliate_firstname' => $affiliate['affiliate_firstname'], 'affiliate_lastname' => $affiliate['affiliate_lastname'], 'affiliate_street_address' => $affiliate['affiliate_street_address'], 'affiliate_suburb' => $affiliate['affiliate_suburb'], 'affiliate_city' => $affiliate['affiliate_city'], 'affiliate_country' => $affiliate['countries_name'], 'affiliate_postcode' => $affiliate['affiliate_postcode'], 'affiliate_company' => $affiliate['affiliate_company'], 'affiliate_state' => $affiliate['affiliate_state'], 'affiliate_address_format_id' => $affiliate['address_format_id']); tep_db_perform(TABLE_AFFILIATE_PAYMENT, $sql_data_array); $insert_id = tep_db_insert_id(); // Set the Sales to Final State tep_db_query("update " . TABLE_AFFILIATE_SALES . " set affiliate_payment_id = '" . $insert_id . "', affiliate_billing_status = 1, affiliate_payment_date = now() where affiliate_id = '" . $affiliate_payment['affiliate_id'] . "' and affiliate_billing_status = 99"); // Notify Affiliate if (AFFILIATE_NOTIFY_AFTER_BILLING == 'true') { $check_status_query = tep_db_query("select af.affiliate_email_address, ap.affiliate_lastname, ap.affiliate_firstname, ap.affiliate_payment_status, ap.affiliate_payment_date, ap.affiliate_payment_date from " . TABLE_AFFILIATE_PAYMENT . " ap, " . TABLE_AFFILIATE . " af where affiliate_payment_id = '" . $insert_id . "' and af.affiliate_id = ap.affiliate_id "); $check_status = tep_db_fetch_array($check_status_query); $email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_AFFILIATE_PAYMENT_NUMBER . ' ' . $insert_id . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_AFFILIATE_PAYMENT_INFO, 'payment_id=' . $insert_id, 'SSL') . "\n" . EMAIL_TEXT_PAYMENT_BILLED . ' ' . tep_date_long($check_status['affiliate_payment_date']) . "\n\n" . EMAIL_TEXT_NEW_PAYMENT; tep_mail($check_status['affiliate_firstname'] . ' ' . $check_status['affiliate_lastname'], $check_status['affiliate_email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, AFFILIATE_EMAIL_ADDRESS);
function calculate_credit($amount) { //print('amount : '.$amount.'<br>'); global $customer_id, $order, $cc_id; $cc_id = $_SESSION['cc_id']; $od_amount = 0; $get_products_special_price = 0; if (isset($cc_id)) { $coupon_query = tep_db_query("select coupon_code,coupon_sale_exclude from " . TABLE_COUPONS . " where coupon_id = '" . $cc_id . "'"); if (tep_db_num_rows($coupon_query) != 0) { $coupon_result = tep_db_fetch_array($coupon_query); $this->coupon_code = $coupon_result['coupon_code']; //$this->sale_exclusion = $coupon_result['coupon_sale_exclude']; $coupon_get = tep_db_query("select coupon_amount, coupon_minimum_order, restrict_to_products, restrict_to_categories, coupon_type from " . TABLE_COUPONS . " where coupon_code = '" . $coupon_result['coupon_code'] . "'"); $get_result = tep_db_fetch_array($coupon_get); $c_deduct = $get_result['coupon_amount']; if ($get_result['coupon_type'] == 'S') { $c_deduct = $order->info['shipping_cost']; } //v5.14 id coupon total > 0 $p_processed = false; if ($get_result['coupon_type'] == 'S') { $c_deduct = $order->info['shipping_cost']; } if ($get_result['coupon_type'] == 'S' && $get_result['coupon_amount'] > 0) { $c_deduct = $order->info['shipping_cost'] + $get_result['coupon_amount']; } if ($get_result['coupon_minimum_order'] <= $this->get_order_total()) { if ($get_result['restrict_to_products'] || $get_result['restrict_to_categories']) { if ($get_result['restrict_to_categories']) { $cat_ids = preg_split("/[,]/", $get_result['restrict_to_categories']); for ($j = 0; $j < sizeof($order->products); $j++) { $my_path = tep_get_product_path(tep_get_prid($order->products[$j]['id'])); $sub_cat_ids = preg_split("/[_]/", $my_path); for ($iii = 0; $iii < count($sub_cat_ids); $iii++) { for ($ii = 0; $ii < count($cat_ids); $ii++) { if ($sub_cat_ids[$iii] == $cat_ids[$ii]) { if ($get_result['coupon_type'] == 'P') { $p_processed = true; $t = tep_get_prid($order->products[$i]['id']); $pr_c = $this->product_price(tep_get_prid($order->products[$j]['id'])); $pr_c_specail = $this->get_products_special_price($pr_ids[$ii]); $pr_c -= $pr_c_specail; $pod_amount = tep_round($pr_c * 10, 2) / 10 * $c_deduct / 100; $od_amount = $od_amount + $pod_amount; continue 3; } else { $od_amount = $c_deduct; continue 3; } } } } } } else { if ($get_result['restrict_to_products']) { $pr_ids = explode(",", $get_result['restrict_to_products']); for ($ii = 0; $ii < count($pr_ids); $ii++) { for ($i = 0; $i < sizeof($order->products); $i++) { if ($pr_ids[$ii] == tep_get_prid($order->products[$i]['id'])) { if ($get_result['coupon_type'] == 'P') { $p_processed = true; $pr_c = $this->product_price($pr_ids[$ii]); //Fred 2003-10-28, fix for the row above, otherwise the discount is calc based on price excl VAT! $pod_amount = tep_round($pr_c * 10, 2) / 10 * $c_deduct / 100; $od_amount = $od_amount + $pod_amount; } else { $od_amount = $c_deduct; } } } } } } } else { if ($get_result['coupon_type'] != 'P') { $od_amount = $c_deduct; } else { $od_amount = $amount * $get_result['coupon_amount'] / 100; } } } } if ($od_amount > $amount) { $od_amount = $amount; } } //print('1233od_amount : '.$od_amount.'<br>'); return $od_amount; }
function round_amt($price) { $price += 1.0E-6; return tep_round($price, 2); }
echo ' <tr>' . "\n" . ' <td class="smallText" align="right">' . $TotalDetails["Name"] . '</td>' . "\n" . ' <td class="smallText" align="right">' . $TotalDetails["Text"] . ($order->info['currency'] != DEFAULT_CURRENCY ? ' (' . $currencies->format($subtotal_sum) . ')' : '') . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][title]', trim($TotalDetails["Name"])) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][value]', $TotalDetails["Price"] * $order->info['currency_value']) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][class]', $TotalDetails["Class"]) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][total_id]', $TotalDetails["TotalID"]) . '</td>' . "\n" . ' </tr>' . "\n"; } elseif ($TotalDetails["Class"] == "ot_tax") { echo ' <tr>' . "\n" . ' <td align="right" class="smallText">' . tep_draw_input_field('update_totals[' . $TotalIndex . '][title]', trim($TotalDetails["Name"]), 'size="' . strlen(trim($TotalDetails['Name'])) . '" style="text-align: right;"') . '</td>' . "\n" . ' <td class="smallText"><strong>' . $TotalDetails["Text"] . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][value]', $TotalDetails['Price'], 'size="6" style="text-align: right;"') . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][class]', $TotalDetails['Class']) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][total_id]', $TotalDetails['TotalID']) . '</strong></td>' . "\n" . ' </tr>' . "\n"; } elseif ($TotalDetails["Class"] == "ot_shipping") { // $shipping_field = tep_draw_input_field('update_totals[' . $TotalIndex . '][title]', trim($TotalDetails['Name']), 'size="' . (strlen(trim($TotalDetails['Name']))+2) . '" style="text-align: right;"'); $shipping_field = tep_draw_pull_down_menu('update_totals[' . $TotalIndex . '][title]', $shipping_array, $order->delivery['delivery_method_class']); echo ' <tr>' . "\n" . ' <td align="right" class="smallText">' . $shipping_field . '</td>' . "\n" . ' <td class="smallText">' . tep_draw_input_field('update_totals[' . $TotalIndex . '][value]', $TotalDetails['Price'], 'size="6" style="text-align: right;"') . ($order->info['currency'] != DEFAULT_CURRENCY ? ' (' . $currencies->format($TotalDetails['Price'] / $order->info['currency_value']) . ')' : '') . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][class]', $TotalDetails['Class']) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][total_id]', $TotalDetails['TotalID']) . '</td>' . "\n" . ' </tr>' . "\n"; if ($order->delivery['delivery_method_class'] == 'slf') { echo ' <tr>' . "\n" . ' <td align="right" class="smallText">' . tep_draw_pull_down_menu('update_delivery_self_address_id', $self_delivery_addresses, $order->delivery['delivery_self_address_id']) . '</td>' . "\n" . ' <td class="smallText"> </td>' . "\n" . ' </tr>' . "\n"; } } else { echo ' <tr>' . "\n" . ' <td align="right" class="smallText">' . tep_draw_input_field('update_totals[' . $TotalIndex . '][title]', trim($TotalDetails['Name']), 'size="' . strlen(trim($TotalDetails['Name'])) . '" style="text-align: right;"') . '</td>' . "\n" . ' <td class="smallText">' . tep_draw_input_field('update_totals[' . $TotalIndex . '][value]', $TotalDetails['Price'], 'size="6" style="text-align: right;"') . ($order->info['currency'] != DEFAULT_CURRENCY && tep_not_null($TotalDetails['Price']) ? ' (' . $currencies->format($TotalDetails['Price'] / $order->info['currency_value']) . ')' : '') . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][class]', $TotalDetails['Class']) . tep_draw_hidden_field('update_totals[' . $TotalIndex . '][total_id]', $TotalDetails['TotalID']) . '</td>' . "\n" . ' </tr>' . "\n"; } } if ($order->info['currency'] != DEFAULT_CURRENCY) { echo ' <tr>' . "\n" . ' <td colspan="2">' . tep_draw_separator('pixel_trans.gif', '1', '1') . '</td>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td align="right" class="smallText"><strong>' . ENTRY_CURRENCY_EXCHANGE_RATE . '</strong></td>' . "\n" . ' <td class="smallText"><strong>' . tep_round($order->info['currency_value'], 4) . '</strong></td>' . "\n" . ' </tr>' . "\n"; } ?> </table></td> </tr> <!-- End Order Total Block --> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?> </td> </tr> <tr> <td class="main"><table border="0" cellspacing="1" cellpadding="5">
function collect_posts() { // All tep_redirect URL parameters modified for this function in v5.13 by Rigadin global $_POST, $customer_id, $currencies, $cc_id; if ($_POST['gv_redeem_code']) { // get some info from the coupon table $coupon_query = tep_db_query("select coupon_id, coupon_amount, coupon_type, coupon_minimum_order,uses_per_coupon, uses_per_user, restrict_to_products,restrict_to_categories from " . TABLE_COUPONS . " where coupon_code='" . $_POST['gv_redeem_code'] . "' and coupon_active='Y'"); $coupon_result = tep_db_fetch_array($coupon_query); if ($coupon_result['coupon_type'] != 'G') { if (tep_db_num_rows($coupon_query) == 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_NO_INVALID_REDEEM_COUPON), 'SSL')); } $date_query = tep_db_query("select coupon_start_date from " . TABLE_COUPONS . " where coupon_start_date <= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'"); if (tep_db_num_rows($date_query) == 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_STARTDATE_COUPON), 'SSL')); } $date_query = tep_db_query("select coupon_expire_date from " . TABLE_COUPONS . " where coupon_expire_date >= now() and coupon_code='" . $_POST['gv_redeem_code'] . "'"); if (tep_db_num_rows($date_query) == 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_FINISDATE_COUPON), 'SSL')); } $coupon_count = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "'"); $coupon_count_customer = tep_db_query("select coupon_id from " . TABLE_COUPON_REDEEM_TRACK . " where coupon_id = '" . $coupon_result['coupon_id'] . "' and customer_id = '" . $customer_id . "'"); if (tep_db_num_rows($coupon_count) >= $coupon_result['uses_per_coupon'] && $coupon_result['uses_per_coupon'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_USES_COUPON . $coupon_result['uses_per_coupon'] . TIMES), 'SSL')); } if (tep_db_num_rows($coupon_count_customer) >= $coupon_result['uses_per_user'] && $coupon_result['uses_per_user'] > 0) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_INVALID_USES_USER_COUPON . $coupon_result['uses_per_user'] . TIMES), 'SSL')); } //**si** 09-11-05 /* if ($coupon_result['coupon_type']=='S') { $coupon_amount = $order->info['shipping_cost']; } else { $coupon_amount = $currencies->format($coupon_result['coupon_amount']) . ' '; } if ($coupon_result['coupon_type']=='P') $coupon_amount = $coupon_result['coupon_amount'] . '% '; if ($coupon_result['coupon_minimum_order']>0) $coupon_amount .= 'on orders greater than ' . $coupon_result['coupon_minimum_order']; if (!tep_session_is_registered('cc_id')) tep_session_register('cc_id'); //Fred - this was commented out before $cc_id = $coupon_result['coupon_id']; //Fred ADDED, set the global and session variable tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error='.$this->code.'&error=' . urlencode(ERROR_REDEEMED_AMOUNT), 'SSL')); // Added in v5.13a by Rigadin */ global $order, $ot_coupon, $currency; // BEGIN >>> CCVG 5.15 - Custom Modification - fix Coupon code redemption error // Moved code up a few lines if (!tep_session_is_registered('cc_id')) { tep_session_register('cc_id'); } $cc_id = $coupon_result['coupon_id']; // END <<< CCVG 5.15 - Custom Modification - fix Coupon code redemption error $coupon_amount = tep_round($ot_coupon->pre_confirmation_check($order->info['subtotal']), $currencies->currencies[$currency]['decimal_places']); // $cc_id /* you will need to uncomment this if your tax order total module is AFTER shipping eg you have all of your tax, including tax from shipping module, in your tax total. if ($coupon_result['coupon_type']=='S') { //if not zero rated add vat to shipping $coupon_amount = tep_add_tax($coupon_amount, '17.5'); } */ $coupon_amount_out = $currencies->format($coupon_amount) . ' '; if ($coupon_result['coupon_minimum_order'] > 0) { $coupon_amount_out .= 'on orders greater than ' . $currencies->format($coupon_result['coupon_minimum_order']); } if (!tep_session_is_registered('cc_id')) { tep_session_register('cc_id'); } $cc_id = $coupon_result['coupon_id']; if (strlen($cc_id) > 0 && $coupon_amount == 0) { $err_msg = ERROR_REDEEMED_AMOUNT . ERROR_REDEEMED_AMOUNT_ZERO; } else { $err_msg = ERROR_REDEEMED_AMOUNT . $coupon_amount_out; } tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode($err_msg), 'SSL')); //**si** 09-11-05 end // $_SESSION['cc_id'] = $coupon_result['coupon_id']; //Fred commented out, do not use $_SESSION[] due to backward comp. Reference the global var instead. } // ENDIF valid coupon code } // ENDIF code entered // v5.13a If no code entered and coupon redeem button pressed, give an alarm if ($_POST['submit_redeem_coupon_x']) { tep_redirect(tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code . '&error=' . urlencode(ERROR_NO_REDEEM_CODE), 'SSL')); } }
function calculate_price($products_price, $products_tax, $quantity = 1) { global $currency; return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity; }
$affiliate = tep_db_fetch_array($affiliate_query); $affiliate_percent = 0; $affiliate_percent = $affiliate['affiliate_commission_percent']; if ($affiliate_percent < AFFILIATE_PERCENT) { $affiliate_percent = AFFILIATE_PERCENT; } $affiliate_clickthroughs_raw = "select count(*) as count from " . TABLE_AFFILIATE_CLICKTHROUGHS . " where affiliate_id = '" . $_GET['acID'] . "'"; $affiliate_clickthroughs_query = tep_db_query($affiliate_clickthroughs_raw); $affiliate_clickthroughs = tep_db_fetch_array($affiliate_clickthroughs_query); $affiliate_clickthroughs = $affiliate_clickthroughs['count']; $affiliate_sales_raw = "\n select count(*) as count, sum(affiliate_value) as total, sum(affiliate_payment) as payment from " . TABLE_AFFILIATE_SALES . " a \n left join " . TABLE_ORDERS . " o on (a.affiliate_orders_id=o.orders_id) \n where a.affiliate_id = '" . $_GET['acID'] . "' and o.orders_status >= " . AFFILIATE_PAYMENT_ORDER_MIN_STATUS . "\n "; $affiliate_sales_query = tep_db_query($affiliate_sales_raw); $affiliate_sales = tep_db_fetch_array($affiliate_sales_query); $affiliate_transactions = $affiliate_sales['count']; if ($affiliate_clickthroughs > 0) { $affiliate_conversions = tep_round($affiliate_transactions / $affiliate_clickthroughs * 100, 2) . "%"; } else { $affiliate_conversions = "n/a"; } if ($affiliate_sales['total'] > 0) { $affiliate_average = $affiliate_sales['total'] / $affiliate_sales['count']; } else { $affiliate_average = 0; } ?> <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html <?php echo HTML_PARAMS; ?> > <head>
} $affiliate_total = tep_round($affiliate_total, 2); // Check for individual commission $affiliate_percentage = 0; if (AFFILATE_INDIVIDUAL_PERCENTAGE == 'true') { $affiliate_commission_query = tep_db_query("select affiliate_commission_percent from " . TABLE_AFFILIATE . " where affiliate_id = '" . $affiliate_ref . "'"); $affiliate_commission = tep_db_fetch_array($affiliate_commission_query); $affiliate_percent = $affiliate_commission['affiliate_commission_percent']; } if ($affiliate_percent < AFFILIATE_PERCENT) { $affiliate_percent = AFFILIATE_PERCENT; } $affiliate_payment = tep_round($affiliate_total * $affiliate_percent / 100, 2); if ($_SESSION['affiliate_ref']) { $sql_data_array = array('affiliate_id' => $affiliate_ref, 'affiliate_date' => $affiliate_clientdate, 'affiliate_browser' => $affiliate_clientbrowser, 'affiliate_ipaddress' => $affiliate_clientip, 'affiliate_value' => $affiliate_total, 'affiliate_payment' => $affiliate_payment, 'affiliate_orders_id' => $insert_id, 'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id, 'affiliate_percent' => $affiliate_percent, 'affiliate_salesman' => $affiliate_ref); tep_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array); if (AFFILATE_USE_TIER == 'true') { $affiliate_tiers_query = tep_db_query("SELECT aa2.affiliate_id, (aa2.affiliate_rgt - aa2.affiliate_lft) as height\r\n FROM affiliate_affiliate AS aa1, affiliate_affiliate AS aa2\r\n WHERE aa1.affiliate_root = aa2.affiliate_root \r\n AND aa1.affiliate_lft BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt\r\n AND aa1.affiliate_rgt BETWEEN aa2.affiliate_lft AND aa2.affiliate_rgt\r\n AND aa1.affiliate_id = '" . $affiliate_ref . "'\r\n ORDER by height asc limit 1, " . AFFILIATE_TIER_LEVELS . " \r\n "); $affiliate_tier_percentage = split("[;]", AFFILIATE_TIER_PERCENTAGE); $i = 0; while ($affiliate_tiers_array = tep_db_fetch_array($affiliate_tiers_query)) { $affiliate_percent = $affiliate_tier_percentage[$i]; $affiliate_payment = tep_round($affiliate_total * $affiliate_percent / 100, 2); if ($affiliate_payment > 0) { $sql_data_array = array('affiliate_id' => $affiliate_tiers_array['affiliate_id'], 'affiliate_date' => $affiliate_clientdate, 'affiliate_browser' => $affiliate_clientbrowser, 'affiliate_ipaddress' => $affiliate_clientip, 'affiliate_value' => $affiliate_total, 'affiliate_payment' => $affiliate_payment, 'affiliate_orders_id' => $insert_id, 'affiliate_clickthroughs_id' => $affiliate_clickthroughs_id, 'affiliate_percent' => $affiliate_percent, 'affiliate_salesman' => $affiliate_ref); tep_db_perform(TABLE_AFFILIATE_SALES, $sql_data_array); } $i++; } } }
function tep_calculate_tax($price, $tax) { global $currencies; return tep_round($price * $tax / 100, 2); }
function display_price($products_price, $products_tax, $quantity = 1, $currency_type = DEFAULT_CURRENCY) { return $this->format(tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency_type]['decimal_places']) * $quantity); }