本文整理汇总了PHP中zen_calculate_tax函数的典型用法代码示例。如果您正苦于以下问题:PHP zen_calculate_tax函数的具体用法?PHP zen_calculate_tax怎么用?PHP zen_calculate_tax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zen_calculate_tax函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: zen_add_tax
function zen_add_tax($price, $tax)
{
global $currencies;
if (DISPLAY_PRICE_WITH_TAX == 'true' && $tax > 0) {
return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
} else {
return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
}
}
开发者ID:sgkohata,项目名称:zencart-sugu,代码行数:9,代码来源:functions_taxes.php
示例2: 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
示例3: 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
示例4: zen_add_tax
function zen_add_tax($price, $tax)
{
global $currencies;
if (DISPLAY_PRICE_WITH_TAX == 'true' && $tax > 0) {
return $price + zen_calculate_tax($price, $tax);
} else {
return $price;
}
}
开发者ID:R-Future,项目名称:zencart,代码行数:9,代码来源:functions_taxes.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: get_product_price
function get_product_price($product_id)
{
global $db, $order;
$products_id = zen_get_prid($product_id);
// products price
$qty = $_SESSION['cart']->contents[$product_id]['qty'];
$product = $db->Execute("select products_id, products_price, products_tax_class_id, products_weight\n from " . TABLE_PRODUCTS . " where products_id='" . $products_id . "'");
if ($product->RecordCount() > 0) {
$prid = $product->fields['products_id'];
$products_tax = zen_get_tax_rate($product->fields['products_tax_class_id']);
$products_price = $product->fields['products_price'];
$specials = $db->Execute("select specials_new_products_price\n from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'");
if ($specials->RecordCount() > 0) {
$products_price = $specials->fields['specials_new_products_price'];
}
if ($this->include_tax == 'true') {
$total_price += ($products_price + zen_calculate_tax($products_price, $products_tax)) * $qty;
} else {
$total_price += $products_price * $qty;
}
// attributes price
if (isset($_SESSION['cart']->contents[$product_id]['attributes'])) {
reset($_SESSION['cart']->contents[$product_id]['attributes']);
while (list($option, $value) = each($_SESSION['cart']->contents[$product_id]['attributes'])) {
$attribute_price = $db->Execute("select options_values_price, price_prefix\n from " . TABLE_PRODUCTS_ATTRIBUTES . "\n where products_id = '" . $prid . "'\n and options_id = '" . $option . "'\n and options_values_id = '" . $value . "'");
if ($attribute_price->fields['price_prefix'] == '-') {
if ($this->include_tax == 'true') {
$total_price -= $qty * ($attribute_price->fields['options_values_price'] + zen_calculate_tax($attribute_price->fields['options_values_price'], $products_tax));
} else {
$total_price -= $qty * $attribute_price->fields['options_values_price'];
}
} else {
if ($this->include_tax == 'true') {
$total_price += $qty * ($attribute_price->fields['options_values_price'] + zen_calculate_tax($attribute_price->fields['options_values_price'], $products_tax));
} else {
$total_price += $qty * $attribute_price->fields['options_values_price'];
}
}
}
}
}
return $total_price;
}
开发者ID:homework-bazaar,项目名称:zencart-sugu,代码行数:43,代码来源:ot_coupon.php
示例7: getLineItemDetails
/**
* Prepare subtotal and line-item detail content to send to PayPal
*/
function getLineItemDetails()
{
global $order, $currencies, $order_totals, $order_total_modules;
$optionsST = array();
$optionsLI = array();
$onetimeSum = 0;
$onetimeTax = 0;
$creditsApplied = 0;
$creditsTax_applied = 0;
$sumOfLineItems = 0;
$sumOfLineTax = 0;
// prepare subtotals
for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
if ($order_totals[$i]['code'] == 'ot_subtotal') {
$optionsST['ITEMAMT'] = round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_tax') {
$optionsST['TAXAMT'] = round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_shipping') {
$optionsST['SHIPPINGAMT'] = round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_total') {
$optionsST['AMT'] = round($order_totals[$i]['value'], 2);
}
$optionsST['HANDLINGAMT'] = 0;
global ${$order_totals[$i]['code']};
if (isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true) {
$creditsApplied += round($order_totals[$i]['value'], 2);
}
// treat all other OT's as if they're related to handling fees
if (!in_array($order_totals[$i]['code'], array('ot_total', 'ot_subtotal', 'ot_tax', 'ot_shipping')) && !(isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true)) {
$optionsST['HANDLINGAMT'] += $order_totals[$i]['value'];
}
}
// Move shipping tax amount from Tax subtotal into Shipping subtotal for submission to PayPal
$module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_'));
if (zen_not_null($order->info['shipping_method'])) {
if ($GLOBALS[$module]->tax_class > 0) {
$shipping_tax_basis = !isset($GLOBALS[$module]->tax_basis) ? STORE_SHIPPING_TAX_BASIS : $GLOBALS[$module]->tax_basis;
$shippingOnBilling = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->billing['country']['id'], $order->billing['zone_id']);
$shippingOnDelivery = zen_get_tax_rate($GLOBALS[$module]->tax_class, $order->delivery['country']['id'], $order->delivery['zone_id']);
if ($shipping_tax_basis == 'Billing') {
$shipping_tax = $shippingOnBilling;
} elseif ($shipping_tax_basis == 'Shipping') {
$shipping_tax = $shippingOnDelivery;
} else {
if (STORE_ZONE == $order->billing['zone_id']) {
$shipping_tax = $shippingOnBilling;
} elseif (STORE_ZONE == $order->delivery['zone_id']) {
$shipping_tax = $shippingOnDelivery;
} else {
$shipping_tax = 0;
}
}
$taxAdjustmentForShipping = zen_calculate_tax($order->info['shipping_cost'], $shipping_tax);
$optionsST['SHIPPINGAMT'] += $taxAdjustmentForShipping;
$optionsST['TAXAMT'] -= $taxAdjustmentForShipping;
}
}
// loop thru all products to display quantity and price. Appends *** if out-of-stock.
for ($i = 0, $n = sizeof($order->products), $k = 0; $i < $n; $i++, $k++) {
$optionsLI["L_NUMBER{$k}"] = $order->products[$i]['model'];
$optionsLI["L_QTY{$k}"] = (int) $order->products[$i]['qty'];
$optionsLI["L_NAME{$k}"] = $order->products[$i]['name'];
$optionsLI["L_NAME{$k}"] .= zen_get_products_stock($order->products[$i]['id']) - $order->products[$i]['qty'] < 0 ? STOCK_MARK_PRODUCT_OUT_OF_STOCK : '';
// if there are attributes, loop thru them and add to description
if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
$optionsLI["L_NAME{$k}"] .= "\n " . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
}
// end loop
}
// endif attribute-info
$optionsLI["L_AMT{$k}"] = $order->products[$i]['final_price'];
$optionsLI["L_TAXAMT{$k}"] = zen_calculate_tax($order->products[$i]['final_price'], $order->products[$i]['tax']);
// track one-time charges
if ($order->products[$i]['onetime_charges'] != 0) {
$onetimeSum += $order->products[$i]['onetime_charges'];
$onetimeTax += zen_calculate_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']);
}
// Replace & and = with * if found.
$optionsLI["L_NAME{$k}"] = str_replace(array('&', '='), '*', $optionsLI["L_NAME{$k}"]);
$optionsLI["L_NAME{$k}"] = zen_clean_html($optionsLI["L_NAME{$k}"], 'strong');
// reformat properly
$optionsLI["L_NUMBER{$k}"] = substr($optionsLI["L_NUMBER{$k}"], 0, 127);
$optionsLI["L_NAME{$k}"] = substr($optionsLI["L_NAME{$k}"], 0, 127);
$optionsLI["L_AMT{$k}"] = $optionsLI["L_AMT{$k}"];
$optionsLI["L_TAXAMT{$k}"] = round($optionsLI["L_TAXAMT{$k}"], 2);
}
// end for loopthru all products
if ($onetimeSum > 0) {
$i++;
$k++;
$optionsLI["L_NUMBER{$k}"] = $k;
$optionsLI["L_NAME{$k}"] = 'One-Time Charges';
$optionsLI["L_AMT{$k}"] = $onetimeSum;
//.........这里部分代码省略.........
开发者ID:BGCX067,项目名称:ez-commerce-svn-to-git,代码行数:101,代码来源:paypalwpp.php
示例8: 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
示例9: get_order_total
/**
* Enter description here...
*
* @return unknown
*/
function get_order_total()
{
global $order;
$order_total_tax = $order->info['tax'];
$order_total = $order->info['total'];
// echo "order total = $order_total<br>";
// echo "order total shipping = {$order->info['shipping_cost']}<br>";
// echo "order total tax = {$order->info['tax']}<br>";
if ($this->include_shipping != 'true') {
$order_total -= $order->info['shipping_cost'];
}
if ($this->include_shipping != 'true') {
$order_total_tax -= $order->info['shipping_tax'];
}
if ($this->include_tax != 'true') {
$order_total -= $order->info['tax'];
}
// if ($this->include_tax != "true" && $this->include_shipping != 'true') $order_total -= $order->info['shipping_tax'];
// echo "order total = $order_total<br>";
$orderTotalFull = $order_total;
$products = $_SESSION['cart']->get_products();
for ($i = 0; $i < sizeof($products); $i++) {
if (!is_product_valid($products[$i]['id'], $_SESSION['cc_id'])) {
$order_total -= $products[$i]['final_price'] * $products[$i]['quantity'];
if ($this->include_tax == 'true') {
$products_tax = zen_get_tax_rate($products[$i]['tax_class_id']);
$order_total -= zen_calculate_tax($products[$i]['final_price'], $products_tax) * $products[$i]['quantity'];
}
$order_total_tax -= zen_calculate_tax($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id'])) * $products[$i]['quantity'];
}
}
$orderTotalInclusive = $order_total + $order_total_tax;
if (DISPLAY_PRICE_WITH_TAX == 'true') {
$order_total += $order_total_tax;
}
$order_total = array('totalFull' => $orderTotalFull, 'total' => $order_total, 'tax' => $order_total_tax, 'totalInclusive' => $orderTotalInclusive);
return $order_total;
}
开发者ID:dalinhuang,项目名称:yijinhuanxiang,代码行数:43,代码来源:ot_coupon.php
示例10: create_add_products
//.........这里部分代码省略.........
if ($stock_left <= 0) {
// only set status to off when not displaying sold out
if (SHOW_PRODUCTS_SOLD_OUT == '0') {
$db->Execute("update " . TABLE_PRODUCTS . " set products_status = 0 where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
}
}
// for low stock email
if ($stock_left <= STOCK_REORDER_LEVEL) {
// WebMakers.com Added: add to low stock email
$this->email_low_stock .= 'ID# ' . zen_get_prid($this->products[$i]['id']) . ', ' . $this->products[$i]['model'] . ', ' . $this->products[$i]['name'] . ', ' . 'Stock: ' . $stock_left . "\n\n";
// kuroi: trigger and details for attribute low stock email
} elseif ($attribute_stock_left <= STOCK_REORDER_LEVEL) {
$this->email_low_stock .= 'ID# ' . zen_get_prid($this->products[$i]['id']) . ', ' . $this->products[$i]['model'] . ', ' . $this->products[$i]['name'] . ', ';
foreach ($this->products[$i]['attributes'] as $attributes) {
$this->email_low_stock .= $attributes['option'] . ': ' . $attributes['value'] . ', ';
}
$this->email_low_stock .= 'Stock: ' . $attribute_stock_left . "\n\n";
}
}
}
// Update products_ordered (for bestsellers list)
// $db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%d', $order->products[$i]['qty']) . " where products_id = '" . zen_get_prid($order->products[$i]['id']) . "'");
$db->Execute("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . sprintf('%f', $this->products[$i]['qty']) . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
$zco_notifier->notify('NOTIFY_ORDER_PROCESSING_STOCK_DECREMENT_END');
$products_name = $this->products[$i]['name'];
if (strlen($products_name) > 64) {
$products_name = substr($products_name, 0, 64);
}
$sql_data_array = array('orders_id' => $zf_insert_id, 'products_id' => zen_get_prid($this->products[$i]['id']), 'products_model' => $this->products[$i]['model'], 'products_name' => $products_name, 'products_price' => $this->products[$i]['price'], 'final_price' => $this->products[$i]['final_price'], 'onetime_charges' => $this->products[$i]['onetime_charges'], 'products_tax' => $this->products[$i]['tax'], 'products_quantity' => $this->products[$i]['qty'], 'products_priced_by_attribute' => $this->products[$i]['products_priced_by_attribute'], 'product_is_free' => $this->products[$i]['product_is_free'], 'products_discount_type' => $this->products[$i]['products_discount_type'], 'products_discount_type_from' => $this->products[$i]['products_discount_type_from'], 'products_prid' => $this->products[$i]['id']);
zen_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array);
$order_products_id = $db->Insert_ID();
$zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_PRODUCT_LINE_ITEM', array_merge(array('orders_products_id' => $order_products_id), $sql_data_array));
if (FEC_GIFT_WRAPPING_SWITCH == 'true') {
// Gift wrap
$wrap_count = 0;
$wrapsettings = $_SESSION['wrapsettings'];
$prid = $this->products[$i]['id'];
for ($q = 1; $q <= $this->products[$i]['qty']; $q++) {
if (!isset($wrapsettings[$prid][$q]) || $wrapsettings[$prid][$q] == 0) {
continue;
}
$sql_data_array = array('orders_id' => $zf_insert_id, 'orders_products_id' => $order_products_id, 'wrap' => $wrapsettings[$prid][$q]);
zen_db_perform(TABLE_ORDERS_GIFTWRAP, $sql_data_array);
$wrap_count++;
}
// End gift wrap
}
$zco_notifier->notify('NOTIFY_ORDER_PROCESSING_CREDIT_ACCOUNT_UPDATE_BEGIN');
$order_total_modules->update_credit_account($i);
//ICW ADDED FOR CREDIT CLASS SYSTEM
$zco_notifier->notify('NOTIFY_ORDER_PROCESSING_ATTRIBUTES_BEGIN');
//------ bof: insert customer-chosen options to order--------
$attributes_exist = '0';
$this->products_ordered_attributes = '';
if (isset($this->products[$i]['attributes'])) {
$attributes_exist = '1';
for ($j = 0, $n2 = sizeof($this->products[$i]['attributes']); $j < $n2; $j++) {
if (DOWNLOAD_ENABLED == 'true') {
$attributes_query = "select popt.products_options_name, poval.products_options_values_name,\n\n pa.options_values_price, pa.price_prefix,\n\n pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,\n\n pa.attributes_discounted, pa.attributes_price_base_included, pa.attributes_price_onetime,\n\n pa.attributes_price_factor, pa.attributes_price_factor_offset,\n\n pa.attributes_price_factor_onetime, pa.attributes_price_factor_onetime_offset,\n\n pa.attributes_qty_prices, pa.attributes_qty_prices_onetime,\n\n pa.attributes_price_words, pa.attributes_price_words_free,\n\n pa.attributes_price_letters, pa.attributes_price_letters_free,\n\n pad.products_attributes_maxdays, pad.products_attributes_maxcount, pad.products_attributes_filename,\n\n pa.product_attribute_is_free, pa.attributes_discounted\n\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\n left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\n on pa.products_attributes_id=pad.products_attributes_id\n\n where pa.products_id = '" . zen_db_input($this->products[$i]['id']) . "'\n\n and pa.options_id = '" . $this->products[$i]['attributes'][$j]['option_id'] . "'\n\n and pa.options_id = popt.products_options_id\n\n and pa.options_values_id = '" . $this->products[$i]['attributes'][$j]['value_id'] . "'\n\n and pa.options_values_id = poval.products_options_values_id\n\n and popt.language_id = '" . $_SESSION['languages_id'] . "'\n\n and poval.language_id = '" . $_SESSION['languages_id'] . "'";
$attributes_values = $db->Execute($attributes_query);
} else {
$attributes_values = $db->Execute("select popt.products_options_name, poval.products_options_values_name,\n\n pa.options_values_price, pa.price_prefix,\n\n pa.product_attribute_is_free, pa.products_attributes_weight, pa.products_attributes_weight_prefix,\n\n pa.attributes_discounted, pa.attributes_price_base_included, pa.attributes_price_onetime,\n\n pa.attributes_price_factor, pa.attributes_price_factor_offset,\n\n pa.attributes_price_factor_onetime, pa.attributes_price_factor_onetime_offset,\n\n pa.attributes_qty_prices, pa.attributes_qty_prices_onetime,\n\n pa.attributes_price_words, pa.attributes_price_words_free,\n\n pa.attributes_price_letters, pa.attributes_price_letters_free\n\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\n where pa.products_id = '" . $this->products[$i]['id'] . "' and pa.options_id = '" . (int) $this->products[$i]['attributes'][$j]['option_id'] . "' and pa.options_id = popt.products_options_id and pa.options_values_id = '" . (int) $this->products[$i]['attributes'][$j]['value_id'] . "' and pa.options_values_id = poval.products_options_values_id and popt.language_id = '" . $_SESSION['languages_id'] . "' and poval.language_id = '" . $_SESSION['languages_id'] . "'");
}
//clr 030714 update insert query. changing to use values form $order->products for products_options_values.
$sql_data_array = array('orders_id' => $zf_insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values->fields['products_options_name'], 'products_options_values' => $this->products[$i]['attributes'][$j]['value'], 'options_values_price' => $attributes_values->fields['options_values_price'], 'price_prefix' => $attributes_values->fields['price_prefix'], 'product_attribute_is_free' => $attributes_values->fields['product_attribute_is_free'], 'products_attributes_weight' => $attributes_values->fields['products_attributes_weight'], 'products_attributes_weight_prefix' => $attributes_values->fields['products_attributes_weight_prefix'], 'attributes_discounted' => $attributes_values->fields['attributes_discounted'], 'attributes_price_base_included' => $attributes_values->fields['attributes_price_base_included'], 'attributes_price_onetime' => $attributes_values->fields['attributes_price_onetime'], 'attributes_price_factor' => $attributes_values->fields['attributes_price_factor'], 'attributes_price_factor_offset' => $attributes_values->fields['attributes_price_factor_offset'], 'attributes_price_factor_onetime' => $attributes_values->fields['attributes_price_factor_onetime'], 'attributes_price_factor_onetime_offset' => $attributes_values->fields['attributes_price_factor_onetime_offset'], 'attributes_qty_prices' => $attributes_values->fields['attributes_qty_prices'], 'attributes_qty_prices_onetime' => $attributes_values->fields['attributes_qty_prices_onetime'], 'attributes_price_words' => $attributes_values->fields['attributes_price_words'], 'attributes_price_words_free' => $attributes_values->fields['attributes_price_words_free'], 'attributes_price_letters' => $attributes_values->fields['attributes_price_letters'], 'attributes_price_letters_free' => $attributes_values->fields['attributes_price_letters_free'], 'products_options_id' => (int) $this->products[$i]['attributes'][$j]['option_id'], 'products_options_values_id' => (int) $this->products[$i]['attributes'][$j]['value_id'], 'products_prid' => $this->products[$i]['id']);
zen_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array);
$zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_LINE_ITEM', $sql_data_array);
if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values->fields['products_attributes_filename']) && zen_not_null($attributes_values->fields['products_attributes_filename'])) {
$sql_data_array = array('orders_id' => $zf_insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values->fields['products_attributes_filename'], 'download_maxdays' => $attributes_values->fields['products_attributes_maxdays'], 'download_count' => $attributes_values->fields['products_attributes_maxcount'], 'products_prid' => $this->products[$i]['id']);
zen_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array);
$zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADDED_ATTRIBUTE_DOWNLOAD_LINE_ITEM', $sql_data_array);
}
//clr 030714 changing to use values from $orders->products and adding call to zen_decode_specialchars()
// $this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . $attributes_values->fields['products_options_values_name'];
$this->products_ordered_attributes .= "\n\t" . $attributes_values->fields['products_options_name'] . ' ' . zen_decode_specialchars($this->products[$i]['attributes'][$j]['value']);
}
}
//------eof: insert customer-chosen options ----
$zco_notifier->notify('NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS', $custom_insertable_text);
/* START: ADD MY CUSTOM DETAILS
* 1. calculate/prepare custom information to be added to this product entry in order-confirmation.
* 2. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
* $this->products_ordered_attributes .= {INSERT CUSTOM INFORMATION HERE};
*/
$this->products_ordered_attributes .= '';
// $custom_insertable_text;
/* END: ADD MY CUSTOM DETAILS */
// update totals counters
$this->total_weight += $this->products[$i]['qty'] * $this->products[$i]['weight'];
$this->total_tax += zen_calculate_tax($total_products_price, $products_tax) * $this->products[$i]['qty'];
$this->total_cost += $total_products_price;
$zco_notifier->notify('NOTIFY_ORDER_PROCESSING_ONE_TIME_CHARGES_BEGIN');
// build output for email notification
$this->products_ordered .= $this->products[$i]['qty'] . ' x ' . $this->products[$i]['name'] . ($this->products[$i]['model'] != '' ? ' (' . $this->products[$i]['model'] . ') ' : '') . ' = ' . $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) . ($this->products[$i]['onetime_charges'] != 0 ? "\n" . TEXT_ONETIME_CHARGES_EMAIL . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') . $this->products_ordered_attributes . "\n";
$this->products_ordered_html .= '<tr>' . "\n" . '<td class="product-details" align="right" valign="top" width="30">' . $this->products[$i]['qty'] . ' x</td>' . "\n" . '<td class="product-details" valign="top">' . nl2br($this->products[$i]['name']) . ($this->products[$i]['model'] != '' ? ' (' . nl2br($this->products[$i]['model']) . ') ' : '') . "\n" . '<nobr><small><em> ' . nl2br($this->products_ordered_attributes) . '</em></small></nobr></td>' . "\n" . '<td class="product-details-num" valign="top" align="right">' . $currencies->display_price($this->products[$i]['final_price'], $this->products[$i]['tax'], $this->products[$i]['qty']) . ($this->products[$i]['onetime_charges'] != 0 ? '</td></tr>' . "\n" . '<tr><td class="product-details">' . nl2br(TEXT_ONETIME_CHARGES_EMAIL) . '</td>' . "\n" . '<td>' . $currencies->display_price($this->products[$i]['onetime_charges'], $this->products[$i]['tax'], 1) : '') . '</td></tr>' . "\n";
}
$order_total_modules->apply_credit();
//ICW ADDED FOR CREDIT CLASS SYSTEM
$zco_notifier->notify('NOTIFY_ORDER_AFTER_ORDER_CREATE_ADD_PRODUCTS');
}
开发者ID:andychang88,项目名称:daddy-store.com,代码行数:101,代码来源:order.php
示例11: create_add_products
function create_add_products($zf_insert_id, $zf_mode = false)
{
global $db, $currencies, $order_total_modules, $order_totals;
// initialized for the email confirmation
$this->products_ordered = '';
$this->products_ordered_html = '';
$this->subtotal = 0;
$this->total_tax = 0;
// lowstock email report
$this->email_low_stock = '';
for ($i = 0, $n = sizeof($this->products); $i < $n; $i++) {
// Stock Update - Joao Correia
if (STOCK_LIMITED == 'true') {
if (DOWNLOAD_ENABLED == 'true') {
$stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename\r\n FROM " . TABLE_PRODUCTS . " p\r\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa\r\n ON p.products_id=pa.products_id\r\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\r\n ON pa.products_attributes_id=pad.products_attributes_id\r\n WHERE p.products_id = '" . zen_get_prid($this->products[$i]['id']) . "'";
// Will work with only one option for downloadable products
// otherwise, we have to build the query dynamically with a loop
$products_attributes = $this->products[$i]['attributes'];
if (is_array($products_attributes)) {
$stock_query_raw .= " AND pa.options_id = '" . $products_attributes[0]['option_id'] . "' AND pa.options_values_id = '" . $products_attributes[0]['value_id'] . "'";
}
$stock_values = $db->Execute($stock_query_raw);
} else {
$stock_values = $db->Execute("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . zen_get_prid($this->products[$i]['id']) . "'");
}
if ($stock_values->RecordCount() > 0) {
// do not decrement quantities if products_attributes_filename exists
if (DOWNLOAD_ENABLED != 'true' || !$stock_values->fields['products_attributes_filename']) {
$stock_left = $stock_values->fields['products_quantity'] - $this->products[$i]['qty'];
$this->products[$i]['stock_reduce'] = $this->products[$i]['qty'];
} else {
$stock_left = $stock_values->fields['products_quantity'];
}
// $this->products[$i]['stock_value'] = $stock_values->fields['products_quantity'];
$db->Execute("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . zen_get_prid($this->products[$i]['id']) . &q
|
请发表评论