本文整理汇总了PHP中tep_round函数的典型用法代码示例。如果您正苦于以下问题:PHP tep_round函数的具体用法?PHP tep_round怎么用?PHP tep_round使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了tep_round函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculate_price
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;
}
示例2: calculate_credit
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;
}
示例3: format
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;
}
示例4: displayPrice
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);
}
示例5: format_raw
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'], '.', '');
}
示例6: format_raw
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;
}
示例7: calculate_discount
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;
}
示例8: process_button
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;
}
示例9: quote
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;
}
示例10: get_currency_value
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;
}
示例11: tep_calculate_tax
function tep_calculate_tax($price, $tax) {
global $currencies;
return tep_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
示例12: count
$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>';
示例13: tep_round
<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>';
?>
示例14: calculate_credit
//.........这里部分代码省略.........
}
// 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);
}
示例15: tep_get_price_with_tax
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;
}