当前位置: 首页>>代码示例>>PHP>>正文


PHP zen_round函数代码示例

本文整理汇总了PHP中zen_round函数的典型用法代码示例。如果您正苦于以下问题:PHP zen_round函数的具体用法?PHP zen_round怎么用?PHP zen_round使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了zen_round函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: zen_calculate_tax

function zen_calculate_tax($price, $tax)
{
    global $currencies;
    //    $result = bcmul($price, $tax, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    //    $result = bcdiv($result, 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    //    return $result;
    return zen_round($price * $tax / 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
开发者ID:sgkohata,项目名称:zencart-sugu,代码行数:8,代码来源:functions_taxes.php

示例2: value

 function value($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '')
 {
     if (empty($currency_type)) {
         $currency_type = $_SESSION['currency'];
     }
     if ($calculate_currency_value == true) {
         if ($currency_type == DEFAULT_CURRENCY) {
             $rate = zen_not_null($currency_value) ? $currency_value : 1 / $this->currencies[$_SESSION['currency']]['value'];
         } else {
             $rate = zen_not_null($currency_value) ? $currency_value : $this->currencies[$currency_type]['value'];
         }
         $currency_value = zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']);
     } else {
         $currency_value = zen_round($number, $this->currencies[$currency_type]['decimal_places']);
     }
     return $currency_value;
 }
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:17,代码来源:currencies.php

示例3: process

 function process()
 {
     global $order, $currencies;
     if ($this->enabled && $this->selection_test()) {
         $order_total = $this->get_order_total();
         $this->deduction = $this->calculate_credit($order_total);
         // Calculate the credit to be applied
         $order->info['total'] = zen_round($order->info['total'] - $this->deduction, 2);
         if ($this->deduction > 0 && $this->selection_test()) {
             $this->output[] = array('title' => $this->title . ':', 'text' => '-' . $currencies->format($this->deduction), 'value' => $this->deduction);
         }
         if ($this->deduction >= $order->info['total']) {
             $_SESSION['credit_covers'] = true;
         } else {
             $_SESSION['credit_covers'] = false;
         }
     } else {
         $_SESSION['credit_covers'] = false;
     }
 }
开发者ID:happyxlq,项目名称:lt_svn,代码行数:20,代码来源:ot_sc.php

示例4: get_products_attributes

    function get_products_attributes($products_id, $languageId = 1)
    {
        global $db;
        // Added the following to query "and pa.attributes_display_only != 1" This removed read only attributes from the stock selection.
        $query = '	select pa.products_attributes_id, pa.options_values_price, pa.price_prefix,
			 				po.products_options_name, pov.products_options_values_name
			 			from ' . TABLE_PRODUCTS_ATTRIBUTES . ' pa
			 			left join ' . TABLE_PRODUCTS_OPTIONS . ' po on (pa.options_id = po.products_options_id)
			 			left join ' . TABLE_PRODUCTS_OPTIONS_VALUES . ' pov on (pa.options_values_id = pov.products_options_values_id)
			 			where pa.products_id = "' . $products_id . '" 
			 				AND po.language_id = "' . $languageId . '" and po.language_id = pov.language_id
							and pa.attributes_display_only != 1';
        $attributes = $db->Execute($query);
        if ($attributes->RecordCount() > 0) {
            while (!$attributes->EOF) {
                $attributes_array[$attributes->fields['products_options_name']][] = array('id' => $attributes->fields['products_attributes_id'], 'text' => $attributes->fields['products_options_values_name'] . ' (' . $attributes->fields['price_prefix'] . '$' . zen_round($attributes->fields['options_values_price'], 2) . ')');
                $attributes->MoveNext();
            }
            return $attributes_array;
        } else {
            return false;
        }
    }
开发者ID:badarac,项目名称:stock_by_attribute_1.5.4,代码行数:23,代码来源:products_with_attributes_stock.php

示例5: before_process

 /**
  * Prepare and submit the authorization to the gateway
  */
 function before_process()
 {
     global $order, $order_totals, $db, $messageStack, $lp_avs, $lp_trans_num;
     $myorder = array();
     // Calculate the next expected order id
     $last_order_id = $db->Execute("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
     $new_order_id = $last_order_id->fields['orders_id'];
     $new_order_id = $new_order_id + 1;
     // add randomized suffix to order id to produce uniqueness ... since it's unwise to submit the same order-number twice to the gateway
     $new_order_id = (string) $new_order_id . '-' . zen_create_random_value(6);
     // Build Info to send to Gateway
     $myorder["result"] = "LIVE";
     switch (MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE) {
         case "TESTING: Successful":
             $myorder["result"] = "GOOD";
             break;
         case "TESTING: Decline":
             $myorder["result"] = "DECLINE";
             break;
         case "TESTING: Duplicate":
             $myorder["result"] = "DUPLICATE";
             break;
     }
     // "oid" - Order ID number must be unique. If not set, gateway will assign one.
     //$oid = zen_create_random_value(16, 'digits'); // Create a UID for the order
     $myorder["oid"] = $new_order_id;
     //"";    // time(); ????
     // prepare totals for submission
     $surcharges = 0;
     $creditsApplied = 0;
     global $order_totals;
     reset($order_totals);
     $myorder['subtotal'] = $myorder['tax'] = $myorder['shipping'] = $myorder['chargetotal'] = 0;
     for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
         if ($order_totals[$i]['code'] == '') {
             continue;
         }
         if (in_array($order_totals[$i]['code'], array('ot_total', 'ot_subtotal', 'ot_tax', 'ot_shipping'))) {
             if ($order_totals[$i]['code'] == 'ot_subtotal') {
                 $myorder["subtotal"] = round($order_totals[$i]['value'], 2);
             }
             if ($order_totals[$i]['code'] == 'ot_tax') {
                 $myorder["tax"] += round($order_totals[$i]['value'], 2);
             }
             if ($order_totals[$i]['code'] == 'ot_shipping') {
                 $myorder["shipping"] = round($order_totals[$i]['value'], 2);
             }
             if ($order_totals[$i]['code'] == 'ot_total') {
                 $myorder["chargetotal"] = round($order_totals[$i]['value'], 2);
             }
         } else {
             global ${$order_totals[$i]['code']};
             if (substr($order_totals[$i]['text'], 0, 1) == '-' || isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true) {
                 $creditsApplied += round($order_totals[$i]['value'], 2);
             } else {
                 $surcharges += round($order_totals[$i]['value'], 2);
             }
         }
     }
     foreach (array('subtotal', 'tax', 'chargetotal', 'shipping') as $i) {
         if (isset($myorder[$i])) {
             $myorder[$i] = number_format($myorder[$i], 2, '.', '');
         }
     }
     if ($surcharges == 0 && $creditsApplied == 0 && $order->info['total'] >= $order->info['subtotal'] && sizeof($order->products) <= 20) {
         // itemized contents
         $num_line_items = 0;
         reset($order->products);
         for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
             $num_line_items++;
             $myorder["items"][$num_line_items]['id'] = $order->products[$i]['id'];
             $myorder["items"][$num_line_items]['description'] = substr(htmlentities($order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 128);
             $myorder["items"][$num_line_items]['quantity'] = $order->products[$i]['qty'];
             $myorder["items"][$num_line_items]['price'] = number_format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), 2, '.', '');
             // check and adjust for fractional quantities, which cannot be submitted as line-item details
             $q = $order->products[$i]['qty'];
             $q1 = strval($q);
             $q2 = (int) $q;
             $q3 = strval($q2);
             if ($q1 != $q3 || $myorder["items"][$num_line_items]['quantity'] * $myorder["items"][$num_line_items]['price'] != number_format($order->products[$i]['qty'] * $order->products[$i]['final_price'], 2, '.', '')) {
                 $myorder["items"][$num_line_items]['quantity'] = 1;
                 $myorder["items"][$num_line_items]['price'] = number_format(zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $decimals) * $order->products[$i]['qty'], 2, '.', '');
                 $myorder["items"][$num_line_items]['description'] = '(' . $order->products[$i]['qty'] . ' x )' . substr($myorder["items"][$num_line_items]['description'], 115);
             }
             if (isset($order->products[$i]['attributes'])) {
                 $options_text_length = 0;
                 for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j++) {
                     $options_text_length += strlen($order->products[$i]['attributes'][$j]['option'] . $order->products[$i]['attributes'][$j]['value']);
                 }
                 if ($options_text_length < 128) {
                     for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j++) {
                         $myorder["items"][$num_line_items]['options' . $j]['name'] = substr(htmlentities($order->products[$i]['attributes'][$j]['option'], ENT_QUOTES, 'UTF-8'), 0, 128);
                         $myorder["items"][$num_line_items]['options' . $j]['value'] = substr(htmlentities($order->products[$i]['attributes'][$j]['value'], ENT_QUOTES, 'UTF-8'), 0, 128);
                     }
                 }
             }
             // track one-time charges
