function process() { global $oOrder, $oCurrencies; if (MODULE_ORDER_TOTAL_LOWORDERFEE_LOW_ORDER_FEE == '1') { switch (MODULE_ORDER_TOTAL_LOWORDERFEE_DESTINATION) { case 'national': if ($oOrder->delivery['country_id'] == STORE_COUNTRY) $pass = true; break; case 'international': if ($oOrder->delivery['country_id'] != STORE_COUNTRY) $pass = true; break; case 'both': $pass = true; break; default: $pass = false; break; } if ( ($pass == true) && ( ($oOrder->info['total'] - $oOrder->info['shipping_cost']) < MODULE_ORDER_TOTAL_LOWORDERFEE_ORDER_UNDER) ) { $tax = oos_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); // $tax_description = oos_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->delivery['country']['id'], $oOrder->delivery['zone_id']); $tax_description = oos_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); $oOrder->info['tax'] += oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $oOrder->info['tax_groups']["$tax_description"] += oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $oOrder->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + oos_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $this->output[] = array('title' => $this->title . ':', 'text' => $oCurrencies->format(oos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax), true, $oOrder->info['currency'], $oOrder->info['currency_value']), 'value' => oos_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax)); } } }
/** * Smarty {oos_add_tax} function plugin * * Type: function * Name: oos_get_zone_name * Version: 1.0 * ------------------------------------------------------------- */ function smarty_function_oos_add_tax($params, &$smarty) { global $oCurrencies; MyOOS_CoreApi::requireOnce('lib/smarty/libs/plugins/shared.escape_special_chars.php'); foreach ($params as $_key => $_val) { ${$_key} = smarty_function_escape_special_chars($_val); } if ($_SESSION['member']->group['show_price_tax'] == 1) { return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + oos_calculate_tax($price, $tax); } else { return round($price, $oCurrencies->currencies[DEFAULT_CURRENCY]['decimal_places']); } }
function process() { global $oOrder, $oCurrencies; if (MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == '1') { switch (MODULE_ORDER_TOTAL_SHIPPING_DESTINATION) { case 'national': if ($oOrder->delivery['country_id'] == STORE_COUNTRY) { $pass = true; } break; case 'international': if ($oOrder->delivery['country_id'] != STORE_COUNTRY) { $pass = true; } break; case 'both': $pass = true; break; default: $pass = false; break; } if ($pass == true && $oOrder->info['total'] - $oOrder->info['shipping_cost'] >= MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER) { $oOrder->info['shipping_method'] = $this->title; $oOrder->info['total'] -= $oOrder->info['shipping_cost']; $oOrder->info['shipping_cost'] = 0; } } $module = substr($_SESSION['shipping']['id'], 0, strpos($_SESSION['shipping']['id'], '_')); if (oos_is_not_null($oOrder->info['shipping_method'])) { if ($GLOBALS[$module]->tax_class > 0) { $shipping_tax = oos_get_tax_rate($GLOBALS[$module]->tax_class, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); $shipping_tax_description = oos_get_tax_rate($GLOBALS[$module]->tax_class, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); $tax = oos_calculate_tax($oOrder->info['shipping_cost'], $shipping_tax); if ($_SESSION['member']->group['show_price_tax'] == 1) { $oOrder->info['shipping_cost'] += $tax; } $oOrder->info['tax'] += $tax; $oOrder->info['tax_groups']["{$shipping_tax_description}"] += $tax; $oOrder->info['total'] += $tax; } $this->output[] = array('title' => $oOrder->info['shipping_method'] . ':', 'text' => $oCurrencies->format($oOrder->info['shipping_cost'], true, $oOrder->info['currency'], $oOrder->info['currency_value']), 'value' => $oOrder->info['shipping_cost']); } }
function oos_add_tax($price, $tax) { global $currencies; if (DISPLAY_PRICE_WITH_TAX == '1') { return round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + oos_calculate_tax($price, $tax); } else { return round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']); } }
function process() { global $oOrder, $oCurrencies, $cod_cost, $cod_country; if (MODULE_ORDER_TOTAL_COD_STATUS == '1') { //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 ($_SESSION['shipping']['id'] == 'flat_flat') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_FLAT); } if ($_SESSION['shipping']['id'] == 'item_item') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ITEM); } if ($_SESSION['shipping']['id'] == 'table_table') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_TABLE); } if ($_SESSION['shipping']['id'] == 'zones_zones') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_ZONES); } if ($_SESSION['shipping']['id'] == 'ap_ap') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_AP); } if ($_SESSION['shipping']['id'] == 'dp_dp') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_DP); } if ($_SESSION['shipping']['id'] == 'chp_ECO') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_PRI') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'chp_URG') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CHP); } if ($_SESSION['shipping']['id'] == 'certifiedmail_certifiedmail') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_CERTIFIEDMAIL); } if ($_SESSION['shipping']['id'] == 'hermes_hermes') { $cod_zones = split("[:,]", MODULE_ORDER_TOTAL_COD_FEE_HERMES); } for ($i = 0; $i < count($cod_zones); $i++) { if ($cod_zones[$i] == $oOrder->billing['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) { if (MODULE_ORDER_TOTAL_COD_TAX_CLASS > 0) { $cod_tax = oos_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); // $cod_tax_description = oos_get_tax_description(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); $cod_tax_description = oos_get_tax_rate(MODULE_ORDER_TOTAL_COD_TAX_CLASS, $oOrder->billing['country']['id'], $oOrder->billing['zone_id']); $oOrder->info['tax'] += oos_calculate_tax($cod_cost, $cod_tax); $oOrder->info['tax_groups']["{$cod_tax_description}"] += oos_calculate_tax($cod_cost, $cod_tax); $oOrder->info['total'] += $cod_cost + oos_calculate_tax($cod_cost, $cod_tax); $this->output[] = array('title' => $this->title . ':', 'text' => $oCurrencies->format(oos_add_tax($cod_cost, $cod_tax), true, $oOrder->info['currency'], $oOrder->info['currency_value']), 'value' => oos_add_tax($cod_cost, $cod_tax)); } else { $oOrder->info['total'] += $cod_cost; $this->output[] = array('title' => $this->title . ':', 'text' => $oCurrencies->format($cod_cost, true, $oOrder->info['currency'], $oOrder->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' => ''); } } }
/** * Add tax to a products price * * @param $price * @param $tax */ function oos_add_tax($price, $tax) { if( ($_SESSION['member']->group['show_price_tax'] == 1) && ($tax > 0) ) { return $price + oos_calculate_tax($price, $tax); } else { return $price; } }
function get_order_total() { global $oOrder; $order_total = $oOrder->info['total']; // Check if gift voucher is in cart and adjust total $products = $_SESSION['cart']->get_products(); for ($i = 0; $i < count($products); $i++) { $t_prid = oos_get_product_id($products[$i]['id']); // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $productstable = $oostable['products']; $query = "SELECT products_price, products_tax_class_id, products_model\n FROM {$productstable}\n WHERE products_id = '" . intval($t_prid) . "'"; $gv_result = $dbconn->GetRow($query); if (ereg('^GIFT', addslashes($gv_result['products_model']))) { $qty = $_SESSION['cart']->get_quantity($t_prid); $products_tax = oos_get_tax_rate($gv_result['products_tax_class_id']); if ($this->include_tax == '0') { $gv_amount = $gv_result['products_price'] * $qty; } else { $gv_amount = ($gv_result['products_price'] + oos_calculate_tax($gv_result['products_price'], $products_tax)) * $qty; } $order_total = $order_total - $gv_amount; } } if ($this->include_tax == '0') { $order_total = $order_total - $oOrder->info['tax']; } if ($this->include_shipping == '0') { $order_total = $order_total - $oOrder->info['shipping_cost']; } return $order_total; }
function get_product_price($product_id) { global $oOrder; // Get database information $dbconn =& oosDBGetConn(); $oostable =& oosDBGetTables(); $products_id = oos_get_product_id($product_id); // products price $qty = $_SESSION['cart']->contents[$product_id]['qty']; $productstable = $oostable['products']; $product_query = $dbconn->Execute("SELECT products_id, products_price, products_tax_class_id, products_weight FROM {$productstable} WHERE products_id='" . (int) $product_id . "'"); if ($product = $product_query->fields) { $prid = $product['products_id']; $products_tax = oos_get_tax_rate($product['products_tax_class_id']); $products_price = $product['products_price']; $specialstable = $oostable['specials']; $specials_query = $dbconn->Execute("SELECT specials_new_products_price FROM {$specialstable} WHERE products_id = '" . (int) $prid . "' AND status = '1'"); if ($specials_query->RecordCount()) { $specials = $specials_query->fields; $products_price = $specials['specials_new_products_price']; } if ($this->include_tax == '1') { $total_price += ($products_price + oos_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'])) { $products_attributestable = $oostable['products_attributes']; $attribute_price_query = $dbconn->Execute("SELECT options_values_price, price_prefix FROM {$products_attributestable} WHERE products_id = '" . (int) $prid . "' AND options_id = '" . oos_db_input($option) . "' AND options_values_id = '" . oos_db_input($value) . "'"); $attribute_price = $attribute_price_query->fields; if ($attribute_price['price_prefix'] == '+') { if ($this->include_tax == '1') { $total_price += $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price += $qty * $attribute_price['options_values_price']; } } else { if ($this->include_tax == '1') { $total_price -= $qty * ($attribute_price['options_values_price'] + oos_calculate_tax($attribute_price['options_values_price'], $products_tax)); } else { $total_price -= $qty * $attribute_price['options_values_price']; } } } } } if ($this->include_shipping == '1') { $total_price += $oOrder->info['shipping_cost']; } return $total_price; }
$sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'orders_products_filename' => $attributes_values['products_attributes_filename'], 'download_maxdays' => $attributes_values['products_attributes_maxdays'], 'download_count' => $attributes_values['products_attributes_maxcount']); // insert oos_db_perform($oostable['orders_products_download'], $sql_data_array); } $products_ordered_attributes .= "\n\t" . $attributes_values['products_options_name'] . ' ' . oos_decode_special_chars($oOrder->products[$i]['attributes'][$j]['value']); } } // insert customer choosen option eof $total_weight += ($oOrder->products[$i]['qty'] * $oOrder->products[$i]['weight']); $total_tax += oos_calculate_tax($total_products_price, $products_tax) * $oOrder->products[$i]['qty']; $total_cost += $total_products_price; $products_ordered .= $oOrder->products[$i]['qty'] . ' x ' . $oOrder->products[$i]['name'] . ' (' . $oOrder->products[$i]['model'] . ') = ' . $oCurrencies->display_price($oOrder->products[$i]['final_price'], $oOrder->products[$i]['tax'], $oOrder->products[$i]['qty']) . $products_ordered_attributes . "\n"; } $oOrderTotalModules->apply_credit(); // lets start with the email confirmation $email_order = STORE_NAME . "\n" . $aLang['email_separator'] . "\n" . $aLang['email_text_order_number'] . ' ' . $insert_id . "\n" . $aLang['email_text_invoice_url'] . ' ' . oos_href_link($aPages['account_history_info'], 'order_id=' . $insert_id, 'SSL', false) . "\n" . $aLang['email_text_date_ordered'] . ' ' . strftime(DATE_FORMAT_LONG) . "\n\n"; if ($oOrder->info['comments']) {