• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP zen_get_tax_description函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: calculate_deductions

 function calculate_deductions($order_total)
 {
     global $db, $order, $messageStack;
     $od_amount = array();
     $deduction = $this->calculate_credit($this->get_order_total());
     $od_amount['total'] = $deduction;
     switch ($this->calculate_tax) {
         case 'None':
             $remainder = $order->info['total'] - $od_amount['total'];
             $tax_deduct = $order->info['tax'] - $remainder;
             // division by 0
             if ($order->info['tax'] <= 0) {
                 $ratio_tax = 0;
             } else {
                 $ratio_tax = $tax_deduct / $order->info['tax'];
             }
             $tax_deduct = 0;
             /*
                     if ($this->include_tax) {
                       reset($order->info['tax_groups']);
                       foreach ($order->info['tax_groups'] as $key=>$value) {
                         $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio_tax;
                         $tax_deduct += $od_amount['tax_groups'][$key];
                       }
                     }
             */
             $od_amount['tax'] = $tax_deduct;
             break;
         case 'Standard':
             if ($od_amount['total'] >= $order_total) {
                 $ratio = 1;
             } else {
                 $ratio = $od_amount['total'] / ($order_total - $order->info['tax']);
             }
             reset($order->info['tax_groups']);
             $tax_deduct = 0;
             foreach ($order->info['tax_groups'] as $key => $value) {
                 $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
                 $tax_deduct += $od_amount['tax_groups'][$key];
             }
             $od_amount['tax'] = $tax_deduct;
             break;
         case 'Credit Note':
             $od_amount['total'] = $deduction;
             $tax_rate = zen_get_tax_rate($this->tax_class);
             $od_amount['tax'] = zen_calculate_tax($deduction, $tax_rate);
             $tax_description = zen_get_tax_description($this->tax_class);
             $od_amount['tax_groups'][$tax_description] = $od_amount['tax'];
             break;
         default:
     }
     return $od_amount;
 }
开发者ID:promoweb,项目名称:zc-v1-series,代码行数:53,代码来源:ot_gv.php