//.........这里部分代码省略.........
开发者ID:kirkbauer2,项目名称:kirkzc,代码行数:101,代码来源:linkpoint_api.php

示例6: average_product_reviews_font_awesome

/**
 * @param $average
 * @return string
 */
function average_product_reviews_font_awesome($average)
{
    $reviews_string = '';
    $rating = zen_round($average * 2, 0) / 2;
    $full_stars = floor($rating);
    $empty_stars = 5 - ceil($rating);
    $half_stars = 5 - $full_stars - $empty_stars;
    $full_stars_count = 0;
    while ($full_stars != $full_stars_count) {
        $reviews_string .= '<i class="fa fa-star"></i>';
        $full_stars_count++;
    }
    if ($half_stars != 0) {
        $reviews_string .= '<i class="fa fa-star-half-o"></i>';
    }
    $empty_stars_count = 0;
    while ($empty_stars != $empty_stars_count) {
        $reviews_string .= '<i class="fa fa-star"></i>';
        $empty_stars_count++;
    }
    return $reviews_string;
}
开发者ID:bislewl,项目名称:Average-Product-Rating,代码行数:26,代码来源:average_product_reviews.php

示例7: value

 /**
  * Only exists in storefront
  *
  * @copyright Copyright 2003-2010 Zen Cart Development Team
  * @copyright Portions Copyright 2003 osCommerce
  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  */
 public function value($number, $calculate_value = true, $currency_type = '', $currency_value = '')
 {
     if (empty($currency_type)) {
         $currency_type = $this->getSessionVar('currency');
     }
     if ($calculate_value) {
         if ($currency_type == DEFAULT_CURRENCY) {
             $rate = $currency_value ?: 1 / $this->currencies[$this->getSessionVar('currency')]['value'];
         } else {
             $rate = $currency_value ?: $this->currencies[$currency_type]['value'];
         }
         $currency_value = zen_round($number * $rate, $this->currencies[$currency_type]['decimal_places']);
     } else {
         $currency_value = zen_round($number, $this->currencies[$currency_type]['decimal_places']);
     }
     return $currency_value;
 }
