function process() { global $order, $xtPrice; //include needed functions require_once DIR_FS_INC . 'xtc_calculate_tax.inc.php'; 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) { $tax = xtc_get_tax_rate(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); $tax_description = xtc_get_tax_description(MODULE_ORDER_TOTAL_LOWORDERFEE_TAX_CLASS, $order->delivery['country']['id'], $order->delivery['zone_id']); if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $order->info['tax'] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['tax_groups'][TAX_ADD_TAX . "{$tax_description}"] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['total'] += MODULE_ORDER_TOTAL_LOWORDERFEE_FEE + xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $low_order_fee = xtc_add_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE; $order->info['tax'] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['tax_groups'][TAX_NO_TAX . "{$tax_description}"] += xtc_calculate_tax(MODULE_ORDER_TOTAL_LOWORDERFEE_FEE, $tax); $order->info['subtotal'] += $low_order_fee; $order->info['total'] += $low_order_fee; } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] != 1) { $low_order_fee = MODULE_ORDER_TOTAL_LOWORDERFEE_FEE; $order->info['subtotal'] += $low_order_fee; $order->info['total'] += $low_order_fee; } $this->output[] = array('title' => $this->title . ':', 'text' => $xtPrice->xtcFormat($low_order_fee, true), 'value' => $low_order_fee); } } }
function xtc_order_total() { global $order; $this->amounts['total'] = 0; $order_total = $order->info['total']; // Check if gift voucher is in cart and adjust total $products = $_SESSION['cart']->get_products(); for ($i = 0; $i < sizeof($products); $i++) { $t_prid = xtc_get_prid($products[$i]['id']); $gv_query = xtc_db_query("select products_price, products_tax_class_id, products_model from " . TABLE_PRODUCTS . " where products_id = '" . $t_prid . "'"); $gv_result = xtc_db_fetch_array($gv_query); $qty = $_SESSION['cart']->get_quantity($products[$i]['id']); $products_tax = xtc_get_tax_rate($gv_result['products_tax_class_id']); if (!isset($this->amounts[(string) $products_tax])) { $this->amounts[(string) $products_tax] = 0; } if (substr($gv_result['products_model'], 0, 4) == 'GIFT') { if ($this->include_tax == 'false') { $gv_amount = $gv_result['products_price'] * $qty; } else { $gv_amount = ($gv_result['products_price'] + xtc_calculate_tax($gv_result['products_price'], $products_tax)) * $qty; } $order_total -= $gv_amount; } else { $this->amounts[(string) $products_tax] += $gv_result['products_price'] * (int) $qty; $this->amounts['total'] += $gv_result['products_price'] * $qty; } } if ($this->include_shipping == 'false') { $order_total -= $order->info['shipping_cost']; } if ($this->include_tax == 'false') { $order_total -= $order->info['tax']; } $this->amount = $order_total; }
/** * Use $_SESSION to insert the order into the shop-db --- $_SESSION must contain all order-data! $GLOBALS must be set with all needed vars! * incl. attributes and stockupdate * @return array with orderId and orderProductsIds */ public function insertOrderIntoShop() { global $order, $order_total_modules, $order_totals, $insert_id; if (!is_object($order)) { //$order doesnt exist if called by notification! $order = $this->Order; } $order_total_modules = $this->orderTotalModules; $order_totals = $this->orderTotals; $tmp_status = $order->info['order_status']; if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == 1) { $discount = $_SESSION['customers_status']['customers_status_ot_discount']; } else { $discount = '0.00'; } if ($_SERVER["HTTP_X_FORWARDED_FOR"]) { $customers_ip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } else { $customers_ip = $_SERVER["REMOTE_ADDR"]; } if ($_SESSION['credit_covers'] != '1') { $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_firstname' => $order->customer['firstname'], 'customers_lastname' => $order->customer['lastname'], 'customers_cid' => $order->customer['csID'], 'customers_vat_id' => $_SESSION['customer_vat_id'], 'customers_company' => $order->customer['company'], 'customers_status' => $_SESSION['customers_status']['customers_status_id'], 'customers_status_name' => $_SESSION['customers_status']['customers_status_name'], 'customers_status_image' => $_SESSION['customers_status']['customers_status_image'], 'customers_status_discount' => $discount, 'customers_street_address' => $order->customer['street_address'], 'customers_suburb' => $order->customer['suburb'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_firstname' => $order->delivery['firstname'], 'delivery_lastname' => $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_suburb' => $order->delivery['suburb'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_country_iso_code_2' => $order->delivery['country']['iso_code_2'], 'delivery_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $order->billing['lastname'], 'billing_firstname' => $order->billing['firstname'], 'billing_lastname' => $order->billing['lastname'], 'billing_company' => $order->billing['company'], 'billing_street_address' => $order->billing['street_address'], 'billing_suburb' => $order->billing['suburb'], 'billing_city' => $order->billing['city'], 'billing_postcode' => $order->billing['postcode'], 'billing_state' => $order->billing['state'], 'billing_country' => $order->billing['country']['title'], 'billing_country_iso_code_2' => $order->billing['country']['iso_code_2'], 'billing_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'payment_class' => $order->info['payment_class'], 'shipping_method' => $order->info['shipping_method'], 'shipping_class' => $order->info['shipping_class'], 'date_purchased' => 'now()', 'orders_status' => $tmp_status, 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value'], 'customers_ip' => $customers_ip, 'language' => $_SESSION['language'], 'comments' => $order->info['comments']); } else { // free gift , no paymentaddress $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_firstname' => $order->customer['firstname'], 'customers_lastname' => $order->customer['lastname'], 'customers_cid' => $order->customer['csID'], 'customers_vat_id' => $_SESSION['customer_vat_id'], 'customers_company' => $order->customer['company'], 'customers_status' => $_SESSION['customers_status']['customers_status_id'], 'customers_status_name' => $_SESSION['customers_status']['customers_status_name'], 'customers_status_image' => $_SESSION['customers_status']['customers_status_image'], 'customers_status_discount' => $discount, 'customers_street_address' => $order->customer['street_address'], 'customers_suburb' => $order->customer['suburb'], 'customers_city' => $order->customer['city'], 'customers_postcode' => $order->customer['postcode'], 'customers_state' => $order->customer['state'], 'customers_country' => $order->customer['country']['title'], 'customers_telephone' => $order->customer['telephone'], 'customers_email_address' => $order->customer['email_address'], 'customers_address_format_id' => $order->customer['format_id'], 'delivery_name' => $order->delivery['firstname'] . ' ' . $order->delivery['lastname'], 'delivery_firstname' => $order->delivery['firstname'], 'delivery_lastname' => $order->delivery['lastname'], 'delivery_company' => $order->delivery['company'], 'delivery_street_address' => $order->delivery['street_address'], 'delivery_suburb' => $order->delivery['suburb'], 'delivery_city' => $order->delivery['city'], 'delivery_postcode' => $order->delivery['postcode'], 'delivery_state' => $order->delivery['state'], 'delivery_country' => $order->delivery['country']['title'], 'delivery_country_iso_code_2' => $order->delivery['country']['iso_code_2'], 'delivery_address_format_id' => $order->delivery['format_id'], 'payment_method' => $order->info['payment_method'], 'payment_class' => $order->info['payment_class'], 'shipping_method' => $order->info['shipping_method'], 'shipping_class' => $order->info['shipping_class'], 'date_purchased' => 'now()', 'orders_status' => $tmp_status, 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value'], 'customers_ip' => $customers_ip, 'comments' => $order->info['comments']); } xtc_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = xtc_db_insert_id(); for ($i = 0, $n = sizeof($order_totals); $i < $n; $i++) { $sql_data_array = array('orders_id' => $insert_id, 'title' => $order_totals[$i]['title'], 'text' => $order_totals[$i]['text'], 'value' => $order_totals[$i]['value'], 'class' => $order_totals[$i]['code'], 'sort_order' => $order_totals[$i]['sort_order']); xtc_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); } $customer_notification = SEND_EMAILS == 'true' ? '1' : '0'; $sql_data_array = array('orders_id' => $insert_id, 'orders_status_id' => $order->info['order_status'], 'date_added' => 'now()', 'customer_notified' => $customer_notification, 'comments' => $order->info['comments']); xtc_db_perform(TABLE_ORDERS_STATUS_HISTORY, $sql_data_array); // initialized for the email confirmation $products_ordered = ''; $products_ordered_html = ''; $subtotal = 0; $total_tax = 0; $sofortData = array(); for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $sofortData[$i] = array(); $sofortData[$i]['sofortItemId'] = $order->products[$i]['id']; if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT products_quantity, pad.products_attributes_filename\n\t\t\t\t\t\t\t\t FROM " . TABLE_PRODUCTS . " p\n\t\t\t\t\t\t\t\t LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\t\t\t\t ON p.products_id=pa.products_id\n\t\t\t\t\t\t\t\t LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\t\t\t\t\t\t\t\t ON pa.products_attributes_id=pad.products_attributes_id\n\t\t\t\t\t\t\t\t WHERE p.products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->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 = $order->products[$i]['attributes']; if (is_array($products_attributes)) { $stock_query_raw .= " AND pa.options_id = '" . HelperFunctions::escapeSql($products_attributes[0]['option_id']) . "' AND pa.options_values_id = '" . HelperFunctions::escapeSql($products_attributes[0]['value_id']) . "'"; } $stock_query = xtc_db_query($stock_query_raw); } else { $stock_query = xtc_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "'"); } if (xtc_db_num_rows($stock_query) > 0) { $stock_values = xtc_db_fetch_array($stock_query); // do not decrement quantities if products_attributes_filename exists if (DOWNLOAD_ENABLED != 'true' || !$stock_values['products_attributes_filename']) { $stock_left = $stock_values['products_quantity'] - $order->products[$i]['qty']; } else { $stock_left = $stock_values['products_quantity']; } // doppelbuchung der Artikel bei Rbs verhindern if ($order->info['payment_method'] != 'sofort_sofortrechnung') { xtc_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . HelperFunctions::escapeSql($stock_left) . "' where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "'"); } if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false') { xtc_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "'"); } } } // Update products_ordered (for bestsellers list) xtc_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . HelperFunctions::escapeSql(sprintf('%d', $order->products[$i]['qty'])) . " where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "'"); $sql_data_array = array('orders_id' => $insert_id, 'products_id' => xtc_get_prid($order->products[$i]['id']), 'products_model' => $order->products[$i]['model'], 'products_name' => $order->products[$i]['name'], 'products_shipping_time' => $order->products[$i]['shipping_time'], 'products_price' => $order->products[$i]['price'], 'final_price' => $order->products[$i]['final_price'], 'products_tax' => $order->products[$i]['tax'], 'products_discount_made' => $order->products[$i]['discount_allowed'], 'products_quantity' => $order->products[$i]['qty'], 'allow_tax' => $_SESSION['customers_status']['customers_status_show_price_tax']); xtc_db_perform(TABLE_ORDERS_PRODUCTS, $sql_data_array); $order_products_id = xtc_db_insert_id(); $sofortData[$i]['sofortOrderProductsId'] = $order_products_id; // Aenderung Specials Quantity Anfang $specials_result = xtc_db_query("SELECT products_id, specials_quantity from " . TABLE_SPECIALS . " WHERE products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "' "); if (xtc_db_num_rows($specials_result)) { $spq = xtc_db_fetch_array($specials_result); $new_sp_quantity = $spq['specials_quantity'] - $order->products[$i]['qty']; if ($new_sp_quantity >= 1) { xtc_db_query("update " . TABLE_SPECIALS . " set specials_quantity = '" . HelperFunctions::escapeSql($new_sp_quantity) . "' where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "' "); } else { xtc_db_query("update " . TABLE_SPECIALS . " set status = '0', specials_quantity = '" . HelperFunctions::escapeSql($new_sp_quantity) . "' where products_id = '" . HelperFunctions::escapeSql(xtc_get_prid($order->products[$i]['id'])) . "' "); } } // Aenderung Ende $order_total_modules->update_credit_account($i); // GV Code ICW ADDED FOR CREDIT CLASS SYSTEM //------insert customer choosen option to order-------- $attributes_exist = '0'; $products_ordered_attributes = ''; if (isset($order->products[$i]['attributes'])) { $attributes_exist = '1'; for ($j = 0, $n2 = sizeof($order->products[$i]['attributes']); $j < $n2; $j++) { if (DOWNLOAD_ENABLED == 'true') { $attributes_query = "select popt.products_options_name,\n\t\t\t\t\t\t\t\t\t\t poval.products_options_values_name,\n\t\t\t\t\t\t\t\t\t\t pa.options_values_price,\n\t\t\t\t\t\t\t\t\t\t pa.price_prefix,\n\t\t\t\t\t\t\t\t\t\t pad.products_attributes_maxdays,\n\t\t\t\t\t\t\t\t\t\t pad.products_attributes_maxcount,\n\t\t\t\t\t\t\t\t\t\t pad.products_attributes_filename\n\t\t\t\t\t\t\t\t\t\t from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\t\t\t\t\t\t left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n\t\t\t\t\t\t\t\t\t\t on pa.products_attributes_id=pad.products_attributes_id\n\t\t\t\t\t\t\t\t\t\t where pa.products_id = '" . HelperFunctions::escapeSql($order->products[$i]['id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_id = '" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['option_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_id = popt.products_options_id\n\t\t\t\t\t\t\t\t\t\t and pa.options_values_id = '" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['value_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\t\t\t\t\t\t and popt.language_id = '" . HelperFunctions::escapeSql($_SESSION['languages_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and poval.language_id = '" . HelperFunctions::escapeSql($_SESSION['languages_id']) . "'"; $attributes = xtc_db_query($attributes_query); } else { $attributes = xtc_db_query("select popt.products_options_name,\n\t\t\t\t\t\t\t\t\t\t poval.products_options_values_name,\n\t\t\t\t\t\t\t\t\t\t pa.options_values_price,\n\t\t\t\t\t\t\t\t\t\t pa.price_prefix\n\t\t\t\t\t\t\t\t\t\t from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n\t\t\t\t\t\t\t\t\t\t where pa.products_id = '" . HelperFunctions::escapeSql($order->products[$i]['id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_id = '" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['option_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_id = popt.products_options_id\n\t\t\t\t\t\t\t\t\t\t and pa.options_values_id = '" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['value_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and pa.options_values_id = poval.products_options_values_id\n\t\t\t\t\t\t\t\t\t\t and popt.language_id = '" . HelperFunctions::escapeSql($_SESSION['languages_id']) . "'\n\t\t\t\t\t\t\t\t\t\t and poval.language_id = '" . HelperFunctions::escapeSql($_SESSION['languages_id']) . "'"); } // update attribute stock xtc_db_query("UPDATE " . TABLE_PRODUCTS_ATTRIBUTES . " set\n\t\t\t\t\t\t\t\t attributes_stock=attributes_stock - '" . HelperFunctions::escapeSql($order->products[$i]['qty']) . "'\n\t\t\t\t\t\t\t\t where\n\t\t\t\t\t\t\t\t products_id='" . HelperFunctions::escapeSql($order->products[$i]['id']) . "'\n\t\t\t\t\t\t\t\t and options_values_id='" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['value_id']) . "'\n\t\t\t\t\t\t\t\t and options_id='" . HelperFunctions::escapeSql($order->products[$i]['attributes'][$j]['option_id']) . "'\n\t\t\t\t\t\t\t\t "); $attributes_values = xtc_db_fetch_array($attributes); $sql_data_array = array('orders_id' => $insert_id, 'orders_products_id' => $order_products_id, 'products_options' => $attributes_values['products_options_name'], 'products_options_values' => $attributes_values['products_options_values_name'], 'options_values_price' => $attributes_values['options_values_price'], 'price_prefix' => $attributes_values['price_prefix']); xtc_db_perform(TABLE_ORDERS_PRODUCTS_ATTRIBUTES, $sql_data_array); if (DOWNLOAD_ENABLED == 'true' && isset($attributes_values['products_attributes_filename']) && xtc_not_null($attributes_values['products_attributes_filename'])) { $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']); xtc_db_perform(TABLE_ORDERS_PRODUCTS_DOWNLOAD, $sql_data_array); } } } //------insert customer choosen option eof ---- $total_weight += $order->products[$i]['qty'] * $order->products[$i]['weight']; $total_tax += xtc_calculate_tax($total_products_price, $products_tax) * $order->products[$i]['qty']; $total_cost += $total_products_price; } if (isset($_SESSION['tracking']['refID'])) { xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t refferers_id = '" . HelperFunctions::escapeSql($_SESSION['tracking']['refID']) . "'\n\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); // check if late or direct sale $customers_logon_query = "SELECT customers_info_number_of_logons\n\t\t\t\t\t\t FROM " . TABLE_CUSTOMERS_INFO . " \n\t\t\t\t\t\t WHERE customers_info_id = '" . HelperFunctions::escapeSql($_SESSION['customer_id']) . "'"; $customers_logon_query = xtc_db_query($customers_logon_query); $customers_logon = xtc_db_fetch_array($customers_logon_query); if ($customers_logon['customers_info_number_of_logons'] == 0) { // direct sale xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t\t conversion_type = '1'\n\t\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); } else { // late sale xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t\t conversion_type = '2'\n\t\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); } } else { $customers_query = xtc_db_query("SELECT refferers_id as ref FROM " . TABLE_CUSTOMERS . " WHERE customers_id='" . HelperFunctions::escapeSql($_SESSION['customer_id']) . "'"); $customers_data = xtc_db_fetch_array($customers_query); if (xtc_db_num_rows($customers_query)) { xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t\t refferers_id = '" . HelperFunctions::escapeSql($customers_data['ref']) . "'\n\t\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); // check if late or direct sale $customers_logon_query = "SELECT customers_info_number_of_logons\n\t\t\t\t\t\t\t FROM " . TABLE_CUSTOMERS_INFO . " \n\t\t\t\t\t\t\t WHERE customers_info_id = '" . HelperFunctions::escapeSql($_SESSION['customer_id']) . "'"; $customers_logon_query = xtc_db_query($customers_logon_query); $customers_logon = xtc_db_fetch_array($customers_logon_query); if ($customers_logon['customers_info_number_of_logons'] == 0) { // direct sale xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t\t\t conversion_type = '1'\n\t\t\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); } else { // late sale xtc_db_query("update " . TABLE_ORDERS . " set\n\t\t\t\t\t conversion_type = '2'\n\t\t\t\t\t where orders_id = '" . HelperFunctions::escapeSql($insert_id) . "'"); } } } $order_total_modules->apply_credit(); $return['orderId'] = $insert_id; $return['sofortData'] = $sofortData; return $return; }
function xtc_order_total() { global $order; $order_total = $order->info['total']; $products = $_SESSION['cart']->get_products(); for ($i = 0; $i < sizeof($products); $i++) { $prid = xtc_get_prid($products[$i]['id']); $gv_query = xtc_db_query('SELECT products_price, products_tax_class_id, products_model FROM ' . TABLE_PRODUCTS . ' WHERE products_id = "' . xtc_db_input($prid) . '"'); $gv_result = xtc_db_fetch_array($gv_query); $qty = $_SESSION['cart']->get_quantity($products[$i]['id']); $products_tax = xtc_get_tax_rate($gv_result['products_tax_class_id']); if (preg_match('/^GIFT/', addslashes($gv_result['products_model']))) { if ($this->include_tax == 'false') { $gv_amount = $gv_result['products_price'] * $qty; } else { $gv_amount = ($gv_result['products_price'] + xtc_calculate_tax($gv_result['products_price'], $products_tax)) * $qty; } $order_total -= $gv_amount; } else { $this->amounts[(string) $products_tax] += $gv_result['products_price'] * (int) $qty; $this->amounts['total'] += $gv_result['products_price'] * $qty; } } $this->amount = $order_total; }