示例2: ot_shipping

 function ot_shipping()
 {
     global $order, $currencies;
     $this->code = 'ot_shipping';
     $this->title = MODULE_ORDER_TOTAL_SHIPPING_TITLE;
     $this->description = MODULE_ORDER_TOTAL_SHIPPING_DESCRIPTION;
     $this->sort_order = MODULE_ORDER_TOTAL_SHIPPING_SORT_ORDER;
     unset($_SESSION['shipping_tax_description']);
     $this->output = array();
     if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
             $order->info['shipping_method'] = $this->title;
             $order->info['total'] -= $order->info['shipping_cost'];
             $order->info['shipping_cost'] = 0;
         }
     }
     $module = isset($_SESSION['shipping']) && isset($_SESSION['shipping']['id']) ? substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_')) : '';
     if (is_object($order) && zen_not_null($order->info['shipping_method'])) {
         if ($GLOBALS[$module]->tax_class > 0) {
             if (!isset($GLOBALS[$module]->tax_basis)) {
                 $shipping_tax_basis = STORE_SHIPPING_TAX_BASIS;
             } else {
                 $shipping_tax_basis = $GLOBALS[$module]->tax_basis;
             }
             if ($shipping_tax_basis == 'Billing') {
                 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
             } elseif ($shipping_tax_basis == 'Shipping') {
                 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             } else {
                 if (STORE_ZONE == $order->billing['zone_id']) {
                     $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                     $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                 } elseif (STORE_ZONE == $order->delivery['zone_id']) {
                     $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                     $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 } else {
                     $shipping_tax = 0;
                 }
             }
             $shipping_tax_amount = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $order->info['shipping_tax'] += $shipping_tax_amount;
             $order->info['tax'] += $shipping_tax_amount;
             $order->info['tax_groups']["{$shipping_tax_description}"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $order->info['total'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $_SESSION['shipping_tax_description'] = $shipping_tax_description;
             $_SESSION['shipping_tax_amount'] = $shipping_tax_amount;
             if (DISPLAY_PRICE_WITH_TAX == 'true') {
                 $order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             }
         }
         if ($_SESSION['shipping']['id'] == 'free_free') {
             $order->info['shipping_method'] = FREE_SHIPPING_TITLE;
             $order->info['shipping_cost'] = 0;
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkzc,代码行数:76,代码来源:ot_shipping.php


示例3: calculate_deductions

 function calculate_deductions($order_total)
 {
     global $db, $order;
     $od_amount = array();
     if ($order_total == 0) {
         return $od_amount;
     }
     $orderTotal = $this->get_order_total();
     $orderTotalTax = $orderTotal['tax'];
     $taxGroups = $orderTotal['taxGroups'];
     $group_query = $db->Execute("select customers_group_pricing from " . TABLE_CUSTOMERS . " where customers_id = '" . (int) $_SESSION['customer_id'] . "'");
     if ($group_query->fields['customers_group_pricing'] != '0') {
         $group_discount = $db->Execute("select group_name, group_percentage from " . TABLE_GROUP_PRICING . "\n                                      where group_id = '" . (int) $group_query->fields['customers_group_pricing'] . "'");
         $gift_vouchers = $_SESSION['cart']->gv_only();
         $discount = ($orderTotal['total'] - $gift_vouchers) * $group_discount->fields['group_percentage'] / 100;
         //      echo "discout = $discount<br>";
         $od_amount['total'] = round($discount, 2);
         $ratio = $od_amount['total'] / $order_total;
         /**
          * when calculating the ratio add some insignificant values to stop divide by zero errors
          */
         switch ($this->calculate_tax) {
             case 'None':
                 if ($this->include_tax) {
                     reset($order->info['tax_groups']);
                     foreach ($order->info['tax_groups'] as $key => $value) {
                         $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
                     }
                 }
                 break;
             case 'Standard':
                 if ($od_amount['total'] >= $order_total) {
                     $ratio = 1;
                 }
                 $adjustedTax = $orderTotalTax * $ratio;
                 if ($order->info['tax'] == 0) {
                     return $od_amount;
                 }
                 $ratioTax = $orderTotalTax != 0 ? $adjustedTax / $orderTotalTax : 0;
                 reset($order->info['tax_groups']);
                 $tax_deduct = 0;
                 foreach ($taxGroups as $key => $value) {
                     $od_amount['tax_groups'][$key] = $value * $ratioTax;
                     $tax_deduct += $od_amount['tax_groups'][$key];
                 }
                 $od_amount['tax'] = $tax_deduct;
                 break;
             case 'Credit Note':
                 $tax_rate = zen_get_tax_rate($this->tax_class);
                 $od_amount['tax'] = zen_calculate_tax($od_amount['total'], $tax_rate);
                 $tax_description = zen_get_tax_description($this->tax_class);
                 $od_amount['tax_groups'][$tax_description] = $od_amount['tax'];
                 break;
         }
     }
     return $od_amount;
 }
开发者ID:R-Future,项目名称:zencart,代码行数:57,代码来源:ot_group_pricing.php


示例4: process

 function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == 'true') {
         switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         //        if ( ($pass == true) && ( ($order->info['total'] - $order->info['shipping_cost']) < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) {
         if ($pass == true && $order->info['subtotal'] < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
             $charge_it = 'true';
             $cart_content_type = $_SESSION['cart']->get_content_type();
             $gv_content_only = $_SESSION['cart']->gv_only();
             if ($cart_content_type == 'physical' or $cart_content_type == 'mixed') {
                 $charge_it = 'true';
             } else {
                 // check to see if everything is virtual, if so - skip the low order fee.
                 if ($cart_content_type == 'virtual' and MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL == 'true') {
                     $charge_it = 'false';
                     if ($gv_content_only > 0 and MODULE_ORDER_TOTAL_LOWORDERFEE_GV == 'false') {
                         $charge_it = 'true';
                     }
                 }
                 if ($gv_content_only > 0 and MODULE_ORDER_TOTAL_LOWORDERFEE_GV == 'true') {
                     // check to see if everything is gift voucher, if so - skip the low order fee.
                     $charge_it = 'false';
                     if ($cart_content_type == 'virtual' and MODULE_ORDER_TOTAL_LOWORDERFEE_VIRTUAL == 'false') {
                         $charge_it = 'true';
                     }
                 }
             }
             if ($charge_it == 'true') {
                 $tax_address = zen_get_tax_locations();
                 $tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
                 $tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $tax_address['country_id'], $tax_address['zone_id']);
                 // calculate from flat fee or percentage
                 if (substr(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, -1) == '%') {
                     $low_order_fee = $order->info['subtotal'] * (MODULE_ORDER_TOTAL_LOWORDERFEE_FEE / 100);
                 } else {
                     $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE;
                 }
                 $order->info['tax'] += zen_calculate_tax($low_order_fee, $tax);
                 $order->info['tax_groups']["{$tax_description}"] += zen_calculate_tax($low_order_fee, $tax);
                 $order->info['total'] += $low_order_fee + zen_calculate_tax($low_order_fee, $tax);
                 if (DISPLAY_PRICE_WITH_TAX == 'true') {
                     $low_order_fee += zen_calculate_tax($low_order_fee, $tax);
                 }
                 $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format($low_order_fee, true, $order->info['currency'], $order->info['currency_value']), 'value' => $low_order_fee);
             }
         }
     }
 }