开发者ID:zenmagick,项目名称:zenmagick,代码行数:24,代码来源:Currencies.php

示例8: attributes_price


//.........这里部分代码省略.........
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
             $attributes_price = 0;
             $attribute_price_query = "select *\n                                    from " . TABLE_PRODUCTS_ATTRIBUTES . "\n                                    where products_id = '" . (int) $products_id . "'\n                                    and options_id = '" . (int) $option . "'\n                                    and options_values_id = '" . (int) $value . "'";
             $attribute_price = $db->Execute($attribute_price_query);
             // Dual Pricing start
             if ($_SESSION['customer_id']) {
                 $customers_id = $_SESSION['customer_id'];
                 $customer_check = $db->Execute("select * from " . TABLE_CUSTOMERS . " where customers_id = '{$customers_id}'");
                 if ($customer_check->fields['customers_whole'] != "0") {
                     $i = $customer_check->fields['customers_whole'];
                     $i--;
                     $options_value_price = (double) $attribute_price->fields['options_values_price_w'];
                 } else {
                     $options_value_price = $attribute_price->fields['options_values_price'];
                 }
             } else {
                 $options_value_price = $attribute_price->fields['options_values_price'];
             }
             // Dual Pricing end
             $new_attributes_price = 0;
             $discount_type_id = '';
             $sale_maker_discount = '';
             //          if ($attribute_price->fields['product_attribute_is_free']) {
             if ($attribute_price->fields['product_attribute_is_free'] == '1' and zen_get_products_price_is_free((int) $products_id)) {
                 // no charge
             } else {
                 // + or blank adds
                 if ($attribute_price->fields['price_prefix'] == '-') {
                     // calculate proper discount for attributes
                     if ($attribute_price->fields['attributes_discounted'] == '1') {
                         $discount_type_id = '';
                         $sale_maker_discount = '';
                         $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
                         $attributes_price -= $new_attributes_price;
                     } else {
                         $attributes_price -= $attribute_price->fields['options_values_price'];
                     }
                 } else {
                     if ($attribute_price->fields['attributes_discounted'] == '1') {
                         // calculate proper discount for attributes
                         $discount_type_id = '';
                         $sale_maker_discount = '';
                         $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
                         // Dual Pricing start
                         if ($_SESSION['customer_id']) {
                             if ($customer_check->fields['customers_whole'] != "0") {
                                 $new_attributes_price = zen_get_discount_calc($products_id, $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price_w'], $qty);
                             }
                         }
                         // Dual Pricing end
                         $attributes_price += $new_attributes_price;
                     } else {
                         $attributes_price += $attribute_price->fields['options_values_price'];
                     }
                 }
                 //////////////////////////////////////////////////
                 // calculate additional charges
                 // products_options_value_text
                 if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) {
                     $text_words = zen_get_word_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']);
                     $text_letters = zen_get_letters_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']);
                     $attributes_price += $text_letters;
                     $attributes_price += $text_words;
                 }
                 // attributes_price_factor
                 $added_charge = 0;
                 if ($attribute_price->fields['attributes_price_factor'] > 0) {
                     $chk_price = zen_get_products_base_price($products_id);
                     $chk_special = zen_get_products_special_price($products_id, false);
                     $added_charge = zen_get_attributes_price_factor($chk_price, $chk_special, $attribute_price->fields['attributes_price_factor'], $attribute_price->fields['attributes_price_factor_offset']);
                     $attributes_price += $added_charge;
                 }
                 // attributes_qty_prices
                 $added_charge = 0;
                 if ($attribute_price->fields['attributes_qty_prices'] != '') {
                     $chk_price = zen_get_products_base_price($products_id);
                     $chk_special = zen_get_products_special_price($products_id, false);
                     $added_charge = zen_get_attributes_qty_prices_onetime($attribute_price->fields['attributes_qty_prices'], $this->contents[$products_id]['qty']);
                     $attributes_price += $added_charge;
                 }
                 //////////////////////////////////////////////////
             }
             // Validate Attributes
             if ($attribute_price->fields['attributes_display_only']) {
                 $_SESSION['valid_to_checkout'] = false;
                 $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id']) . ERROR_PRODUCT_OPTION_SELECTION . '<br />';
             }
             /*
             //// extra testing not required on text attribute this is done in application_top before it gets to the cart
             if ($attribute_price->fields['attributes_required']) {
             $_SESSION['valid_to_checkout'] = false;
             $_SESSION['cart_errors'] .= zen_get_products_name($attribute_price->fields['products_id'], $_SESSION['languages_id'])  . ERROR_PRODUCT_OPTION_SELECTION . '<br />';
             }
             */
             $total_attributes_price += zen_round($attributes_price, $currencies->get_decimal_places($_SESSION['currency']));
         }
     }
     return $total_attributes_price;
 }
