本文整理汇总了PHP中zen_get_tax_locations函数的典型用法代码示例。如果您正苦于以下问题:PHP zen_get_tax_locations函数的具体用法?PHP zen_get_tax_locations怎么用?PHP zen_get_tax_locations使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zen_get_tax_locations函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculate_tax_deduction
function calculate_tax_deduction($amount, $od_amount, $method, $finalise = false)
{
global $order;
$tax_address = zen_get_tax_locations();
switch ($method) {
case 'Standard':
if ($amount == 0) {
$ratio1 = 0;
} else {
$ratio1 = zen_round($od_amount / $amount, 2);
}
$tod_amount = 0;
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups'])) {
$tax_rate = zen_get_tax_rate_from_desc($key, $tax_address['country_id'], $tax_address['zone_id']);
$total_net += $tax_rate * $value;
}
if ($od_amount > $total_net) {
$od_amount = $total_net;
}
reset($order->info['tax_groups']);
while (list($key, $value) = each($order->info['tax_groups'])) {
$tax_rate = zen_get_tax_rate_from_desc($key, $tax_address['country_id'], $tax_address['zone_id']);
$net = $tax_rate * $value;
if ($net > 0) {
$god_amount = $value * $ratio1;
$tod_amount += $god_amount;
if ($finalise) {
$order->info['tax_groups'][$key] = $order->info['tax_groups'][$key] - $god_amount;
}
}
}
if ($finalise) {
$order->info['tax'] -= $tod_amount;
}
if ($finalise) {
$order->info['total'] -= $tod_amount;
}
break;
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']);
$tod_amount = $this->deduction / (100 + $tax_rate) * $tax_rate;
if ($finalise) {
$order->info['tax_groups'][$tax_desc] -= $tod_amount;
}
if ($finalise) {
$order->info['tax'] -= $tod_amount;
}
if ($finalise) {
$order->info['total'] -= $tod_amount;
}
break;
default:
}
return zen_round($tod_amount, 2);
}
示例2: process
function process()
{
global $order, $currencies;
reset($order->info['tax_groups']);
$taxDescription = '';
$taxValue = 0;
if (STORE_TAX_DISPLAY_STATUS == 1) {
$taxAddress = zen_get_tax_locations();
$result = zen_get_all_tax_descriptions($taxAddress['country_id'], $taxAddress['zone_id']);
if (count($result) > 0) {
foreach ($result as $description) {
if (!isset($order->info['tax_groups'][$description])) {
$order->info['tax_groups'][$description] = 0;
}
}
}
}
if (count($order->info['tax_groups']) > 1 && isset($order->info['tax_groups'][0])) {
unset($order->info['tax_groups'][0]);
}
while (list($key, $value) = each($order->info['tax_groups'])) {
if (SHOW_SPLIT_TAX_CHECKOUT == 'true') {
if ($value > 0 or $value == 0 && STORE_TAX_DISPLAY_STATUS == 1) {
$this->output[] = array('title' => (is_numeric($key) && $key == 0 ? TEXT_UNKNOWN_TAX_RATE : $key) . ':', 'text' => $currencies->format($value, true, $order->info['currency'], $order->info['currency_value']), 'value' => $value);
}
} else {
if ($value > 0 || $value == 0 && STORE_TAX_DISPLAY_STATUS == 1) {
$taxDescription .= (is_numeric($key) && $key == 0 ? TEXT_UNKNOWN_TAX_RATE : $key) . ' + ';
$taxValue += $value;
}
}
}
if (SHOW_SPLIT_TAX_CHECKOUT != 'true' && ($taxValue > 0 or STORE_TAX_DISPLAY_STATUS == 1)) {
$this->output[] = array('title' => substr($taxDescription, 0, strlen($taxDescription) - 3) . ':', 'text' => $currencies->format($taxValue, true, $order->info['currency'], $order->info['currency_value']), 'value' => $taxValue);
}
}
示例3: 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);
}
}
}
}
示例4: 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' => '');
}
}
}
示例5: 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;
}
示例6: calculate_deductions
/**
* Enter description here...
*
* @param unknown_type $order_total
* @return unknown
*/
function calculate_deductions($order_total)
{
global $db, $order, $messageStack;
$tax_address = zen_get_tax_locations();
$od_amount = array();
$orderTotal = $this->get_order_total();
$orderTotalTax = $orderTotal['tax'];
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 && $order_total != 0 || $coupon->RecordCount() > 0 && $coupon->fields['coupon_type'] == 'S') {
if ($coupon->fields['coupon_minimum_order'] <= $orderTotal['totalFull']) {
if ($coupon->fields['coupon_type'] == 'S') {
$od_amount['total'] = $_SESSION['shipping']['cost'];
$od_amount['type'] = 'S';
$od_amount['tax'] = $_SESSION['shipping_tax_amount'];
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($order_total * ($coupon->fields['coupon_amount'] / 100), 2);
$od_amount['type'] = 'P';
$ratio = $od_amount['total'] / $order_total;
} elseif ($coupon->fields['coupon_type'] == 'F') {
$od_amount['total'] = $coupon->fields['coupon_amount'] * ($order_total > 0);
$od_amount['type'] = 'F';
$ratio = $od_amount['total'] / $order_total;
}
if ($od_amount['total'] > $order_total) {
$od_amount['total'] = $order_total;
}
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;
$ratioTax = $adjustedTax / $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] * $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:
}
}
}
}
return $od_amount;
}
示例7: calculate_deductions
function calculate_deductions($order_total)
{
global $db, $order, $messageStack;
$tax_address = zen_get_tax_locations();
$od_amount = array();
if ($_SESSION['cc_id']) {
$coupon = $db->Execute("select * from " . TABLE_COUPONS . " where coupon_id = '" . $_SESSION['cc_id'] . "'");
if ($coupon->RecordCount() > 0 && $order_total != 0 || $coupon->RecordCount() > 0 && $coupon->fields['coupon_type'] == 'S') {
if ($coupon->fields['coupon_minimum_order'] <= $order_total) {
if ($coupon->fields['coupon_type'] == 'S') {
$od_amount['total'] = $order->info['shipping_cost'];
$od_amount['type'] = 'S';
} else {
if ($coupon->fields['coupon_type'] == 'P') {
$od_amount['total'] = zen_round($order_total * ($coupon->fields['coupon_amount'] / 100), 2);
} else {
$od_amount['total'] = $coupon->fields['coupon_amount'] * ($order_total > 0);
}
if ($od_amount['total'] > $order_total) {
$od_amount['total'] = $order_total;
}
$products = $_SESSION['cart']->get_products();
for ($i = 0; $i < sizeof($products); $i++) {
// speed up process and store value
$is_valid_results = is_product_valid($products[$i]['id'], $_SESSION['cc_id']);
if ($is_valid_results) {
if ($coupon->fields['coupon_type'] == 'P') {
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] = $od_amount['total'] / 100 * $tax_rate;
$od_amount['tax'] += $od_amount[$tax_desc];
break;
case 'Standard':
$ratio = $od_amount['total'] / $this->get_order_total();
$products = $_SESSION['cart']->get_products();
for ($j = 0; $j < sizeof($products); $j++) {
$t_prid = zen_get_prid($products[$j]['id']);
$cc_result = $db->Execute("select products_tax_class_id\n from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
if ($is_valid_results) {
$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) {
// $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;
$od_amount[$tax_desc] += round(($products[$j]['final_price'] * $products[$j]['quantity'] * $tax_rate + 0.5) / 100 * $ratio, 2);
$od_amount['tax'] += $od_amount[$tax_desc];
}
}
}
break;
default:
}
}
if ($coupon->fields['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] = $od_amount['total'] / 100 * $tax_rate;
$od_amount['tax'] += $od_amount[$tax_desc];
break;
case 'Standard':
$ratio = $od_amount['total'] / $this->get_order_total();
$products = $_SESSION['cart']->get_products();
for ($j = 0; $j < sizeof($products); $j++) {
$t_prid = zen_get_prid($products[$j]['id']);
$cc_result = $db->Execute("select products_tax_class_id\n from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'");
if ($is_valid_results) {
$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) {
// $od_amount[$tax_desc] += (($products[$j]['final_price'] * $products[$j]['quantity']) * $tax_rate)/100 * $ratio;
$od_amount[$tax_desc] += round(($products[$j]['final_price'] * $products[$j]['quantity'] * $tax_rate + 0.5) / 100 * $ratio, 2);
$od_amount['tax'] += $od_amount[$tax_desc];
}
}
}
break;
default:
}
}
}
}
}
}
}
}
return $od_amount;
}
示例8: eo_get_order_by_id
function eo_get_order_by_id($oID)
{
global $db, $order;
// Retrieve the order
$order = new order($oID);
// Add some required customer information for tax calculation
// The next method has been modified to add required info to the
// session and global variables.
zen_get_tax_locations();
// Cleanup tax_groups in the order (broken code in order.php)
// Shipping module will automatically add tax if needed.
$order->info['tax_groups'] = array();
foreach ($order->products as $product) {
eo_get_product_taxes($product);
}
// Correctly add the running subtotal (broken code in order.php)
if (!array_key_exists('subtotal', $order->info)) {
$query = $db->Execute('SELECT `value` FROM `' . TABLE_ORDERS_TOTAL . '` ' . 'WHERE `orders_id`=\'' . (int) $oID . '\' ' . 'AND `class`=\'ot_subtotal\'');
if (!$query->EOF) {
$order->info['subtotal'] = $query->fields['value'];
}
}
// Convert country portion of addresses to same format used in catalog side
$country = null;
if (array_key_exists('country', $order->customer)) {
$country = eo_get_country($order->customer['country']);
if ($country !== null) {
$order->customer['country'] = $country;
$order->customer['zone_id'] = zen_get_zone_id($order->customer['country']['id'], $order->customer['state']);
}
}
if (array_key_exists('country', $order->delivery)) {
$country = eo_get_country($order->delivery['country']);
if ($country !== null) {
$order->delivery['country'] = $country;
$order->delivery['zone_id'] = zen_get_zone_id($order->delivery['country']['id'], $order->delivery['state']);
}
}
if (array_key_exists('country', $order->billing)) {
$country = eo_get_country($order->billing['country']);
if ($country !== null) {
$order->billing['country'] = $country;
$order->billing['zone_id'] = zen_get_zone_id($order->billing['country']['id'], $order->billing['state']);
}
}
unset($country);
// Handle shipping costs (module will automatically handle tax)
if (!array_key_exists('shipping_cost', $order->info)) {
$query = $db->Execute('SELECT `value` FROM `' . TABLE_ORDERS_TOTAL . '` ' . 'WHERE `orders_id` = \'' . (int) $oID . '\' ' . 'AND `class` = \'ot_shipping\'');
if (!$query->EOF) {
$order->info['shipping_cost'] = $query->fields['value'];
$_SESSION['shipping'] = array('title' => $order->info['shipping_method'], 'id' => $order->info['shipping_module_code'] . '_', 'cost' => $order->info['shipping_cost']);
// Load the shopping cart class into the session
eo_shopping_cart();
// Load the shipping class into the globals
require_once DIR_FS_CATALOG . DIR_WS_CLASSES . 'shipping.php';
$shipping_modules = new shipping($_SESSION['shipping']);
}
}
return $order;
}
示例9: order_total
if (in_array($products[$i]['category'], $resticted_categories)) {
$Gcart->SetButtonVariant(false);
$Gwarnings[] = GOOGLECHECKOUT_STRING_WARN_RESTRICTED_CATEGORY;
break;
}
}
// Coustom Order Totals
// ver el tema del tax...
//$_POST['dc_redeem_code'] = 'ROPU';
require_once DIR_WS_CLASSES . 'order_total.php';
$order_total_modules = new order_total();
$order_total_modules->collect_posts();
$order_total_modules->pre_confirmation_check();
$order_totals = $order_total_modules->process();
//print_r($order_totals);
$tax_address = zen_get_tax_locations();
$ot_used = false;
foreach ($order_totals as $order_total) {
if (!in_array($order_total['code'], $googlepayment->ot_ignore)) {
// Cant used this since the OT is passed as an item, and tax cant be calculated
$tax_class_id = @constant("MODULE_ORDER_TOTAL_" . substr(strtoupper($order_total['code']), 3) . "_TAX_CLASS");
$tax = $db->Execute("select tax_class_title \n from " . TABLE_TAX_CLASS . " \n where tax_class_id = " . makeSqlInteger($tax_class_id));
$tt = @$tax->fields['tax_class_title'];
if (!empty($tt) && !in_array($tax_class_id, $tax_array)) {
$tax_array[] = $tax_class_id;
$tax_name_array[] = $tt;
}
$ot_value = $order_total['value'] * (strrpos($order_total['text'], '-') === false ? 1 : -1);
//($order_total['text']{0}=='-'?-1:1);
$Gitem = new GoogleItem($order_total['title'], '', '1', $currencies->get_value(DEFAULT_CURRENCY) * $ot_value, 'LB', 0);
$Gitem->SetMerchantPrivateItemData(new MerchantPrivateItemData(array('order_total' => base64_encode(serialize($order_total)))));
示例10: 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;
//.........这里部分代码省略.........