开发者ID:ygeneration666,项目名称:ec,代码行数:66,代码来源:ot_loworderfee.php


示例5: process

 function process()
 {
     global $order, $currencies;
     if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true') {
         switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) {
             case 'national':
                 if ($order->delivery['country_id'] == STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'international':
                 if ($order->delivery['country_id'] != STORE_COUNTRY) {
                     $pass = true;
                 }
                 break;
             case 'both':
                 $pass = true;
                 break;
             default:
                 $pass = false;
                 break;
         }
         if ($pass == true && $order->info['total'] - $order->info['shipping_cost'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) {
             $order->info['shipping_method'] = $this->title;
             $order->info['total'] -= $order->info['shipping_cost'];
             $order->info['shipping_cost'] = 0;
         }
     }
     $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
     if (zen_not_null($order->info['shipping_method'])) {
         if ($GLOBALS[$module]->tax_class > 0) {
             if (!defined($GLOBALS[$module]->tax_basis)) {
                 $shipping_tax_basis = STORE_SHIPPING_TAX_BASIS;
             } else {
                 $shipping_tax_basis = $GLOBALS[$module]->tax_basis;
             }
             if ($shipping_tax_basis == 'Billing') {
                 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
             } elseif ($shipping_tax_basis == 'Shipping') {
                 $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
             } else {
                 if (STORE_ZONE == $order->billing['zone_id']) {
                     $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                     $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
                 } elseif (STORE_ZONE == $order->delivery['zone_id']) {
                     $shipping_tax = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                     $shipping_tax_description = zen_get_tax_description($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
                 } else {
                     $shipping_tax = 0;
                 }
             }
             $order->info['tax'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $order->info['tax_groups']["{$shipping_tax_description}"] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             $order->info['total'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             if (DISPLAY_PRICE_WITH_TAX == 'true') {
                 $order->info['shipping_cost'] += zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
             }
         }
         if ($_SESSION['shipping'] == 'free_free') {
             $order->info['shipping_method'] = FREE_SHIPPING_TITLE;
         }
         $this->output[] = array('title' => $order->info['shipping_method'] . ':', 'text' => $currencies->format($order->info['shipping_cost'], true, $order->info['currency'], $order->info['currency_value']), 'value' => $order->info['shipping_cost']);
     }
 }
开发者ID:homework-bazaar,项目名称:zencart-sugu,代码行数:66,代码来源:ot_shipping.php


示例6: process

 function process()
 {
     global $order, $currencies, $cod_cost, $cod_country, $shipping;
     if ($this->enabled == true) {
         //Will become true, if cod can be processed.
         $cod_country = false;
         //check if payment method is cod. If yes, check if cod is possible.
         if ($_SESSION['payment'] == 'cod') {
             //process installed shipping modules
             if (substr_count($_SESSION['shipping']['id'], 'flat') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FLAT);
             }
             if (substr_count($_SESSION['shipping']['id'], 'free') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREE);
             }
             if (substr_count($_SESSION['shipping']['id'], 'freeshipper') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREESHIPPER);
             }
             if (substr_count($_SESSION['shipping']['id'], 'freeoptions') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FREEOPTIONS);
             }
             if (substr_count($_SESSION['shipping']['id'], 'item') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ITEM);
             }
             if (substr_count($_SESSION['shipping']['id'], 'perweightunit') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_PERWEIGHTUNIT);
             }
             if (substr_count($_SESSION['shipping']['id'], 'table') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_TABLE);
             }
             if (substr_count($_SESSION['shipping']['id'], 'ups') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_UPS);
             }
             if (substr_count($_SESSION['shipping']['id'], 'usps') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_USPS);
             }
             if (substr_count($_SESSION['shipping']['id'], 'fedex') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_FEDEX);
             }
             if (substr_count($_SESSION['shipping']['id'], 'zones') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_ZONES);
             }
             if (substr_count($_SESSION['shipping']['id'], 'ap') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_AP);
             }
             if (substr_count($_SESSION['shipping']['id'], 'dp') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_DP);
             }
             //satt inn av Pompel
             if (substr_count($_SESSION['shipping']['id'], 'servicepakke') != 0) {
                 $cod_zones = preg_split("/[:,]/", MODULE_ORDER_TOTAL_COD_FEE_SERVICEPAKKE);
             }
             for ($i = 0; $i < count($cod_zones); $i++) {
                 if ($cod_zones[$i] == $order->delivery['country']['iso_code_2']) {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     //print('match' . $i . ': ' . $cod_cost);
                     break;
                 } elseif ($cod_zones[$i] == '00') {
                     $cod_cost = $cod_zones[$i + 1];
                     $cod_country = true;
                     //print('match' . $i . ': ' . $cod_cost);
                     break;
                 } else {
                     //print('no match');
                 }
                 $i++;
             }
         } else {
             //COD selected, but no shipping module which offers COD
         }
         if ($cod_country) {
             $cod_tax_address = zen_get_tax_locations();
             $tax = zen_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $cod_tax_address['country_id'], $cod_tax_address['zone_id']);
             $order->info['total'] += $cod_cost;
             if ($tax > 0) {
                 $tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $cod_tax_address['country_id'], $cod_tax_address['zone_id']);
                 $order->info['tax'] += zen_calculate_tax($cod_cost, $tax);
                 $order->info['tax_groups'][$tax_description] += zen_calculate_tax($cod_cost, $tax);
                 $order->info['total'] += zen_calculate_tax($cod_cost, $tax);
                 if (DISPLAY_PRICE_WITH_TAX == 'true') {
                     $cod_cost += zen_calculate_tax($cod_cost, $tax);
                 }
             }
             $this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format($cod_cost, true, $order->info['currency'], $order->info['currency_value']), 'value' => $cod_cost);
         } else {
             //Following code should be improved if we can't get the shipping modules disabled, who don't allow COD
             // as well as countries who do not have cod
             //          $this->output[] = array('title' => $this->title . ':',
             //                                  'text' => 'No COD for this module.',
             //                                  'value' => '');
         }
     }
 }