开发者ID:jeking928,项目名称:Dual-Pricing-2.1.6,代码行数:101,代码来源:shopping_cart.php

示例9: quote

 /**
  * Get quote from shipping provider's API:
  *
  * @param string $method
  * @return array of quotation results
  */
 function quote($method = '')
 {
     // BOF: UPS USPS
     global $order, $shipping_weight, $shipping_num_boxes, $transittime;
     if (zen_not_null($method) && (isset($this->types[$method]) || in_array($method, $this->intl_types))) {
         $this->_setService($method);
     }
     // usps doesnt accept zero weight send 1 ounce (0.0625) minimum
     $usps_shipping_weight = $shipping_weight <= 0.0 ? 0.0625 : $shipping_weight;
     $shipping_pounds = floor($usps_shipping_weight);
     $shipping_ounces = 16 * ($usps_shipping_weight - floor($usps_shipping_weight));
     // usps currently cannot handle more than 5 digits on international
     $shipping_ounces = zen_round($shipping_ounces, 3);
     // weight must be less than 35lbs and greater than 6 ounces or it is not machinable
     switch (true) {
         case $shipping_pounds == 0 and $shipping_ounces < 6:
             // override admin choice too light
             $is_machinable = 'False';
             break;
         case $usps_shipping_weight > 35:
             // override admin choice too heavy
             $is_machinable = 'False';
             break;
         default:
             // admin choice on what to use
             $is_machinable = MODULE_SHIPPING_USPS_MACHINABLE;
     }
     $this->_setMachinable($is_machinable);
     $this->_setContainer('None');
     $this->_setSize('REGULAR');
     $this->_setFirstClassType('FLAT');
     $this->_setWeight($shipping_pounds, $shipping_ounces);
     $uspsQuote = $this->_getQuote();
     if (is_array($uspsQuote)) {
         if (isset($uspsQuote['error'])) {
             $this->quotes = array('module' => $this->title, 'error' => $uspsQuote['error']);
         } else {
             // BOF: UPS USPS
             if (in_array('Display weight', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
                 switch (SHIPPING_BOX_WEIGHT_DISPLAY) {
                     case 0:
                         $show_box_weight = '';
                         break;
                     case 1:
                         $show_box_weight = ' (' . $shipping_num_boxes . ' ' . TEXT_SHIPPING_BOXES . ')';
                         break;
                     case 2:
                         $show_box_weight = ' (' . number_format($usps_shipping_weight * $shipping_num_boxes, 2) . TEXT_SHIPPING_WEIGHT . ')';
                         break;
                     default:
                         $show_box_weight = ' (' . $shipping_num_boxes . ' x ' . number_format($usps_shipping_weight, 2) . TEXT_SHIPPING_WEIGHT . ')';
                         break;
                 }
             }
             // EOF: UPS USPS
             // BOF: UPS USPS
             $this->quotes = array('id' => $this->code, 'module' => $this->title . $show_box_weight);
             // EOF: UPS USPS
             $methods = array();
             $size = sizeof($uspsQuote);
             for ($i = 0; $i < $size; $i++) {
                 list($type, $cost) = each($uspsQuote[$i]);
                 // BOF: UPS USPS
                 $title = isset($this->types[$type]) ? $this->types[$type] : $type;
                 if (in_array('Display transit time', explode(', ', MODULE_SHIPPING_USPS_OPTIONS))) {
                     $title .= $transittime[$type];
                 }
                 /*
                 $methods[] = array('id' => $type,
                 'title' => ((isset($this->types[$type])) ? $this->types[$type] : $type),
                 'cost' => ($cost + MODULE_SHIPPING_USPS_HANDLING) * $shipping_num_boxes);
                 */
                 $cost = preg_replace('/[^0-9.]/', '', $cost);
                 $methods[] = array('id' => $type, 'title' => $title, 'cost' => $cost * $shipping_num_boxes + (MODULE_SHIPPING_USPS_HANDLING_METHOD == 'Box' ? MODULE_SHIPPING_USPS_HANDLING * $shipping_num_boxes : MODULE_SHIPPING_USPS_HANDLING));
             }
             $this->quotes['methods'] = $methods;
             if ($this->tax_class > 0) {
                 $this->quotes['tax'] = zen_get_tax_rate($this->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             }
         }
     } elseif ($uspsQuote == -1) {
         $this->quotes = array('module' => $this->title, 'error' => MODULE_SHIPPING_USPS_TEXT_SERVER_ERROR . (MODULE_SHIPPING_USPS_SERVER == 'test' ? MODULE_SHIPPING_USPS_TEXT_TEST_MODE_NOTICE : ''));
     } else {
         $this->quotes = array('module' => $this->title, 'error' => MODULE_SHIPPING_USPS_TEXT_ERROR . (MODULE_SHIPPING_USPS_SERVER == 'test' ? MODULE_SHIPPING_USPS_TEXT_TEST_MODE_NOTICE : ''));
     }
     if (zen_not_null($this->icon)) {
         $this->quotes['icon'] = zen_image($this->icon, $this->title);
     }
     return $this->quotes;
 }
开发者ID:dalinhuang,项目名称:yijinhuanxiang,代码行数:96,代码来源:usps.php

示例10: calculate_credit

 /**
  * Calculate GV claim amount (GV amounts are always based on the STORE's default currency value)
  */
 function calculate_credit($save_total_cost)
 {
     global $db, $order, $currencies;
     // calculate value based on default currency
     $gv_payment_amount = $currencies->value($_SESSION['cot_gv'], true, DEFAULT_CURRENCY);
     $full_cost = $save_total_cost - $gv_payment_amount;
     if ($full_cost < 0) {
         $full_cost = 0;
         $gv_payment_amount = $save_total_cost;
     }
     return zen_round($gv_payment_amount, 2);
 }
开发者ID:promoweb,项目名称:zc-v1-series,代码行数:15,代码来源:ot_gv.php

示例11: cart


//.........这里部分代码省略.........
             $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\r\n                                from " . TABLE_ADDRESS_BOOK . " ab\r\n                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
             $tax_address = $db->Execute($tax_address_query);
             break;
         case 'Store':
             if ($billing_address->fields['entry_zone_id'] == STORE_ZONE) {
                 $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\r\n                                  from " . TABLE_ADDRESS_BOOK . " ab\r\n                                  left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                  where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                  and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
             } else {
                 $tax_address_query = "select ab.entry_country_id, ab.entry_zone_id\r\n                                  from " . TABLE_ADDRESS_BOOK . " ab\r\n                                  left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                  where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                  and ab.address_book_id = '" . (int) ($this->content_type == 'virtual' ? $_SESSION['billto'] : $_SESSION['sendto']) . "'";
             }
             $tax_address = $db->Execute($tax_address_query);
     }
     $class =& $_SESSION['payment'];
     if (isset($_SESSION['cc_id'])) {
         $coupon_code_query = "select coupon_code\r\n                              from " . TABLE_COUPONS . "\r\n                              where coupon_id = '" . (int) $_SESSION['cc_id'] . "'";
         $coupon_code = $db->Execute($coupon_code_query);
     }
     $this->info = array('order_status' => DEFAULT_ORDERS_STATUS_ID, 'currency' => $_SESSION['currency'], 'currency_value' => $currencies->currencies[$_SESSION['currency']]['value'], 'payment_method' => $GLOBALS[$class]->title, 'payment_module_code' => $GLOBALS[$class]->code, 'coupon_code' => $coupon_code->fields['coupon_code'], 'shipping_method' => $_SESSION['shipping']['title'], 'shipping_module_code' => $_SESSION['shipping']['id'], 'shipping_cost' => $_SESSION['shipping']['cost'], 'subtotal' => 0, 'tax' => 0, 'total' => 0, 'tax_groups' => array(), 'comments' => isset($_SESSION['comments']) ? $_SESSION['comments'] : '', 'ip_address' => $_SERVER['REMOTE_ADDR']);
     //print_r($GLOBALS[$class]);
     //echo $class;
     //print_r($GLOBALS);
     //echo $_SESSION['payment'];
     /*
     // this is set above to the module filename it should be set to the module title like Checks/Money Order rather than moneyorder
           if (isset($$_SESSION['payment']) && is_object($$_SESSION['payment'])) {
             $this->info['payment_method'] = $$_SESSION['payment']->title;
           }
     */
     if ($this->info['total'] == 0) {
         if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
             $this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;
         } else {
             $this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
         }
     }
     if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) {
         if (isset($GLOBALS[$class]->order_status) && is_numeric($GLOBALS[$class]->order_status) && $GLOBALS[$class]->order_status > 0) {
             $this->info['order_status'] = $GLOBALS[$class]->order_status;
         }
     }
     $this->customer = array('firstname' => $customer_address->fields['customers_firstname'], 'lastname' => $customer_address->fields['customers_lastname'], 'company' => $customer_address->fields['entry_company'], 'street_address' => $customer_address->fields['entry_street_address'], 'suburb' => $customer_address->fields['entry_suburb'], 'city' => $customer_address->fields['entry_city'], 'postcode' => $customer_address->fields['entry_postcode'], 'state' => zen_not_null($customer_address->fields['entry_state']) ? $customer_address->fields['entry_state'] : $customer_address->fields['zone_name'], 'zone_id' => $customer_address->fields['entry_zone_id'], 'country' => array('id' => $customer_address->fields['countries_id'], 'title' => $customer_address->fields['countries_name'], 'iso_code_2' => $customer_address->fields['countries_iso_code_2'], 'iso_code_3' => $customer_address->fields['countries_iso_code_3']), 'format_id' => $customer_address->fields['address_format_id'], 'telephone' => $customer_address->fields['customers_telephone'], 'email_address' => $customer_address->fields['customers_email_address']);
     $this->delivery = array('firstname' => $shipping_address->fields['entry_firstname'], 'lastname' => $shipping_address->fields['entry_lastname'], 'company' => $shipping_address->fields['entry_company'], 'street_address' => $shipping_address->fields['entry_street_address'], 'suburb' => $shipping_address->fields['entry_suburb'], 'city' => $shipping_address->fields['entry_city'], 'postcode' => $shipping_address->fields['entry_postcode'], 'state' => zen_not_null($shipping_address->fields['entry_state']) ? $shipping_address->fields['entry_state'] : $shipping_address->fields['zone_name'], 'zone_id' => $shipping_address->fields['entry_zone_id'], 'country' => array('id' => $shipping_address->fields['countries_id'], 'title' => $shipping_address->fields['countries_name'], 'iso_code_2' => $shipping_address->fields['countries_iso_code_2'], 'iso_code_3' => $shipping_address->fields['countries_iso_code_3']), 'country_id' => $shipping_address->fields['entry_country_id'], 'format_id' => $shipping_address->fields['address_format_id']);
     $this->billing = array('firstname' => $billing_address->fields['entry_firstname'], 'lastname' => $billing_address->fields['entry_lastname'], 'company' => $billing_address->fields['entry_company'], 'street_address' => $billing_address->fields['entry_street_address'], 'suburb' => $billing_address->fields['entry_suburb'], 'city' => $billing_address->fields['entry_city'], 'postcode' => $billing_address->fields['entry_postcode'], 'state' => zen_not_null($billing_address->fields['entry_state']) ? $billing_address->fields['entry_state'] : $billing_address->fields['zone_name'], 'zone_id' => $billing_address->fields['entry_zone_id'], 'country' => array('id' => $billing_address->fields['countries_id'], 'title' => $billing_address->fields['countries_name'], 'iso_code_2' => $billing_address->fields['countries_iso_code_2'], 'iso_code_3' => $billing_address->fields['countries_iso_code_3']), 'country_id' => $billing_address->fields['entry_country_id'], 'format_id' => $billing_address->fields['address_format_id']);
     $index = 0;
     $products = $_SESSION['cart']->get_products();
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => zen_get_tax_rate($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price($products[$i]['id']), 'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']), 'weight' => $products[$i]['weight'], 'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'], 'product_is_free' => $products[$i]['product_is_free'], 'products_discount_type' => $products[$i]['products_discount_type'], 'products_discount_type_from' => $products[$i]['products_discount_type_from'], 'id' => $products[$i]['id']);
         if ($products[$i]['attributes']) {
             $subindex = 0;
             reset($products[$i]['attributes']);
             while (list($option, $value) = each($products[$i]['attributes'])) {
                 /*
                 	//clr 030714 Determine if attribute is a text attribute and change products array if it is.
                             if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
                               $attr_value = $products[$i]['attributes_values'][$option];
                             } else {
                               $attr_value = $attributes->fields['products_options_values_name'];
                             }
                 */
                 $attributes_query = "select popt.products_options_name, poval.products_options_values_name,\r\n                                        pa.options_values_price, pa.price_prefix\r\n                                 from " . TABLE_PRODUCTS_OPTIONS . " popt,\r\n                                      " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,\r\n                                      " . TABLE_PRODUCTS_ATTRIBUTES . " pa\r\n                                 where pa.products_id = '" . (int) $products[$i]['id'] . "'\r\n                                 and pa.options_id = '" . (int) $option . "'\r\n                                 and pa.options_id = popt.products_options_id\r\n                                 and pa.options_values_id = '" . (int) $value . "'\r\n                                 and pa.options_values_id = poval.products_options_values_id\r\n                                 and popt.language_id = '" . (int) $_SESSION['languages_id'] . "'\r\n                                 and poval.language_id = '" . (int) $_SESSION['languages_id'] . "'";
                 $attributes = $db->Execute($attributes_query);
                 //clr 030714 Determine if attribute is a text attribute and change products array if it is.
                 if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID) {
                     $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                     $attr_value = $attributes->fields['products_options_values_name'];
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options_name'], 'value' => $attr_value, 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes->fields['price_prefix'], 'price' => $attributes->fields['options_values_price']);
                 $subindex++;
             }
         }
         // add onetime charges here
         //$_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity'])
         $shown_price = zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'] + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
         $this->info['subtotal'] += $shown_price;
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if (DISPLAY_PRICE_WITH_TAX == 'true') {
             $this->info['tax'] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
             if (isset($this->info['tax_groups']["{$products_tax_description}"])) {
                 $this->info['tax_groups']["{$products_tax_description}"] += $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
             } else {
                 $this->info['tax_groups']["{$products_tax_description}"] = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
             }
         } else {
             $this->info['tax'] += $products_tax / 100 * $shown_price;
             if (isset($this->info['tax_groups']["{$products_tax_description}"])) {
                 $this->info['tax_groups']["{$products_tax_description}"] += $products_tax / 100 * $shown_price;
             } else {
                 $this->info['tax_groups']["{$products_tax_description}"] = $products_tax / 100 * $shown_price;
             }
         }
         $this->info['tax'] = zen_round($this->info['tax'], 2);
         $index++;
     }
     if (DISPLAY_PRICE_WITH_TAX == 'true') {
         $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
     } else {
         $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
     }
 }
