本文整理汇总了PHP中zen_add_tax函数的典型用法代码示例。如果您正苦于以下问题:PHP zen_add_tax函数的具体用法?PHP zen_add_tax怎么用?PHP zen_add_tax使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了zen_add_tax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: noSymbolDisplayPrice
function noSymbolDisplayPrice()
{
return $this->noSymbolFormat(zen_add_tax($products_price, $products_tax) * $quantity);
}
示例2: zen_draw_checkbox_field
if ($flag_markup) {
echo zen_draw_checkbox_field('markup_checked[' . $products->fields['products_id'] . ']', '1', !$flag_special && $_POST['marge']);
//echo zen_draw_hidden_field('markup[' . $products->fields['products_id'] . ']', '1');
} else {
// this has become obsolete since we changed prices to update by default when markup is not set
//echo zen_draw_hidden_field('update_price[' . $products->fields['products_id'] . ']', 'yes');
}
if ($flag_special) {
echo ' <a target=blank href="' . zen_href_link(FILENAME_SPECIALS, 'sID=' . $spec->fields['specials_id'] . '&action=edit') . '" target="_blank">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', TEXT_SPECIALS_PRODUCTS) . '</a>';
}
if (QUICKUPDATES_DISPLAY_TVA_PRICES == 'true') {
$parameters = 'size="6"';
$parameters .= ' onKeyUp="updateNet(' . $products->fields['products_id'] . '); updateMargin(' . $products->fields['products_id'] . ');"';
// $taxprice needs the $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'] to be set (done at top of file)
// an alternative might be to use $price (i.s.o. $taxprice) and update it with updatGross('$products->fields['products_id']') for each product ?)
$tax_price = zen_add_tax($price, $tax_rate->fields['tax_rate']);
$tax_price = sprintf("%01.2f", round($tax_price, 4));
echo '</td>' . "\n";
echo '<td class="smallText">' . zen_draw_input_field('quick_updates_new[products_taxprice][' . $products->fields['products_id'] . ']', $tax_price, $parameters);
//echo zen_draw_hidden_field('update_taxprice['.$products->fields['products_id'].']','yes');
echo zen_draw_hidden_field('quick_updates_old[products_tax_value][' . $products->fields['products_id'] . ']', $tax_rate->fields['tax_rate']);
}
echo zen_draw_hidden_field('quick_updates_old[products_price][' . $products->fields['products_id'] . ']', $products->fields['products_price']);
echo '<a target="_blank" href="' . zen_href_link(FILENAME_PRODUCTS_PRICE_MANAGER, 'products_filter=' . $products->fields['products_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_products_price_manager.gif', QUICKUPDATES_PPM_LINK_ALT) . '</a>';
echo '</td>' . "\n";
if (QUICKUPDATES_MODIFY_WEIGHT == 'true') {
echo '<td class="smallText">' . zen_draw_input_field('quick_updates_new[products_weight][' . $products->fields['products_id'] . ']', $products->fields['products_weight'], 'size="4"') . zen_draw_hidden_field('quick_updates_old[products_weight][' . $products->fields['products_id'] . ']', $products->fields['products_weight']) . '</td>' . "\n";
}
if (QUICKUPDATES_MODIFY_TAX == 'true') {
echo '<td class="smallText">' . zen_draw_pull_down_menu('quick_updates_new[products_tax_class_id][' . $products->fields['products_id'] . ']', $tax_class_array, $products->fields['products_tax_class_id'], 'style="width: 5em;"') . zen_draw_hidden_field('quick_updates_old[products_tax_class_id][' . $products->fields['products_id'] . ']', $products->fields['products_tax_class_id']) . '</td>' . "\n";
}
示例3: getLineItemDetails
//.........这里部分代码省略.........
}
}
$flagSubtotalsUnknownYet = $optionsST['SHIPPINGAMT'] + $optionsST['SHIPDISCAMT'] + $optionsST['AMT'] + $optionsST['TAXAMT'] + $optionsST['ITEMAMT'] + $optionsST['INSURANCEAMT'] == 0;
} else {
// if we get here, we don't have any order-total information yet because the customer has clicked Express before starting normal checkout flow
// thus, we must make a note to manually calculate subtotals, rather than relying on the more robust order-total infrastructure
$flagSubtotalsUnknownYet = TRUE;
}
$decimals = $currencies->get_decimal_places($_SESSION['currency']);
// loop thru all products to prepare details of quantity and price.
for ($i = 0, $n = sizeof($order->products), $k = -1; $i < $n; $i++) {
// PayPal is inconsistent in how it handles zero-value line-items, so skip this entry if price is zero
if ($order->products[$i]['final_price'] == 0) {
continue;
} else {
$k++;
}
$optionsLI["L_NUMBER{$k}"] = $order->products[$i]['model'];
$optionsLI["L_NAME{$k}"] = $order->products[$i]['name'] . ' [' . (int) $order->products[$i]['id'] . ']';
// Append *** if out-of-stock.
$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
// PayPal can't handle fractional-quantity values, so convert it to qty 1 here
if ($order->products[$i]['qty'] > 1 && ($order->products[$i]['qty'] != (int) $order->products[$i]['qty'] || $flag_treat_as_partial)) {
$optionsLI["L_NAME{$k}"] = '(' . $order->products[$i]['qty'] . ' x ) ' . $optionsLI["L_NAME{$k}"];
// zen_add_tax already handles whether DISPLAY_PRICES_WITH_TAX is set
$optionsLI["L_AMT{$k}"] = zen_round(zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $decimals) * $order->products[$i]['qty'], $decimals);
$optionsLI["L_QTY{$k}"] = 1;
// no line-item tax component
} else {
$optionsLI["L_QTY{$k}"] = $order->products[$i]['qty'];
$optionsLI["L_AMT{$k}"] = zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $decimals);
}
$subTotalLI += $optionsLI["L_QTY{$k}"] * $optionsLI["L_AMT{$k}"];
// $subTotalTax += ($optionsLI["L_QTY$k"] * $optionsLI["L_TAXAMT$k"]);
// add line-item for one-time charges on this product
if ($order->products[$i]['onetime_charges'] != 0) {
$k++;
$optionsLI["L_NAME{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_ONETIME_CHARGES_PREFIX . substr(htmlentities($order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 120);
$optionsLI["L_AMT{$k}"] = zen_round(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), $decimals);
$optionsLI["L_QTY{$k}"] = 1;
// $optionsLI["L_TAXAMT$k"] = zen_round(zen_calculate_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), $decimals);
$subTotalLI += $optionsLI["L_AMT{$k}"];
// $subTotalTax += $optionsLI["L_TAXAMT$k"];
}
$numberOfLineItemsProcessed = $k;
}
// end for loopthru all products
// add line items for any surcharges added by order-total modules
if ($surcharges > 0) {
$numberOfLineItemsProcessed++;
$k = $numberOfLineItemsProcessed;
$optionsLI["L_NAME{$k}"] = MODULES_PAYMENT_PAYPALWPP_LINEITEM_TEXT_SURCHARGES_LONG;
$optionsLI["L_AMT{$k}"] = $surcharges;
$optionsLI["L_QTY{$k}"] = 1;
$subTotalLI += $surcharges;
}
// add line items for discounts such as gift certificates and coupons
if ($creditsApplied > 0) {
示例4: calculate
//.........这里部分代码省略.........
// + or blank adds
if ($attribute_price->fields['price_prefix'] == '-') {
// appears to confuse products priced by attributes
if ($product->fields['product_is_always_free_shipping'] == '1' or $product->fields['products_virtual'] == '1') {
$shipping_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
$freeShippingTotal -= $shipping_attributes_price;
}
if ($attribute_price->fields['attributes_discounted'] == '1') {
// calculate proper discount for attributes
$new_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
$productTotal -= $new_attributes_price;
} else {
$productTotal -= $attribute_price->fields['options_values_price'];
}
// calculate Product Price without Specials, Sales or Discounts
// $this->total_before_discounts -= $attribute_price->fields['options_values_price'];
$total_before_discounts -= $attribute_price->fields['options_values_price'];
} else {
// appears to confuse products priced by attributes
if ($product->fields['product_is_always_free_shipping'] == '1' or $product->fields['products_virtual'] == '1') {
$shipping_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
$freeShippingTotal += $shipping_attributes_price;
}
if ($attribute_price->fields['attributes_discounted'] == '1') {
// calculate proper discount for attributes
$new_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price'], $qty);
// Dual Pricing start
//$productTotal += $new_attributes_price;
if ($_SESSION['customer_id']) {
if ($customer_check->fields['customers_whole'] != "0") {
$new_attributes_price = zen_get_discount_calc($product->fields['products_id'], $attribute_price->fields['products_attributes_id'], $attribute_price->fields['options_values_price_w'], $qty);
}
}
$this->total += $qty * zen_add_tax($new_attributes_price, $products_tax);
// Dual Pricing end
} else {
$productTotal += $attribute_price->fields['options_values_price'];
}
// calculate Product Price without Specials, Sales or Discounts
$total_before_discounts += $attribute_price->fields['options_values_price'];
}
// eof: attribute price
// adjust for downloads
// adjust products price
$check_attribute = $attribute_price->fields['products_attributes_id'];
$sql = "select *\n from " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . "\n where products_attributes_id = '" . $check_attribute . "'";
$check_download = $db->Execute($sql);
if ($check_download->RecordCount()) {
// count number of downloads
$this->download_count += $check_download->RecordCount() * $qty;
// do not count download as free when set to product/download combo
if ($adjust_downloads == 1 and $product->fields['product_is_always_free_shipping'] != 2) {
$freeShippingTotal += $products_price;
$this->free_shipping_item += $qty;
}
// adjust for attributes price
$freeShippingTotal += $new_attributes_price;
//die('I SEE B ' . $this->free_shipping_price);
}
// echo 'I SEE ' . $this->total . ' vs ' . $this->free_shipping_price . ' items: ' . $this->free_shipping_item. '<br>';
////////////////////////////////////////////////
// calculate additional attribute charges
$chk_price = zen_get_products_base_price($products_id);
$chk_special = zen_get_products_special_price($products_id, false);
// products_options_value_text
if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) {
示例5:
echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']));
?>
</td>
</tr>
<?php
} else {
?>
<td><?php
echo $quotes[$i]['module'];
?>
(<?php
echo $quotes[$i]['methods'][$j]['title'];
?>
)</td>
<td class="cartTotalDisplay"><?php
echo $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax']));
?>
</td>
</tr>
<?php
}
}
}
}
}
?>
</table>
<?php
}
}
?>
示例6: before_process
/**
* Prepare and submit the authorization to the gateway
*/
function before_process()
{
global $order, $order_totals, $db, $messageStack, $lp_avs, $lp_trans_num;
$myorder = array();
// Calculate the next expected order id
$last_order_id = $db->Execute("select * from " . TABLE_ORDERS . " order by orders_id desc limit 1");
$new_order_id = $last_order_id->fields['orders_id'];
$new_order_id = $new_order_id + 1;
// add randomized suffix to order id to produce uniqueness ... since it's unwise to submit the same order-number twice to the gateway
$new_order_id = (string) $new_order_id . '-' . zen_create_random_value(6);
// Build Info to send to Gateway
$myorder["result"] = "LIVE";
switch (MODULE_PAYMENT_LINKPOINT_API_TRANSACTION_MODE_RESPONSE) {
case "TESTING: Successful":
$myorder["result"] = "GOOD";
break;
case "TESTING: Decline":
$myorder["result"] = "DECLINE";
break;
case "TESTING: Duplicate":
$myorder["result"] = "DUPLICATE";
break;
}
// "oid" - Order ID number must be unique. If not set, gateway will assign one.
//$oid = zen_create_random_value(16, 'digits'); // Create a UID for the order
$myorder["oid"] = $new_order_id;
//""; // time(); ????
// prepare totals for submission
$surcharges = 0;
$creditsApplied = 0;
global $order_totals;
reset($order_totals);
$myorder['subtotal'] = $myorder['tax'] = $myorder['shipping'] = $myorder['chargetotal'] = 0;
for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) {
if ($order_totals[$i]['code'] == '') {
continue;
}
if (in_array($order_totals[$i]['code'], array('ot_total', 'ot_subtotal', 'ot_tax', 'ot_shipping'))) {
if ($order_totals[$i]['code'] == 'ot_subtotal') {
$myorder["subtotal"] = round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_tax') {
$myorder["tax"] += round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_shipping') {
$myorder["shipping"] = round($order_totals[$i]['value'], 2);
}
if ($order_totals[$i]['code'] == 'ot_total') {
$myorder["chargetotal"] = round($order_totals[$i]['value'], 2);
}
} else {
global ${$order_totals[$i]['code']};
if (substr($order_totals[$i]['text'], 0, 1) == '-' || isset(${$order_totals[$i]['code']}->credit_class) && ${$order_totals[$i]['code']}->credit_class == true) {
$creditsApplied += round($order_totals[$i]['value'], 2);
} else {
$surcharges += round($order_totals[$i]['value'], 2);
}
}
}
foreach (array('subtotal', 'tax', 'chargetotal', 'shipping') as $i) {
if (isset($myorder[$i])) {
$myorder[$i] = number_format($myorder[$i], 2, '.', '');
}
}
if ($surcharges == 0 && $creditsApplied == 0 && $order->info['total'] >= $order->info['subtotal'] && sizeof($order->products) <= 20) {
// itemized contents
$num_line_items = 0;
reset($order->products);
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
$num_line_items++;
$myorder["items"][$num_line_items]['id'] = $order->products[$i]['id'];
$myorder["items"][$num_line_items]['description'] = substr(htmlentities($order->products[$i]['name'], ENT_QUOTES, 'UTF-8'), 0, 128);
$myorder["items"][$num_line_items]['quantity'] = $order->products[$i]['qty'];
$myorder["items"][$num_line_items]['price'] = number_format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), 2, '.', '');
// check and adjust for fractional quantities, which cannot be submitted as line-item details
$q = $order->products[$i]['qty'];
$q1 = strval($q);
$q2 = (int) $q;
$q3 = strval($q2);
if ($q1 != $q3 || $myorder["items"][$num_line_items]['quantity'] * $myorder["items"][$num_line_items]['price'] != number_format($order->products[$i]['qty'] * $order->products[$i]['final_price'], 2, '.', '')) {
$myorder["items"][$num_line_items]['quantity'] = 1;
$myorder["items"][$num_line_items]['price'] = number_format(zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $decimals) * $order->products[$i]['qty'], 2, '.', '');
$myorder["items"][$num_line_items]['description'] = '(' . $order->products[$i]['qty'] . ' x )' . substr($myorder["items"][$num_line_items]['description'], 115);
}
if (isset($order->products[$i]['attributes'])) {
$options_text_length = 0;
for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j++) {
$options_text_length += strlen($order->products[$i]['attributes'][$j]['option'] . $order->products[$i]['attributes'][$j]['value']);
}
if ($options_text_length < 128) {
for ($j = 0, $m = sizeof($order->products[$i]['attributes']); $j < $m; $j++) {
$myorder["items"][$num_line_items]['options' . $j]['name'] = substr(htmlentities($order->products[$i]['attributes'][$j]['option'], ENT_QUOTES, 'UTF-8'), 0, 128);
$myorder["items"][$num_line_items]['options' . $j]['value'] = substr(htmlentities($order->products[$i]['attributes'][$j]['value'], ENT_QUOTES, 'UTF-8'), 0, 128);
}
}
}
// track one-time charges
//.........这里部分代码省略.........
示例7: zen_display_tax_value
<?php
if (sizeof($order->info['tax_groups']) > 1) {
?>
<td class="accountTaxDisplay"><?php
echo zen_display_tax_value($order->products[$i]['tax']) . '%';
?>
</td>
<?php
}
?>
<td class="accountTotalDisplay">
<?php
$ppe = zen_round(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), $currencies->get_decimal_places($order->info['currency']));
$ppt = $ppe * $order->products[$i]['qty'];
// echo $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '')
echo $currencies->format($ppt, true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '');
?>
</td>
</tr>
<?php
}
?>
</table>
<hr />
<div id="orderTotals">
<?php
for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
?>
<div class="amount larger forward"><?php
echo $order->totals[$i]['text'];
?>
示例8: zen_check_stock
}
//end foreach [attributes]
if (STOCK_CHECK == 'true') {
$flagStockCheck = zen_check_stock($products[$i]['id'], $products[$i]['quantity']);
if ($flagStockCheck == true) {
$flagAnyOutOfStock = true;
}
}
$linkProductsImage = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
$linkProductsName = zen_href_link(zen_get_info_page($products[$i]['id']), 'products_id=' . $products[$i]['id']);
$productsImage = IMAGE_SHOPPING_CART_STATUS == 1 ? zen_image(DIR_WS_IMAGES . $products[$i]['image'], $products[$i]['name'], IMAGE_SHOPPING_CART_WIDTH, IMAGE_SHOPPING_CART_HEIGHT) : '';
$show_products_quantity_max = zen_get_products_quantity_order_max($products[$i]['id']);
$showFixedQuantity = ($show_products_quantity_max == 1 or zen_get_products_qty_box_status($products[$i]['id']) == 0) ? true : false;
// $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('products_id[]', $products[$i]['id']) . zen_draw_hidden_field('cart_quantity[]', 1);
// $showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', 1);
$showFixedQuantityAmount = $products[$i]['quantity'] . zen_draw_hidden_field('cart_quantity[]', $products[$i]['quantity']);
$showMinUnits = zen_get_products_quantity_min_units_display($products[$i]['id']);
$quantityField = zen_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"');
$buttonUpdate = ((SHOW_SHOPPING_CART_UPDATE == 1 or SHOW_SHOPPING_CART_UPDATE == 3) ? zen_image_submit(ICON_IMAGE_UPDATE, ICON_UPDATE_ALT) : '') . zen_draw_hidden_field('products_id[]', $products[$i]['id']);
$tmp = zen_add_tax($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']));
// $productsPriceEach = $currencies->rateAdjusted($tmp);
// $productsPriceTotal = $productsPriceEach * $products[$i]['quantity'];
$productsPriceTotal = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
$productsPriceEach = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
// $productsPriceTotal = $currencies->display_price($products[$i]['final_price'], zen_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) . ($products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->display_price($products[$i]['onetime_charges'], zen_get_tax_rate($products[$i]['tax_class_id']), 1) : '');
// echo $currencies->rateAdjusted($tmp);
$productArray[$i] = array('attributeHiddenField' => $attributeHiddenField, 'flagStockCheck' => $flagStockCheck, 'flagShowFixedQuantity' => $showFixedQuantity, 'linkProductsImage' => $linkProductsImage, 'linkProductsName' => $linkProductsName, 'productsImage' => $productsImage, 'productsName' => $productsName, 'showFixedQuantity' => $showFixedQuantity, 'showFixedQuantityAmount' => $showFixedQuantityAmount, 'showMinUnits' => $showMinUnits, 'quantityField' => $quantityField, 'buttonUpdate' => $buttonUpdate, 'productsPrice' => $productsPriceTotal, 'productsPriceEach' => $productsPriceEach, 'rowClass' => $rowClass, 'buttonDelete' => $buttonDelete, 'checkBoxDelete' => $checkBoxDelete, 'id' => $products[$i]['id'], 'attributes' => $attrArray);
}
// end FOR loop
// This should be last line of the script:
$zco_notifier->notify('NOTIFY_HEADER_END_SHOPPING_CART');
示例9: calculate
function calculate($pForceRecalculate = FALSE)
{
global $gBitDb;
if (is_null($this->total) || $pForceRecalculate) {
$this->subtotal = 0;
$this->total = 0;
$this->weight = 0;
$this->quantity = 0;
// shipping adjustment
$this->free_shipping_item = 0;
$this->free_shipping_price = 0;
$this->free_shipping_weight = 0;
if (!is_array($this->contents)) {
return 0;
}
reset($this->contents);
foreach (array_keys($this->contents) as $productsKey) {
$qty = $this->contents[$productsKey]['products_quantity'];
// $productsKey will be unique joined string of products_id:hash for cart, eg: 17054:be19531ba04f4dc3fd33bca49a16dca8
$prid = zen_get_prid($productsKey);
// products price
$product = $this->getProductObject($prid);
// sometimes 0 hash things can get stuck in cart.
if ($product && $product->isValid()) {
$productAttributes = !empty($this->contents[$productsKey]['attributes']) ? $this->contents[$productsKey]['attributes'] : array();
$products_tax = zen_get_tax_rate($product->getField('products_tax_class_id'));
$purchasePrice = $product->getPurchasePrice($qty, $productAttributes);
$onetimeCharges = $product->getOneTimeCharges($qty, $productAttributes);
// shipping adjustments
if ($product->getField('product_is_always_free_ship') == 1 or $product->isVirtual($this->contents[$productsKey]) == 1 or preg_match('/^GIFT/', addslashes($product->getField('products_model')))) {
$this->free_shipping_item += $qty;
$this->free_shipping_price += zen_add_tax($purchasePrice, $products_tax) * $qty;
$this->free_shipping_weight += $product->getWeight($qty, $productAttributes);
}
$productsTotal = zen_add_tax($purchasePrice * $qty + $onetimeCharges, $products_tax);
$this->total += $productsTotal;
$this->subtotal += $productsTotal;
$this->weight += $product->getWeight($qty, $productAttributes);
$this->quantity += $qty;
}
}
}
}
示例10: 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->subtotal < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) {
$charge_it = 'true';
$cart_content_type = $gBitCustomer->mCart->get_content_type();
$gv_content_only = $gBitCustomer->mCart->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 = zen_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['countries_id'], $order->delivery['zone_id']);
$tax_description = zen_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['countries_id'], $order->delivery['zone_id']);
// calculate from flat fee or percentage
if (substr(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, -1) == '%') {
$low_order_fee = $order->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);
$this->output[] = array('title' => $this->title . ':', 'text' => $currencies->format(zen_add_tax($low_order_fee, $tax), true, $order->info['currency'], $order->info['currency_value']), 'value' => zen_add_tax($low_order_fee, $tax));
}
}
}
}
示例11: array
} else {
// shipping method with sub methods (multipickup)
for ($j = 0, $n2 = sizeof($quotes[$i]['methods']); $j < $n2; $j++) {
$thisquoteid = $quotes[$i]['id'] . '_' . $quotes[$i]['methods'][$j]['id'];
$ShipTxt .= '<tr class="' . $extra . '">';
$ShipTxt .= '<td class="main">' . $quotes[$i]['icon'] . ' </td>';
if ($quotes[$i]['error']) {
$ShipTxt .= '<td colspan="2" class="main">' . $quotes[$i]['module'] . ' ';
$ShipTxt .= '(' . $quotes[$i]['error'] . ')</td></tr>';
} else {
if ($selected_shipping['id'] == $thisquoteid) {
$ShipTxt .= '<td class="main"><strong>' . $quotes[$i]['module'] . ' ';
$ShipTxt .= '(' . $quotes[$i]['methods'][$j]['title'] . ')</strong></td><td align="right" class="main"><strong>' . $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . '</strong></td></tr>';
} else {
$ShipTxt .= '<td class="main">' . $quotes[$i]['module'] . ' ';
$ShipTxt .= '(' . $quotes[$i]['methods'][$j]['title'] . ')</td><td align="right" class="main">' . $currencies->format(zen_add_tax($quotes[$i]['methods'][$j]['cost'], $quotes[$i]['tax'])) . '</td></tr>';
}
}
}
}
}
}
}
$ShipTxt .= '</table></form>';
$info_box_contents = array();
$info_box_contents[] = array('text' => $ShipTxt);
new infoBox($info_box_contents);
}
// Only do when something is in the cart
?>
</td></tr></table>
示例12: zen_display_tax_value
</strong></td>
</tr>
<?php
}
for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
echo ' <tr>' . "\n" . ' <td class="main" align="right" valign="top" width="30">' . $order->products[$i]['qty'] . ' x</td>' . "\n" . ' <td class="main" valign="top">' . $order->products[$i]['name'];
if (isset($order->products[$i]['attributes']) && sizeof($order->products[$i]['attributes']) > 0) {
for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) {
echo '<br /><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'] . '</i></small></nobr>';
}
}
echo ' </td>' . "\n";
if (sizeof($order->info['tax_groups']) > 1) {
echo ' <td class="main" valign="top" align="right">' . zen_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n";
}
echo ' <td class="main" align="right" valign="top">' . $currencies->format(zen_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ($order->products[$i]['onetime_charges'] != 0 ? '<br />' . $currencies->format(zen_add_tax($order->products[$i]['onetime_charges'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) : '') . '</td>' . "\n" . ' </tr>' . "\n";
}
?>
</table>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<?php
for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
echo ' <tr>' . "\n" . ' <td class="' . str_replace('_', '-', $order->totals[$i]['class']) . '-Text" align="right" width="100%">' . $order->totals[$i]['title'] . '</td>' . "\n" . ' <td class="' . str_replace('_', '-', $order->totals[$i]['class']) . '-Amount" align="right" nowrap="nowrap">' . $order->totals[$i]['text'] . '</td>' . "\n" . ' </tr>' . "\n";
}
?>
</table>
</td>
</tr>
<tr>
<td colspan="2" width="100%">
<?php
示例13: display_price
function display_price($products_price, $products_tax, $quantity = 1, $currency_type = '', $currency_value = '')
{
return $this->format(zen_add_tax($products_price, $products_tax) * $quantity, true, $currency_type, $currency_value);
}
示例14: quote
function quote($pShippingWeight, $method = '', $module = '')
{
global $currencies;
$quotes_array = array();
if (!empty($this->modules)) {
$shipHash['method'] = $method;
$shipHash['shipping_num_boxes'] = 1;
$shipHash['shipping_weight'] = $pShippingWeight;
$za_tare_array = preg_split("/[:,]/", SHIPPING_BOX_WEIGHT);
$zc_tare_percent = $za_tare_array[0];
$zc_tare_weight = $za_tare_array[1];
$za_large_array = preg_split("/[:,]/", SHIPPING_BOX_PADDING);
$zc_large_percent = $za_large_array[0];
$zc_large_weight = $za_large_array[1];
if (SHIPPING_MAX_WEIGHT <= $shipHash['shipping_weight']) {
// large box add padding
$shipHash['shipping_weight'] = $shipHash['shipping_weight'] + $shipHash['shipping_weight'] * ($zc_large_percent / 100) + $zc_large_weight;
} else {
// add tare weight < large
$shipHash['shipping_weight'] = $shipHash['shipping_weight'] + $shipHash['shipping_weight'] * ($zc_tare_percent / 100) + $zc_tare_weight;
}
if ($shipHash['shipping_weight'] > SHIPPING_MAX_WEIGHT) {
// Split into many boxes
$shipHash['shipping_num_boxes'] = ceil($shipHash['shipping_weight'] / SHIPPING_MAX_WEIGHT);
$shipHash['shipping_weight'] = $shipHash['shipping_weight'] / $shipHash['shipping_num_boxes'];
}
$include_quotes = array();
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$base = basename($value);
$class = substr($base, 0, strrpos($base, '.'));
if (zen_not_null($module)) {
if ($module == $class && $GLOBALS[$class]->enabled) {
$include_quotes[] = $class;
}
} elseif ($GLOBALS[$class]->enabled) {
$include_quotes[] = $class;
}
}
$size = sizeof($include_quotes);
for ($i = 0; $i < $size; $i++) {
if ($quotes = $GLOBALS[$include_quotes[$i]]->quote($shipHash)) {
if (!empty($quotes['methods'])) {
foreach (array_keys($quotes['methods']) as $j) {
$quotes['methods'][$j]['cost_add_tax'] = zen_add_tax($quotes['methods'][$j]['cost'], isset($quotes['tax']) ? $quotes['tax'] : 0);
$quotes['methods'][$j]['format_add_tax'] = $currencies->format($quotes['methods'][$j]['cost_add_tax']);
}
}
$quotes_array[] = $quotes;
}
}
}
return $quotes_array;
}
示例15: calculate
//.........这里部分代码省略.........
if (zen_get_attributes_type($attribute_price->fields['products_attributes_id']) == PRODUCTS_OPTIONS_TYPE_TEXT) {
$text_words = zen_get_word_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']);
$text_letters = zen_get_letters_count_price($this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_letters_free'], $attribute_price->fields['attributes_price_letters']);
$productTotal += $text_letters;
$productTotal += $text_words;
if ($product->fields['product_is_always_free_shipping'] == 1 or $product->fields['products_virtual'] == 1 or preg_match('/^GIFT/', addslashes($product->fields['products_model']))) {
$freeShippingTotal += $text_letters;
$freeShippingTotal += $text_words;
}
}
// attributes_price_factor
$added_charge = 0;
if ($attribute_price->fields['attributes_price_factor'] > 0) {
$added_charge = zen_get_attributes_price_factor($chk_price, $chk_special, $attribute_price->fields['attributes_price_factor'], $attribute_price->fields['attributes_price_factor_offset']);
$productTotal += $added_charge;
if ($product->fields['product_is_always_free_shipping'] == 1 or $product->fields['products_virtual'] == 1 or preg_match('/^GIFT/', addslashes($product->fields['products_model']))) {
$freeShippingTotal += $added_charge;
}
}
// attributes_qty_prices
$added_charge = 0;
if ($attribute_price->fields['attributes_qty_prices'] != '') {
$added_charge = zen_get_attributes_qty_prices_onetime($attribute_price->fields['attributes_qty_prices'], $qty);
$productTotal += $added_charge;
if ($product->fields['product_is_always_free_shipping'] == 1 or $product->fields['products_virtual'] == 1 or preg_match('/^GIFT/', addslashes($product->fields['products_model']))) {
$freeShippingTotal += $added_charge;
}
}
//// one time charges
// attributes_price_onetime
if ($attribute_price->fields['attributes_price_onetime'] > 0) {
$totalOnetimeCharge += $attribute_price->fields['attributes_price_onetime'];
}
// attributes_price_factor_onetime
$added_charge = 0;
if ($attribute_price->fields['attributes_price_factor_onetime'] > 0) {
$chk_price = zen_get_products_base_price($products_id);
$chk_special = zen_get_products_special_price($products_id, false);
$added_charge = zen_get_attributes_price_factor($chk_price, $chk_special, $attribute_price->fields['attributes_price_factor_onetime'], $attribute_price->fields['attributes_price_factor_onetime_offset']);
$totalOnetimeCharge += $added_charge;
}
// attributes_qty_prices_onetime
$added_charge = 0;
if ($attribute_price->fields['attributes_qty_prices_onetime'] != '') {
$chk_price = zen_get_products_base_price($products_id);
$chk_special = zen_get_products_special_price($products_id, false);
$added_charge = zen_get_attributes_qty_prices_onetime($attribute_price->fields['attributes_qty_prices_onetime'], $qty);
$totalOnetimeCharge += $added_charge;
}
////////////////////////////////////////////////
}
}
}
// attributes price
// attributes weight
if (isset($this->contents[$products_id]['attributes'])) {
reset($this->contents[$products_id]['attributes']);
while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$attribute_weight_query = "select products_attributes_weight, products_attributes_weight_prefix\n from %table.products_attributes%\n where products_id = '" . (int) $prid . "'\n and options_id = '" . (int) $option . "'\n and options_values_id = '" . (int) $value . "'";
$attribute_weight = $this->getDb()->Execute($attribute_weight_query);
// adjusted count for free shipping
if ($product->fields['product_is_always_free_shipping'] != 1) {
$new_attributes_weight = $attribute_weight->fields['products_attributes_weight'];
} else {
$new_attributes_weight = 0;
}
// shipping adjustments for Attributes
if ($product->fields['product_is_always_free_shipping'] == 1 or $product->fields['products_virtual'] == 1 or preg_match('/^GIFT/', addslashes($product->fields['products_model']))) {
if ($attribute_weight->fields['products_attributes_weight_prefix'] == '-') {
$this->free_shipping_weight -= $qty * $attribute_weight->fields['products_attributes_weight'];
} else {
$this->free_shipping_weight += $qty * $attribute_weight->fields['products_attributes_weight'];
}
}
// + or blank adds
if ($attribute_weight->fields['products_attributes_weight_prefix'] == '-') {
$this->weight -= $qty * $new_attributes_weight;
} else {
$this->weight += $qty * $new_attributes_weight;
}
}
}
// attributes weight
/*
// uncomment for odd shipping requirements needing this:
// if 0 weight defined as free shipping adjust for functions free_shipping_price and free_shipping_item
if (($product->fields['products_weight'] == 0 && ORDER_WEIGHT_ZERO_STATUS == 1) && !($product->fields['products_virtual'] == 1) && !(preg_match('/^GIFT/', addslashes($product->fields['products_model']))) && !($product->fields['product_is_always_free_shipping'] == 1)) {
$freeShippingTotal += $products_price;
$this->free_shipping_item += $qty;
}
*/
$this->total += zen_round(zen_add_tax($productTotal, $products_tax), $decimalPlaces) * $qty;
$this->total += zen_round(zen_add_tax($totalOnetimeCharge, $products_tax), $decimalPlaces);
$this->free_shipping_price += zen_round(zen_add_tax($freeShippingTotal, $products_tax), $decimalPlaces) * $qty;
if ($product->fields['product_is_always_free_shipping'] == 1 or $product->fields['products_virtual'] == 1 or preg_match('/^GIFT/', addslashes($product->fields['products_model']))) {
$this->free_shipping_price += zen_round(zen_add_tax($totalOnetimeCharge, $products_tax), $decimalPlaces);
}
}
}