开发者ID:kirkbauer2,项目名称:kirkzc,代码行数:94,代码来源:ot_cod_fee.php


示例7: calculate_deductions

 /**
  * Enter description here...
  *
  * @param unknown_type $order_total
  * @return unknown
  */
 function calculate_deductions($order_total)
 {
     global $db, $order, $messageStack, $currencies;
     $tax_address = zen_get_tax_locations();
     $od_amount = array();
     $orderTotalDetails = $this->get_order_total();
     $orderTotalTax = $orderTotalDetails['tax'];
     $orderTotal = $orderTotalDetails['total'];
     if ($_SESSION['cc_id']) {
         $coupon = $db->Execute("select * from " . TABLE_COUPONS . " where coupon_id = '" . (int) $_SESSION['cc_id'] . "'");
         $this->coupon_code = $coupon->fields['coupon_code'];
         if ($coupon->RecordCount() > 0 && $orderTotal != 0 || $coupon->RecordCount() > 0 && $coupon->fields['coupon_type'] == 'S') {
             // left for total order amount vs qualified order amount just switch the commented lines
             //        if ($orderTotalDetails['totalFull'] >= $coupon->fields['coupon_minimum_order']) {
             if (strval($orderTotalDetails['total']) >= $coupon->fields['coupon_minimum_order']) {
                 if ($coupon->fields['coupon_type'] == 'S') {
                     $od_amount['total'] = $_SESSION['shipping']['cost'];
                     $od_amount['type'] = 'S';
                     $od_amount['tax'] = $this->calculate_tax == 'Standard' ? $_SESSION['shipping_tax_amount'] : 0;
                     if (DISPLAY_PRICE_WITH_TAX == 'true') {
                         $od_amount['total'] += $od_amount['tax'];
                     }
                     if (isset($_SESSION['shipping_tax_description']) && $_SESSION['shipping_tax_description'] != '') {
                         $od_amount['tax_groups'][$_SESSION['shipping_tax_description']] = $od_amount['tax'];
                     }
                     return $od_amount;
                 }
                 if ($coupon->fields['coupon_type'] == 'P') {
                     $od_amount['total'] = round($orderTotal * ($coupon->fields['coupon_amount'] / 100), 2);
                     $od_amount['type'] = 'P';
                     $ratio = $od_amount['total'] / $orderTotal;
                 } elseif ($coupon->fields['coupon_type'] == 'F') {
                     $od_amount['total'] = round($coupon->fields['coupon_amount'] * ($orderTotal > 0), 2);
                     $od_amount['type'] = 'F';
                     $ratio = $od_amount['total'] / $orderTotal;
                 }
                 if ($od_amount['total'] > $orderTotal) {
                     $od_amount['total'] = $orderTotal;
                 }
                 switch ($this->calculate_tax) {
                     case 'None':
                         if ($this->include_tax == 'true') {
                             reset($order->info['tax_groups']);
                             foreach ($order->info['tax_groups'] as $key => $value) {
                                 $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratio;
                             }
                         }
                         break;
                     case 'Standard':
                         if ($od_amount['total'] >= $orderTotal) {
                             $ratio = 1;
                         }
                         $adjustedTax = $orderTotalTax * $ratio;
                         //            echo "order total tax = $orderTotalTax";
                         $ratioTax = isset($order->info['tax']) && $order->info['tax'] != 0 ? $adjustedTax / $order->info['tax'] : 0;
                         reset($order->info['tax_groups']);
                         $tax_deduct = 0;
                         foreach ($order->info['tax_groups'] as $key => $value) {
                             $od_amount['tax_groups'][$key] = $order->info['tax_groups'][$key] * $ratioTax;
                             $tax_deduct += $od_amount['tax_groups'][$key];
                         }
                         $od_amount['tax'] = $tax_deduct;
                         break;
                     case 'Credit Note':
                         $tax_rate = zen_get_tax_rate($this->tax_class);
                         $od_amount['tax'] = zen_calculate_tax($od_amount['total'], $tax_rate);
                         $tax_description = zen_get_tax_description($this->tax_class);
                         $od_amount['tax_groups'][$tax_description] = $od_amount['tax'];
                         break;
                     default:
                 }
             } else {
                 $messageStack->add_session('redemptions', sprintf(TEXT_INVALID_REDEEM_COUPON_MINIMUM, $currencies->format($coupon->fields['coupon_minimum_order'])), 'caution');
                 $this->clear_posts();
                 zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL', true, false));
             }
         }
     }
     return $od_amount;
 }