开发者ID:severnaya99,项目名称:Sg-2010,代码行数:101,代码来源:order.php

示例12: cart


//.........这里部分代码省略.........
     $products = $_SESSION['cart']->get_products(true);
     for ($i = 0, $n = sizeof($products); $i < $n; $i++) {
         if ($i / 2 == floor($i / 2)) {
             $rowClass = "rowEven";
         } else {
             $rowClass = "rowOdd";
         }
         $this->products[$index] = array('qty' => $products[$i]['quantity'], 'name' => $products[$i]['name'], 'model' => $products[$i]['model'], 'tax' => zen_get_tax_rate($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'tax_description' => zen_get_tax_description($products[$i]['tax_class_id'], $tax_address->fields['entry_country_id'], $tax_address->fields['entry_zone_id']), 'price' => $products[$i]['price'], 'final_price' => $products[$i]['price'] + $_SESSION['cart']->attributes_price(zen_get_uprid($products[$i]['id'], $products[$i]['attributes'])), 'onetime_charges' => $_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity']), 'weight' => $products[$i]['weight'], 'products_priced_by_attribute' => $products[$i]['products_priced_by_attribute'], 'product_is_free' => $products[$i]['product_is_free'], 'products_discount_type' => $products[$i]['products_discount_type'], 'products_discount_type_from' => $products[$i]['products_discount_type_from'], 'id' => $products[$i]['id'], 'rowClass' => $rowClass);
         if ($products[$i]['attributes']) {
             $subindex = 0;
             reset($products[$i]['attributes']);
             while (list($option, $value) = each($products[$i]['attributes'])) {
                 /*
                 //clr 030714 Determine if attribute is a text attribute and change products array if it is.
                 if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID){
                 $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                 $attr_value = $attributes->fields['products_options_values_name'];
                 }
                 */
                 $attributes_query = "select popt.products_options_name, poval.products_options_values_name,\n\n                                          pa.options_values_price, pa.price_prefix\n\n                                   from " . TABLE_PRODUCTS_OPTIONS . " popt,\n\n                                        " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval,\n\n                                        " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\n                                   where pa.products_id = '" . (int) $products[$i]['id'] . "'\n\n                                   and pa.options_id = '" . (int) $option . "'\n\n                                   and pa.options_id = popt.products_options_id\n\n                                   and pa.options_values_id = '" . (int) $value . "'\n\n                                   and pa.options_values_id = poval.products_options_values_id\n\n                                   and popt.language_id = '" . (int) $_SESSION['languages_id'] . "'\n\n                                   and poval.language_id = '" . (int) $_SESSION['languages_id'] . "'";
                 $attributes = $db->Execute($attributes_query);
                 //clr 030714 Determine if attribute is a text attribute and change products array if it is.
                 if ($value == PRODUCTS_OPTIONS_VALUES_TEXT_ID) {
                     $attr_value = $products[$i]['attributes_values'][$option];
                 } else {
                     $attr_value = $attributes->fields['products_options_values_name'];
                 }
                 $this->products[$index]['attributes'][$subindex] = array('option' => $attributes->fields['products_options_name'], 'value' => $attr_value, 'option_id' => $option, 'value_id' => $value, 'prefix' => $attributes->fields['price_prefix'], 'price' => $attributes->fields['options_values_price']);
                 $subindex++;
             }
         }
         // add onetime charges here
         //$_SESSION['cart']->attributes_price_onetime_charges($products[$i]['id'], $products[$i]['quantity'])
         /*********************************************
          * Calculate taxes for this product
          *********************************************/
         $shown_price = zen_add_tax($this->products[$index]['final_price'], $this->products[$index]['tax']) * $this->products[$index]['qty'] + zen_add_tax($this->products[$index]['onetime_charges'], $this->products[$index]['tax']);
         $this->info['subtotal'] += $shown_price;
         // find product's tax rate and description
         $products_tax = $this->products[$index]['tax'];
         $products_tax_description = $this->products[$index]['tax_description'];
         if (DISPLAY_PRICE_WITH_TAX == 'true') {
             // calculate the amount of tax "inc"luded in price (used if tax-in pricing is enabled)
             $tax_add = $shown_price - $shown_price / ($products_tax < 10 ? "1.0" . str_replace('.', '', $products_tax) : "1." . str_replace('.', '', $products_tax));
         } else {
             // calculate the amount of tax for this product (assuming tax is NOT included in the price)
             $tax_add = zen_round($products_tax / 100 * $shown_price, $currencies->currencies[$this->info['currency']]['decimal_places']);
         }
         $this->info['tax'] += $tax_add;
         if (isset($this->info['tax_groups'][$products_tax_description])) {
             $this->info['tax_groups'][$products_tax_description] += $tax_add;
         } else {
             $this->info['tax_groups'][$products_tax_description] = $tax_add;
         }
         /*********************************************
          * END: Calculate taxes for this product
          *********************************************/
         $index++;
     }
     // Update the final total to include tax if not already tax-inc
     if (DISPLAY_PRICE_WITH_TAX == 'true') {
         if ($_SESSION['insurance'] != "") {
             //判断保险是否选中 2011-3-29 du
             if ($_SESSION['insurance'] == 1) {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'] + $this->info['subtotal'] * 0.031;
             } else {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
             }
         } else {
             $this->info['total'] = $this->info['subtotal'] + $this->info['shipping_cost'];
         }
     } else {
         if ($_SESSION['insurance'] != "") {
             //判断保险是否选中 2011-3-29 du
             if ($_SESSION['insurance'] == 1) {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'] + $this->info['subtotal'] * 0.031;
             } else {
                 $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
             }
         } else {
             $this->info['total'] = $this->info['subtotal'] + $this->info['tax'] + $this->info['shipping_cost'];
         }
     }
     /*
     // moved to function create
         if ($this->info['total'] == 0) {
           if (DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID == 0) {
             $this->info['order_status'] = DEFAULT_ORDERS_STATUS_ID;
           } else {
             $this->info['order_status'] = DEFAULT_ZERO_BALANCE_ORDERS_STATUS_ID;
           }
         }
     */
     if (isset($GLOBALS[$class]) && is_object($GLOBALS[$class])) {
         if (isset($GLOBALS[$class]->order_status) && is_numeric($GLOBALS[$class]->order_status) && $GLOBALS[$class]->order_status > 0) {
             $this->info['order_status'] = $GLOBALS[$class]->order_status;
         }
     }
 }
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:101,代码来源:order.php

示例13: calculate_boxes_weight_and_tare

 function calculate_boxes_weight_and_tare()
 {
     global $total_weight, $shipping_weight, $shipping_quoted, $shipping_num_boxes;
     $this->abort_legacy_calculations = FALSE;
     $this->notify('NOTIFY_SHIPPING_MODULE_PRE_CALCULATE_BOXES_AND_TARE');
     if ($this->abort_legacy_calculations) {
         return;
     }
     if (is_array($this->modules)) {
         $shipping_quoted = '';
         $shipping_num_boxes = 1;
         $shipping_weight = $total_weight;
         $za_tare_array = preg_split("/[:,]/", SHIPPING_BOX_WEIGHT);
         $zc_tare_percent = $za_tare_array[0];
         $zc_tare_weight = $za_tare_array[1];
         $za_large_array = preg_split("/[:,]/", SHIPPING_BOX_PADDING);
         $zc_large_percent = $za_large_array[0];
         $zc_large_weight = $za_large_array[1];
         // SHIPPING_BOX_WEIGHT = tare
         // SHIPPING_BOX_PADDING = Large Box % increase
         // SHIPPING_MAX_WEIGHT = Largest package
         /*
         if (SHIPPING_BOX_WEIGHT >= $shipping_weight*SHIPPING_BOX_PADDING/100) {
           $shipping_weight = $shipping_weight+SHIPPING_BOX_WEIGHT;
         } else {
           $shipping_weight = $shipping_weight + ($shipping_weight*SHIPPING_BOX_PADDING/100);
         }
         */
         switch (true) {
             // large box add padding
             case SHIPPING_MAX_WEIGHT <= $shipping_weight:
                 $shipping_weight = $shipping_weight + $shipping_weight * ($zc_large_percent / 100) + $zc_large_weight;
                 break;
             default:
                 // add tare weight < large
                 $shipping_weight = $shipping_weight + $shipping_weight * ($zc_tare_percent / 100) + $zc_tare_weight;
                 break;
         }
         if ($shipping_weight > SHIPPING_MAX_WEIGHT) {
             // Split into many boxes
             //        $shipping_num_boxes = ceil($shipping_weight/SHIPPING_MAX_WEIGHT);
             $zc_boxes = zen_round($shipping_weight / SHIPPING_MAX_WEIGHT, 2);
             $shipping_num_boxes = ceil($zc_boxes);
             $shipping_weight = $shipping_weight / $shipping_num_boxes;
         }
     }
     $this->notify('NOTIFY_SHIPPING_MODULE_CALCULATE_BOXES_AND_TARE');
 }
开发者ID:ygeneration666,项目名称:ec,代码行数:48,代码来源:shipping.php

示例14: zen_add_tax_invoice

function zen_add_tax_invoice($price, $tax)
{
    global $currencies;
    return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
}
开发者ID:KopjeKoffie,项目名称:VAT-mod-for-european-companies-on-Zen-Cart,代码行数:5,代码来源:functions_vatmod.php

示例15: zen_display_tax_value

        }
      }
      echo '            </td>' . "\n" .
           '            <td class="dataTableContent" valign="middle">' . $order->products[$i]['model'] . '</td>' . "\n" .
           '            <td class="dataTableContent" align="right" valign="middle">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
           '            <td class="dataTableContent" align="right" valign="middle"><strong>' .
                          $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) .
// (Formating modified for Super Orders)
                          ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                        '</strong></td>' . "\n" .
           '            <td class="dataTableContent" align="right" valign="middle"><strong>' .
                          $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) .
                          ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
                        '</strong></td>' . "\n" .
           '            <td class="dataTableContent" align="right" valign="middle"><strong>' .
                          $currencies->format(zen_round($order->products[$i]['final_price'], $currencies->get_decimal_places($order->info['currency']))  * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) .
                          ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format($order->products[$i]['onetime_charges'], true, $order->info['currency'], $order->info['currency_value']) : '') .
                        '</strong></td>' . "\n" .
           '            <td class="dataTableContent" align="right" valign="middle"><strong>' .
                          $priceIncTax .
                          ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') .
// (Formating modified for Super Orders)
                        '</strong></td>' . "\n";
      echo '          </tr>' . "\n";
    }
?>
<!-- End Products Detail //-->
          <tr>
            <?php 
	    		if ($parent_child->fields['split_from_order']) {
			 ?>
开发者ID:quangn92,项目名称:visualyou,代码行数:31,代码来源:orders.php


注:本文中的zen_round函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。