开发者ID:dalinhuang,项目名称:yijinhuanxiang,代码行数:86,代码来源:ot_coupon.php


示例8: calculate_deductions

 function calculate_deductions($order_total)
 {
     global $gBitDb, $gBitCustomer, $order;
     $tax_address = zen_get_tax_locations();
     $od_amount['total'] = 0;
     $od_amount['tax'] = 0;
     if ($_SESSION['cc_id']) {
         $coupon = new CommerceVoucher($_SESSION['cc_id']);
         if ($coupon->load() && $coupon->isRedeemable()) {
             if ($coupon->getField('coupon_minimum_order') <= $order_total) {
                 if ($coupon->getField('coupon_type') == 'S') {
                     if ($coupon->getField('restrict_to_shipping')) {
                         $shippingMethods = explode(',', $coupon->getField('restrict_to_shipping'));
                         if (in_array($order->info['shipping_method_code'], $shippingMethods)) {
                             $od_amount['total'] = $order->info['shipping_cost'];
                         }
                     } else {
                         $od_amount['total'] = $order->info['shipping_cost'];
                     }
                     $od_amount['type'] = 'S';
                 } else {
                     if ($coupon->getField('coupon_type') == 'P') {
                         // Max discount is a sum of percentages of valid products
                         $totalDiscount = 0;
                     } else {
                         $totalDiscount = $coupon->getField('coupon_amount') * ($order_total > 0);
                     }
                     $runningDiscount = 0;
                     $runningDiscountQuantity = 0;
                     foreach (array_keys($gBitCustomer->mCart->contents) as $productKey) {
                         $productHash = $gBitCustomer->mCart->getProductHash($productKey);
                         if ($coupon->getField('quantity_max')) {
                             if ($discountQuantity = $coupon->getField('quantity_max') - $runningDiscountQuantity) {
                                 if ($discountQuantity > $productHash['products_quantity']) {
                                     $discountQuantity = $productHash['products_quantity'];
                                 }
                             }
                         } else {
                             $discountQuantity = $productHash['products_quantity'];
                         }
                         if ($productHash && $discountQuantity && $this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                             // _P_ercentage discount
                             if ($coupon->getField('coupon_type') == 'P') {
                                 $runningDiscountQuantity += $discountQuantity;
                                 $itemDiscount = round($productHash['final_price'] * $discountQuantity * ($coupon->getField('coupon_amount') / 100), 2);
                                 $totalDiscount += $itemDiscount;
                                 if ($runningDiscount < $totalDiscount) {
                                     $runningDiscount += $itemDiscount;
                                 }
                                 if ($runningDiscount > $totalDiscount) {
                                     $runningDiscount = $totalDiscount;
                                     $itemDiscount = 0;
                                 }
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $tax_rate = zen_get_tax_rate($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($productHash['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                         if ($tax_rate > 0) {
                                             if (empty($od_amount[$tax_desc])) {
                                                 $od_amount[$tax_desc] = 0;
                                             }
                                             $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
                                             $od_amount['tax'] += $od_amount[$tax_desc];
                                         }
                                         break;
                                 }
                                 // _F_ixed discount
                             } elseif ($coupon->getField('coupon_type') == 'F') {
                                 switch ($this->calculate_tax) {
                                     case 'Credit Note':
                                         $tax_rate = zen_get_tax_rate($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $tax_desc = zen_get_tax_description($this->tax_class, $tax_address['country_id'], $tax_address['zone_id']);
                                         $od_amount[$tax_desc] = $runningDiscount / 100 * $tax_rate;
                                         $od_amount['tax'] += $od_amount[$tax_desc];
                                         break;
                                     case 'Standard':
                                         $ratio = $runningDiscount / $this->get_order_total();
                                         $t_prid = zen_get_prid($productKey);
                                         $cc_result = $gBitDb->query("select `products_tax_class_id` from " . TABLE_PRODUCTS . " where `products_id` = ?", array($t_prid));
                                         if ($this->is_product_valid($productHash, $_SESSION['cc_id'])) {
                                             if ($runningDiscount < $totalDiscount) {
                                                 $runningDiscount += $productHash['final_price'] * $discountQuantity;
                                             }
                                             if ($runningDiscount > $totalDiscount) {
                                                 $runningDiscount = $totalDiscount;
                                             }
                                             $tax_rate = zen_get_tax_rate($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             $tax_desc = zen_get_tax_description($cc_result->fields['products_tax_class_id'], $tax_address['country_id'], $tax_address['zone_id']);
                                             if ($tax_rate > 0) {
                                                 if (empty($od_amount[$tax_desc])) {
                                                     $od_amount[$tax_desc] = 0;
                                                 }
                                                 $od_amount[$tax_desc] += $productHash['final_price'] * $discountQuantity * $tax_rate / 100 * $ratio;
//.........这里部分代码省略.........
开发者ID:bitweaver,项目名称:commerce,代码行数:101,代码来源:ot_coupon.php


示例9: cart

 function cart()
 {
     global $db, $currencies;
     $this->content_type = $_SESSION['cart']->get_content_type();
     $customer_address_query = "select c.customers_firstname, c.customers_lastname, c.customers_telephone,\r\n                                        c.customers_email_address, ab.entry_company, ab.entry_street_address,\r\n                                        ab.entry_suburb, ab.entry_postcode, ab.entry_city, ab.entry_zone_id,\r\n                                        z.zone_name, co.countries_id, co.countries_name,\r\n                                        co.countries_iso_code_2, co.countries_iso_code_3,\r\n                                        co.address_format_id, ab.entry_state\r\n                                 from " . TABLE_CUSTOMERS . " c, " . TABLE_ADDRESS_BOOK . " ab\r\n                                 left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                 left join " . TABLE_COUNTRIES . " co on (ab.entry_country_id = co.countries_id)\r\n                                 where c.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                 and ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                 and c.customers_default_address_id = ab.address_book_id";
     $customer_address = $db->Execute($customer_address_query);
     $shipping_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,\r\n                                        ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,\r\n                                        ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,\r\n                                        c.countries_id, c.countries_name, c.countries_iso_code_2,\r\n                                        c.countries_iso_code_3, c.address_format_id, ab.entry_state\r\n                                 from " . TABLE_ADDRESS_BOOK . " ab\r\n                                 left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                 left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\r\n                                 where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                 and ab.address_book_id = '" . (int) $_SESSION['sendto'] . "'";
     $shipping_address = $db->Execute($shipping_address_query);
     $billing_address_query = "select ab.entry_firstname, ab.entry_lastname, ab.entry_company,\r\n                                       ab.entry_street_address, ab.entry_suburb, ab.entry_postcode,\r\n                                       ab.entry_city, ab.entry_zone_id, z.zone_name, ab.entry_country_id,\r\n                                       c.countries_id, c.countries_name, c.countries_iso_code_2,\r\n                                       c.countries_iso_code_3, c.address_format_id, ab.entry_state\r\n                                from " . TABLE_ADDRESS_BOOK . " ab\r\n                                left join " . TABLE_ZONES . " z on (ab.entry_zone_id = z.zone_id)\r\n                                left join " . TABLE_COUNTRIES . " c on (ab.entry_country_id = c.countries_id)\r\n                                where ab.customers_id = '" . (int) $_SESSION['customer_id'] . "'\r\n                                and ab.address_book_id = '" . (int) $_SESSION['billto'] . "'";
     $billing_address = $db->Execute($billing_address_query);
     //STORE_PRODUCT_TAX_BASIS
     switch (STORE_PRODUCT_TAX_BASIS) {
         case 'Shipping':
             $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);
             break;
         case 'Billing':
             $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 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP zen_get_tax_locations函数代码示例发布时间:2022-05-23
下一篇:
PHP zen_get_show_product_switch函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap