function xtc_get_products($session) { if (!is_array($session)) { return false; } $products_array = array(); reset($session); //BOF - Dokuman - 2009-11-30 - check for array in cart if (is_array($session['cart']->contents)) { //EOF - Dokuman - 2009-11-30 - check for array in cart while (list($products_id, ) = each($session['cart']->contents)) { $products_query = xtc_db_query("select p.products_id, pd.products_name,p.products_image, p.products_model, p.products_price, p.products_discount_allowed, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . xtc_db_input((int) xtc_get_prid($products_id)) . "' and pd.products_id = p.products_id and pd.language_id = '" . xtc_db_input((int) $_SESSION['languages_id']) . "'"); if ($products = xtc_db_fetch_array($products_query)) { $prid = $products['products_id']; // dirty workaround $xtPrice = new xtcPrice($session['currency'], $session['customers_status']['customers_status_id']); $products_price = $xtPrice->xtcGetPrice($products['products_id'], $format = false, $session['cart']->contents[$products_id]['qty'], $products['products_tax_class_id'], $products['products_price']); $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'image' => $products['products_image'], 'price' => $products_price + attributes_price($products_id, $session), 'quantity' => $session['cart']->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + attributes_price($products_id, $session), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => $session['contents'][$products_id]['attributes']); } } return $products_array; } return false; //Dokuman - 2009-11-30 - check for array in cart }
function xtc_get_products_stock($products_id) { $products_id = xtc_get_prid($products_id); $stock_query = xtc_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . xtc_db_input((int) $products_id) . "'"); $stock_values = xtc_db_fetch_array($stock_query); return $stock_values['products_quantity']; }
function xtc_get_uprid($prid, $params) { if (is_numeric($prid)) { $uprid = $prid; if (is_array($params) && sizeof($params) > 0) { $attributes_check = true; $attributes_ids = ''; reset($params); while (list($option, $value) = each($params)) { if (is_numeric($option) && is_numeric($value)) { $attributes_ids .= '{' . (int) $option . '}' . (int) $value; } else { $attributes_check = false; break; } } if ($attributes_check == true) { $uprid .= $attributes_ids; } } } else { $uprid = xtc_get_prid($prid); if (is_numeric($uprid)) { if (strpos($prid, '{') !== false) { $attributes_check = true; $attributes_ids = ''; $attributes = explode('{', substr($prid, strpos($prid, '{') + 1)); for ($i = 0, $n = sizeof($attributes); $i < $n; $i++) { $pair = explode('}', $attributes[$i]); if (is_numeric($pair[0]) && is_numeric($pair[1])) { $attributes_ids .= '{' . (int) $pair[0] . '}' . (int) $pair[1]; } else { $attributes_check = false; break; } } if ($attributes_check == true) { $uprid .= $attributes_ids; } } } else { return false; } } return $uprid; }
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; }
/** * Build the cart to be used for the purchase. * * @param string $estoreUser estoreUser identifier * @param object $order osCommerce order object * @param string $option invoice, part or spec * @param string $code payment code * @param int $paymentPlan pclass id * * @return void */ public function buildCart($estoreUser, $order, $option, $code, $paymentPlan) { if ($option == KiTT::PART) { $artno = MODULE_PAYMENT_KLARNA_PARTPAYMENT_ARTNO; } else { if ($option == KiTT::SPEC) { $artno = MODULE_PAYMENT_KLARNA_SPECCAMP_ARTNO; } else { $artno = MODULE_PAYMENT_KLARNA_INVOICE_ARTNO; } } $flags = KlarnaFlags::INC_VAT; if (KlarnaConstant::showPriceTax() === false) { $flags = KlarnaFlags::NO_FLAG; } // Add all the articles to the goodslist foreach ($order->products as $product) { $attributes = ""; if (isset($product['attributes'])) { foreach ($product['attributes'] as $attr) { $attributes = $attributes . ", " . $attr['option'] . ": " . $attr['value']; } } $artnumber = $product[$artno]; if ($artno == 'id' || $artno == '') { $artnumber = xtc_get_prid($product['id']); } $this->_klarna->addArticle(KiTT_String::encode($product['qty']), KiTT_String::encode($artnumber), KiTT_String::encode(strip_tags($product['name'] . $attributes)), KiTT_String::encode($product['price']), KiTT_String::encode(number_format($product['tax'], 2)), 0, $flags); } // Then the extra charges like shipping and invoicefee and // discount. $klarna_ot = $_SESSION['klarna_ot']; $extra = $klarna_ot['code_entries']; // If someone tries to set a pclass value to -1 using firebug, force // an invoice fee on them. if ($paymentPlan < 0) { $code = "klarna"; } // Go over all the order total modules that are active for this order // and add them. foreach ($klarna_ot as $key => $item) { $flags = KlarnaFlags::INC_VAT; if (KlarnaConstant::showPriceTax() === false) { $flags = KlarnaFlags::NO_FLAG; } if ($key === "ot_shipping") { $flags |= KlarnaFlags::IS_SHIPMENT; } else { if ($key === "ot_klarna_fee") { $flags |= KlarnaFlags::IS_HANDLING; } else { if ($key === "ot_coupon" || $key === "ot_discount" || $key === "ot_gv") { if ($item["value"] > 0) { $item["value"] *= -1; } } } } $title = rtrim($item["title"], ':'); $this->_klarna->addArticle(1, "", html_entity_decode($title, ENT_COMPAT, KiTT_String::$klarnaEncoding), $item["value"], $item["rate"], 0, $flags); } }
function _process_order() { try { /** * Process the internal cartID to match the cartID in the $_SESSION */ if (isset($_SESSION['cart']->cartID) && isset($_SESSION['cartID'])) { if ($_SESSION['cart']->cartID != $_SESSION['cartID']) { return false; } } $order = new order(); /** * PropertiesControl Object */ $coo_properties = MainFactory::create_object('PropertiesControl'); $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 (gm_get_conf("GM_SHOW_IP") == '1' && gm_get_conf("GM_LOG_IP") == '1') { $customers_ip = $_SESSION['user_info']['user_ip']; } $comments = ''; if (trim((string) $this->_request->comment_client) != '') { $comments .= sprintf('Customer\'s Comment: %s', trim((string) $this->_request->comment_client) . "\n"); } $comments .= sprintf('Rakuten Order No: %s', (string) $this->_request->order_no . "\n") . sprintf('Rakuten Client ID: %s', (string) $this->_request->client->client_id . "\n"); $order->info['comments'] = $comments; $order->info['rakuten_order_no'] = (string) $this->_request->order_no; $billing_addr = $this->_request->client; $order->customer['email_address'] = (string) $billing_addr->email; $order->customer['firstname'] = $this->_escape_str_revert((string) $billing_addr->first_name); $order->customer['lastname'] = $this->_escape_str_revert((string) $billing_addr->last_name); $order->customer['telephone'] = (string) $billing_addr->phone; $billing_country_result = xtc_db_query("SELECT countries_id, countries_name from " . TABLE_COUNTRIES . " WHERE countries_iso_code_2 = '" . (string) $billing_addr->country . "' "); if (xtc_db_num_rows($billing_country_result)) { $billing_country = xtc_db_fetch_array($billing_country_result); } else { $billing_country['countries_id'] = -1; $billing_country['countries_name'] = (string) $billing_addr->country; } $order->billing['firstname'] = (string) $billing_addr->first_name; $order->billing['lastname'] = (string) $billing_addr->last_name; $order->billing['company'] = (string) $billing_addr->company; $order->billing['street_address'] = (string) $billing_addr->street . " " . (string) $billing_addr->street_no . ((string) $billing_addr->address_add ? '<br />' . (string) $billing_addr->address_add : ''); $order->billing['city'] = (string) $billing_addr->city; $order->billing['postcode'] = (string) $billing_addr->zip_code; $order->billing['country']['title'] = $billing_country['countries_name']; $order->billing['country']['iso_code_2'] = (string) $billing_addr->country; $order->billing['format_id'] = '5'; $shipping_addr = $this->_request->delivery_address; $shipping_country_result = xtc_db_query("SELECT countries_id, countries_name from " . TABLE_COUNTRIES . " WHERE countries_iso_code_2 = '" . (string) $shipping_addr->country . "' "); if (xtc_db_num_rows($shipping_country_result)) { $shipping_country = xtc_db_fetch_array($shipping_country_result); } else { $shipping_country['countries_id'] = -1; $shipping_country['countries_name'] = (string) $shipping_addr->country; } $order->delivery['firstname'] = (string) $shipping_addr->first_name; $order->delivery['lastname'] = (string) $shipping_addr->last_name; $order->delivery['company'] = (string) $shipping_addr->company; $order->delivery['street_address'] = (string) $shipping_addr->street . " " . (string) $shipping_addr->street_no . ((string) $shipping_addr->address_add ? '<br />' . (string) $shipping_addr->address_add : ''); $order->delivery['city'] = (string) $shipping_addr->city; $order->delivery['postcode'] = (string) $shipping_addr->zip_code; $order->delivery['country']['title'] = $shipping_country['countries_name']; $order->delivery['country']['iso_code_2'] = (string) $shipping_addr->country; $order->delivery['format_id'] = '5'; $order->info['payment_method'] = 'rakuten'; $order->info['payment_class'] = ''; $order->info['shipping_method'] = 'rakuten'; $order->info['shipping_class'] = ''; $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'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_number' => $order->info['cc_number'], 'cc_expires' => $order->info['cc_expires'], 'cc_start' => $order->info['cc_start'], 'cc_cvv' => $order->info['cc_cvv'], 'cc_issue' => $order->info['cc_issue'], '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'], 'rakuten_order_no' => $order->info['rakuten_order_no']); xtc_db_perform(TABLE_ORDERS, $sql_data_array); $insert_id = xtc_db_insert_id(); $_SESSION['tmp_oID'] = $insert_id; $sql_data_array = array('orders_id' => $insert_id, 'title' => MODULE_PAYMENT_RAKUTEN_SUBTOTAL . ':', 'text' => ' ' . sprintf("%01.2f EUR", (double) $this->_request->total - (double) $this->_request->shipping - (double) $this->_request->total_tax_amount), 'value' => (double) $this->_request->total - (double) $this->_request->shipping - (double) $this->_request->total_tax_amount, 'class' => 'ot_subtotal', 'sort_order' => 10); xtc_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $sql_data_array = array('orders_id' => $insert_id, 'title' => MODULE_PAYMENT_RAKUTEN_SHIPPING . ':', 'text' => ' ' . sprintf("%01.2f EUR", (double) $this->_request->shipping), 'value' => (double) $this->_request->shipping, 'class' => 'ot_shipping', 'sort_order' => 30); xtc_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $sql_data_array = array('orders_id' => $insert_id, 'title' => MODULE_PAYMENT_RAKUTEN_TAX . ':', 'text' => ' ' . sprintf("%01.2f EUR", (double) $this->_request->total_tax_amount), 'value' => (double) $this->_request->total_tax_amount, 'class' => 'ot_tax', 'sort_order' => 97); xtc_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $sql_data_array = array('orders_id' => $insert_id, 'title' => MODULE_PAYMENT_RAKUTEN_TOTAL . ':', 'text' => sprintf("<b> %01.2f EUR</b>", (double) $this->_request->total), 'value' => (double) $this->_request->total, 'class' => 'ot_total', 'sort_order' => 99); xtc_db_perform(TABLE_ORDERS_TOTAL, $sql_data_array); $customer_notification = '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); require_once DIR_FS_CATALOG . 'gm/inc/set_shipping_status.php'; for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { /** * Stock update */ if (STOCK_LIMITED == 'true') { if (DOWNLOAD_ENABLED == 'true') { $stock_query_raw = "SELECT p.products_quantity, pad.products_attributes_filename\n FROM " . TABLE_PRODUCTS . " p\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n ON p.products_id=pa.products_id\n LEFT JOIN " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n ON pa.products_attributes_id=pad.products_attributes_id\n WHERE p.products_id = '" . xtc_get_prid($order->products[$i]['id']) . "'"; $products_attributes = $order->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_query = xtc_db_query($stock_query_raw); } else { $stock_query = xtc_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . 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']; } xtc_db_query("update " . TABLE_PRODUCTS . " set products_quantity = '" . $stock_left . "' where products_id = '" . xtc_get_prid($order->products[$i]['id']) . "'"); if ($stock_left < 1 && STOCK_ALLOW_CHECKOUT == 'false' && GM_SET_OUT_OF_STOCK_PRODUCTS == 'true') { xtc_db_query("update " . TABLE_PRODUCTS . " set products_status = '0' where products_id = '" . xtc_get_prid($order->products[$i]['id']) . "'"); } set_shipping_status($order->products[$i]['id']); if ($stock_left <= STOCK_REORDER_LEVEL) { $gm_get_products_name = xtc_db_query("SELECT products_name\n FROM products_description\n WHERE\n products_id = '" . xtc_get_prid($order->products[$i]['id']) . "'\n AND language_id = '" . $_SESSION['languages_id'] . "'"); $gm_stock_data = mysql_fetch_array($gm_get_products_name); $gm_subject = GM_OUT_OF_STOCK_NOTIFY_TEXT . ' ' . $gm_stock_data['products_name']; $gm_body = GM_OUT_OF_STOCK_NOTIFY_TEXT . ': ' . (double) $stock_left . "\n\n" . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php?info=p' . xtc_get_prid($order->products[$i]['id']); /** * Send the email */ xtc_php_mail(STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, '', STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, '', '', $gm_subject, nl2br(htmlentities($gm_body)), $gm_body); } } } /** * Update products_ordered (for bestsellers list) */ xtc_db_query("update " . TABLE_PRODUCTS . " set products_ordered = products_ordered + " . (double) $order->products[$i]['qty'] . " where products_id = '" . 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' => xtc_get_tax_rate($order->products[$i]['tax_class_id'], $shipping_country['countries_id']), '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(); if (!empty($order->products[$i]['quantity_unit_id'])) { xtc_db_query("INSERT INTO orders_products_quantity_units\n SET orders_products_id = '" . (int) $order_products_id . "',\n quantity_unit_id = '" . (int) $order->products[$i]['quantity_unit_id'] . "',\n unit_name = '" . xtc_db_input($order->products[$i]['unit_name']) . "'"); } /** * Save selected properties_combi in product */ $t_combis_id = $coo_properties->extract_combis_id($order->products[$i]['id']); $GLOBALS['coo_debugger']->log('checkout_process: $order->products[$i][id] ' . $order->products[$i]['id'], 'Properties'); $GLOBALS['coo_debugger']->log('checkout_process: extract_combis_id ' . $t_combis_id, 'Properties'); if (empty($t_combis_id) == false) { $coo_properties->add_properties_combi_to_orders_product($t_combis_id, $order_products_id); /** * Update properties_combi quantity */ $t_quantity_change = $order->products[$i]['qty'] * -1; $val = $coo_properties->change_combis_quantity($t_combis_id, $t_quantity_change); } $specials_result = xtc_db_query("SELECT products_id, specials_quantity from " . TABLE_SPECIALS . " WHERE products_id = '" . 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 = '" . $new_sp_quantity . "' where products_id = '" . xtc_get_prid($order->products[$i]['id']) . "' "); } elseif (STOCK_CHECK == 'true') { xtc_db_query("update " . TABLE_SPECIALS . " set status = '0', specials_quantity = '" . $new_sp_quantity . "' where products_id = '" . xtc_get_prid($order->products[$i]['id']) . "' "); } } 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 poval.products_options_values_name,\n pa.options_values_price,\n pa.price_prefix,\n pad.products_attributes_maxdays,\n pad.products_attributes_maxcount,\n pad.products_attributes_filename\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n left join " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " pad\n on pa.products_attributes_id=pad.products_attributes_id\n where pa.products_id = '" . $order->products[$i]['id'] . "'\n and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n and pa.options_id = popt.products_options_id\n and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n and pa.options_values_id = poval.products_options_values_id\n and popt.language_id = '" . $_SESSION['languages_id'] . "'\n and poval.language_id = '" . $_SESSION['languages_id'] . "'"; $attributes = xtc_db_query($attributes_query); } else { $attributes = xtc_db_query("select popt.products_options_name,\n poval.products_options_values_name,\n pa.options_values_price,\n pa.price_prefix\n from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa\n where pa.products_id = '" . $order->products[$i]['id'] . "'\n and pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n and pa.options_id = popt.products_options_id\n and pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n and pa.options_values_id = poval.products_options_values_id\n and popt.language_id = '" . $_SESSION['languages_id'] . "'\n and poval.language_id = '" . $_SESSION['languages_id'] . "'"); } /** * update attribute stock */ xtc_db_query("UPDATE " . TABLE_PRODUCTS_ATTRIBUTES . " set\n attributes_stock=attributes_stock - '" . $order->products[$i]['qty'] . "'\n where\n products_id='" . $order->products[$i]['id'] . "'\n and options_values_id='" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n and options_id='" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n "); $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); } /** * BOF GM_MOD attributes stock_notifier */ $gm_get_attributes_stock = xtc_db_query("SELECT\n pd.products_name,\n pa.attributes_stock,\n po.products_options_name,\n pov.products_options_values_name\n FROM\n products_description pd,\n products_attributes pa,\n products_options po,\n products_options_values pov\n WHERE pa.products_id = '" . $order->products[$i]['id'] . "'\n AND pa.options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n AND pa.options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n AND po.products_options_id = '" . $order->products[$i]['attributes'][$j]['option_id'] . "'\n AND po.language_id = '" . $_SESSION['languages_id'] . "'\n AND pov.products_options_values_id = '" . $order->products[$i]['attributes'][$j]['value_id'] . "'\n AND pov.language_id = '" . $_SESSION['languages_id'] . "'\n AND pd.products_id = '" . $order->products[$i]['id'] . "'\n AND pd.language_id = '" . $_SESSION['languages_id'] . "'"); if (xtc_db_num_rows($gm_get_attributes_stock) == 1) { $gm_attributes_stock_data = xtc_db_fetch_array($gm_get_attributes_stock); if ($gm_attributes_stock_data['attributes_stock'] <= STOCK_REORDER_LEVEL) { $gm_subject = GM_OUT_OF_STOCK_NOTIFY_TEXT . ' ' . $gm_attributes_stock_data['products_name'] . ' - ' . $gm_attributes_stock_data['products_options_name'] . ': ' . $gm_attributes_stock_data['products_options_values_name']; $gm_body = GM_OUT_OF_STOCK_NOTIFY_TEXT . ': ' . (double) $gm_attributes_stock_data['attributes_stock'] . ' (' . $gm_attributes_stock_data['products_name'] . ' - ' . $gm_attributes_stock_data['products_options_name'] . ': ' . $gm_attributes_stock_data['products_options_values_name'] . ")\n\n" . HTTP_SERVER . DIR_WS_CATALOG . 'product_info.php?info=p' . xtc_get_prid($order->products[$i]['id']); xtc_php_mail(STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, '', STORE_OWNER_EMAIL_ADDRESS, STORE_NAME, '', '', $gm_subject, nl2br(htmlentities($gm_body)), $gm_body); } } } } $total_weight += $order->products[$i]['qty'] * $order->products[$i]['weight']; $total_cost += $total_products_price; } if (isset($_SESSION['tracking']['refID'])) { xtc_db_query("update " . TABLE_ORDERS . " set\n refferers_id = '" . $_SESSION['tracking']['refID'] . "'\n where orders_id = '" . $insert_id . "'"); /** * Check if late or direct sale */ $customers_logon_query = "SELECT customers_info_number_of_logons\n FROM " . TABLE_CUSTOMERS_INFO . "\n WHERE customers_info_id = '" . $_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 conversion_type = '1'\n where orders_id = '" . $insert_id . "'"); } else { /** * late sale */ xtc_db_query("update " . TABLE_ORDERS . " set\n conversion_type = '2'\n where orders_id = '" . $insert_id . "'"); } } else { $customers_query = xtc_db_query("SELECT refferers_id as ref FROM " . TABLE_CUSTOMERS . " WHERE customers_id='" . $_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 refferers_id = '" . $customers_data['ref'] . "'\n where orders_id = '" . $insert_id . "'"); /** * check if late or direct sale */ $customers_logon_query = "SELECT customers_info_number_of_logons\n FROM " . TABLE_CUSTOMERS_INFO . "\n WHERE customers_info_id = '" . $_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 conversion_type = '1'\n where orders_id = '" . $insert_id . "'"); } else { /** * Late sale */ xtc_db_query("update " . TABLE_ORDERS . " set\n conversion_type = '2'\n where orders_id = '" . $insert_id . "'"); } } } $_SESSION['cart']->reset(true); /** * Unregister session variables used during checkout */ unset($_SESSION['sendto']); unset($_SESSION['billto']); unset($_SESSION['shipping']); unset($_SESSION['payment']); unset($_SESSION['comments']); unset($_SESSION['last_order']); unset($_SESSION['tmp_oID']); unset($_SESSION['cc']); unset($_SESSION['nvpReqArray']); unset($_SESSION['reshash']); $last_order = $insert_id; if (isset($_SESSION['credit_covers'])) { unset($_SESSION['credit_covers']); } } catch (Exception $e) { throw $e; } return true; }
function get_product_price($product_id) { //wird nur bei Einschr�nkung Produkte/Kategorie benutzt global $order, $xtPrice; $products_id = xtc_get_prid($product_id); // products price //BOF - 2010-01-19 - Dokuman - ot_coupon Bugfixes //$qty = $_SESSION['cart']->contents[$products_id]['qty']; $qty = $_SESSION['cart']->contents[$product_id]['qty']; //EOF - 2010-01-19 - Dokuman - ot_coupon Bugfixes $total_price = 0; $product_query = xtc_db_query("select products_id, products_model, products_price, products_tax_class_id, products_weight from " . TABLE_PRODUCTS . " where products_id='" . $products_id . "'"); if ($product = xtc_db_fetch_array($product_query)) { $prid = $product['products_id']; if ($this->include_tax == 'true') { $total_price += $qty * $xtPrice->xtcGetPrice($product['products_id'], $format = false, 1, $product['products_tax_class_id'], $product['products_price'], 1); $_SESSION['total_price'] = $total_price; } else { $total_price += $qty * $xtPrice->xtcGetPrice($product['products_id'], $format = false, 1, 0, $product['products_price'], 1); } // attributes price // BOF - 2011-03-16 - web28 - use xtPrice function $attribute_price = 0; 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'])) { $values = $xtPrice->xtcGetOptionPrice($product['products_id'], $option, $value); $attribute_price += $qty * $values['price']; } } $total_price += $attribute_price; // EOF - 2011-03-16 - web28 - use xtPrice function } //if ($this->include_shipping == 'true') { //$total_price += $order->info['shipping_cost']; //} return $total_price; }
(c) 2003 nextcommerce (print_product_info.php,v 1.16 2003/08/25); www.nextcommerce.org (c) 2006 XT-Commerce Released under the GNU General Public License ---------------------------------------------------------------------------------------*/ include 'includes/application_top.php'; // include needed functions require_once DIR_FS_INC . 'xtc_date_long.inc.php'; require_once DIR_FS_INC . 'xtc_date_short.inc.php'; require_once DIR_FS_INC . 'xtc_get_products_mo_images.inc.php'; // create smarty elements $info_smarty = new Smarty(); $info_smarty->assign('tpl_path', 'templates/' . CURRENT_TEMPLATE . '/'); $info_smarty->assign('charset', $_SESSION['language_charset']); if (isset($_GET['pID']) && $_GET['pID'] != '') { $_GET['products_id'] = xtc_get_prid($_GET['pID']); $info_smarty->assign('noprint', true); } if (isset($_GET['products_id']) && $_GET['products_id'] != '') { $product = new product((int) $_GET['products_id']); } if (!is_object($product) || !$product->isProduct()) { // product not found in database $error = TEXT_PRODUCT_NOT_FOUND; include DIR_WS_MODULES . FILENAME_ERROR_HANDLER; } else { // defaults $hide_qty = 0; $module_content = ''; // Get manufacturer name etc. for the product page $manufacturer_query = xtc_db_query("SELECT m.manufacturers_id,\n m.manufacturers_name,\n m.manufacturers_image,\n mi.manufacturers_url\n FROM " . TABLE_MANUFACTURERS . " m\n LEFT JOIN " . TABLE_MANUFACTURERS_INFO . " mi\n ON (m.manufacturers_id = mi.manufacturers_id\n AND mi.languages_id = '" . (int) $_SESSION['languages_id'] . "'),\n " . TABLE_PRODUCTS . " p\n WHERE p.products_id = '" . $product->data['products_id'] . "'\n AND p.manufacturers_id = m.manufacturers_id");
/** * Confirm of the order and requesting RatePAY Confirm and handles the Response and saving all necessary Data to DB * */ function after_process() { unset($_SESSION['pi']['company']); unset($_SESSION['pi']['vatid']); global $HTTP_POST_VARS, $order, $xtPrice, $insert_id; global $language; include_once DIR_WS_CLASSES . 'pi_order.php'; $neworder = new pi_order($insert_id); $return = $this->paymentConfirm($insert_id); $request = $return[0]; $response = $return[1]; $orderId = $insert_id; $first_name = $this->removeSpecialChars(utf8_encode($order->delivery['firstname'])); $last_name = $this->removeSpecialChars(utf8_encode($order->delivery['lastname'])); if ($response) { $transactionId = $this->transId; $transactionShortId = $this->transShortId; $this->piRatepayLog($orderId, $transactionId, 'PAYMENT_CONFIRM', 'n/a', $request, $response, $first_name, $last_name); if ((string) $response->head->processing->status->attributes()->code == "OK" && (string) $response->head->processing->result->attributes()->code == "400") { $id = $insert_id; $sql = "INSERT INTO pi_ratepay_rate_orders (order_number, transaction_id, transaction_short_id, descriptor)\r\n\t\t\t\t\t\t\t\tVALUES ('" . xtc_db_input($id) . "', '" . xtc_db_input($transactionId) . "', '" . xtc_db_input($transactionShortId) . "','" . xtc_db_input($this->descriptor) . "')"; xtc_db_query($sql); for ($i = 0; $i <= sizeof($neworder->products); $i++) { $attributes = ""; if (isset($neworder->products[$i]['attributes'])) { foreach ($neworder->products[$i]['attributes'] as $attr) { $attributes = $attributes . ", " . $attr['option'] . ": " . $attr['value']; } } $name = strip_tags($neworder->products[$i]['name'] . $attributes); $price = round($neworder->products[$i]['price'], $xtPrice->get_decimal_places($currency)); $qty = intval($neworder->products[$i]['qty']); if ($price > 0) { $sql = "INSERT INTO pi_ratepay_rate_orderdetails (order_number,article_number, real_article_number, article_name,ordered,article_netUnitPrice)\r\n\t\t\t\t\t\t\t\t\t\tVALUES ('" . xtc_db_input($id) . "', '" . xtc_db_input($neworder->products[$i]['opid']) . "', '" . xtc_db_input(xtc_get_prid($neworder->products[$i]['id'])) . "','" . xtc_db_input($name) . "', " . xtc_db_input($qty) . ", " . number_format($price, 2) . ")"; xtc_db_query($sql); } } if (isset($_SESSION['pi_ratepay']['shipping'])) { $shippingCost = $_SESSION['pi_ratepay']['shipping']; $sql = "INSERT INTO pi_ratepay_rate_orderdetails (order_number,article_number,real_article_number,article_name,ordered,article_netUnitPrice)\r\n\t\t\t\t\t\t\t\t\tVALUES ('" . xtc_db_input($id) . "', 'SHIPPING', 'SHIPPING', 'Versand', 1, " . number_format($shippingCost, 2, ".", "") . ")"; xtc_db_query($sql); unset($_SESSION['pi_ratepay']['shipping']); } if (isset($_SESSION['pi_ratepay']['discount'])) { $discount_price = $_SESSION['pi_ratepay']['discount'] * -1; $sql = "INSERT INTO pi_ratepay_rate_orderdetails (order_number,article_number, real_article_number, article_name,ordered,article_netUnitPrice)\r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . xtc_db_input($id) . "', 'DISCOUNT', 'DISCOUNT', 'Rabatt', 1, " . number_format($discount_price, 2) . ")"; xtc_db_query($sql); unset($_SESSION['pi_ratepay']['discount']); } if (empty($_SESSION['pi']['coupon']) == false) { foreach ($_SESSION['pi']['coupon'] as $value) { $sql = "INSERT INTO pi_ratepay_rate_orderdetails (order_number,article_number, real_article_number, article_name,ordered,article_netUnitPrice)\r\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . xtc_db_input($id) . "', 'COUPON', 'COUPON', '" . $value['title'] . "', 1, " . number_format($value['value'] * -1, 2) . ")"; xtc_db_query($sql); } } $total_amount = $_SESSION['pi_ratepay_rate_total_amount']; $amount = $_SESSION['pi_ratepay_rate_amount']; $interest_amount = $_SESSION['pi_ratepay_rate_interest_amount']; $service_charge = $_SESSION['pi_ratepay_rate_service_charge']; $annual_percentage_rate = $_SESSION['pi_ratepay_rate_annual_percentage_rate']; $monthly_debit_interest = $_SESSION['pi_ratepay_rate_monthly_debit_interest']; $number_of_rates = $_SESSION['pi_ratepay_rate_number_of_rates']; $rate = $_SESSION['pi_ratepay_rate_rate']; $last_rate = $_SESSION['pi_ratepay_rate_last_rate']; xtc_db_query("DELETE FROM `pi_ratepay_rate_details` where orderid = '" . xtc_db_input($id) . "'"); xtc_db_query("INSERT INTO `pi_ratepay_rate_details` (`orderid`,`totalamount`, `amount`, `interestamount`, `servicecharge`, `annualpercentagerate`, `monthlydebitinterest`, `numberofrates`, `rate`, `lastrate`) VALUES ('" . xtc_db_input($id) . "','" . xtc_db_input($total_amount) . "', '" . xtc_db_input($amount) . "', '" . xtc_db_input($interest_amount) . "', '" . xtc_db_input($service_charge) . "', '" . xtc_db_input($annual_percentage_rate) . "', '" . xtc_db_input($monthly_debit_interest) . "', '" . xtc_db_input($number_of_rates) . "','" . xtc_db_input($rate) . "', '" . xtc_db_input($last_rate) . "')"); } else { $_SESSION['disable'] = true; $_SESSION['pi']['error'] = PI_RATEPAY_RATE_ERROR; xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')); } } else { $_SESSION['disable'] = true; $_SESSION['pi']['error'] = PI_RATEPAY_RATE_ERROR; xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')); $this->piRatepayLog($orderId, $transactionId, 'PAYMENT_CONFIRM', 'n/a', $request, false, $first_name, $last_name); } if ($this->order_status) { xtc_db_query("UPDATE " . TABLE_ORDERS . " SET orders_status='" . xtc_db_input($this->order_status) . "' WHERE orders_id='" . xtc_db_input($insert_id) . "'"); } }
function get_products() { if (!is_array($this->contents)) { return 0; } $products_array = array(); reset($this->contents); while (list($products_id, ) = each($this->contents)) { $products_query = xtc_db_query("select p.products_id, pd.products_name, p.products_model, p.products_price, p.products_weight, p.products_tax_class_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id='" . xtc_get_prid($products_id) . "' and pd.products_id = p.products_id and pd.language_id = '" . $_SESSION['languages_id'] . "'"); if ($products = xtc_db_fetch_array($products_query)) { $prid = $products['products_id']; $products_price = $products['products_price']; $specials_query = xtc_db_query("select specials_new_products_price from " . TABLE_SPECIALS . " where products_id = '" . $prid . "' and status = '1'"); if (xtc_db_num_rows($specials_query)) { $specials = xtc_db_fetch_array($specials_query); $products_price = $specials['specials_new_products_price']; } $products_array[] = array('id' => $products_id, 'name' => $products['products_name'], 'model' => $products['products_model'], 'price' => $products_price, 'quantity' => $this->contents[$products_id]['qty'], 'weight' => $products['products_weight'], 'final_price' => $products_price + $this->attributes_price($products_id), 'tax_class_id' => $products['products_tax_class_id'], 'attributes' => $this->contents[$products_id]['attributes']); } } return $products_array; }
function get_html($p_products_array) { $coo_properties_control = MainFactory::create_object('PropertiesControl'); $coo_properties_view = MainFactory::create_object('PropertiesView'); $t_content_array = array(); $module_content = array(); $any_out_of_stock = ''; $mark_stock = ''; $coo_seo_boost = MainFactory::create_object('GMSEOBoost'); $coo_main = new main(); $xtPrice = new xtcPrice($_SESSION['currency'], $_SESSION['customers_status']['customers_status_id']); for ($i = 0, $n = sizeof($p_products_array); $i < $n; $i++) { $t_combis_id = $coo_properties_control->extract_combis_id($p_products_array[$i]['id']); // check if combis_id is empty if ($t_combis_id == '') { // combis_id is empty = article without properties if (STOCK_CHECK == 'true') { $mark_stock = xtc_check_stock($p_products_array[$i]['id'], $p_products_array[$i]['quantity']); if ($mark_stock) { $_SESSION['any_out_of_stock'] = 1; } } } $image = ''; if ($p_products_array[$i]['image'] != '') { $image = DIR_WS_THUMBNAIL_IMAGES . $p_products_array[$i]['image']; } //bof gm $gm_products_id = $p_products_array[$i]['id']; $gm_products_id = str_replace('{', '_', $gm_products_id); $gm_products_id = str_replace('}', '_', $gm_products_id); $gm_query = xtc_db_query("SELECT gm_show_weight FROM products WHERE products_id='" . $p_products_array[$i]['id'] . "'"); $gm_array = xtc_db_fetch_array($gm_query); if (empty($gm_array['gm_show_weight'])) { $p_products_array[$i]['gm_weight'] = 0; } $gm_product_link = xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($p_products_array[$i]['id'], $p_products_array[$i]['name']) . '&no_boost=1'); include DIR_FS_CATALOG . 'gm/modules/gm_gprint_order_details_cart.php'; $t_shipping_time = $p_products_array[$i]['shipping_time']; $t_products_weight = $p_products_array[$i]['gm_weight']; $t_products_model = $p_products_array[$i]['model']; #properties if ($t_combis_id != '') { $t_properties_html = $coo_properties_view->get_order_details_by_combis_id($t_combis_id, 'cart'); $coo_products = MainFactory::create_object('GMDataObject', array('products', array('products_id' => $p_products_array[$i]['id']))); $use_properties_combis_quantity = $coo_products->get_data_value('use_properties_combis_quantity'); if ($use_properties_combis_quantity == 1) { // check article quantity $mark_stock = xtc_check_stock($p_products_array[$i]['id'], $p_products_array[$i]['quantity']); if ($mark_stock) { $_SESSION['any_out_of_stock'] = 1; } } else { if ($use_properties_combis_quantity == 0 && ATTRIBUTE_STOCK_CHECK == 'true' && STOCK_CHECK == 'true' || $use_properties_combis_quantity == 2) { // check combis quantity $t_properties_stock = $coo_properties_control->get_properties_combis_quantity($t_combis_id); if ($t_properties_stock < $p_products_array[$i]['quantity']) { $_SESSION['any_out_of_stock'] = 1; $mark_stock = '<span class="markProductOutOfStock">' . STOCK_MARK_PRODUCT_OUT_OF_STOCK . '</span>'; } } } $t_weight = $coo_properties_control->get_properties_combis_weight($t_combis_id); if ($coo_products->get_data_value('use_properties_combis_weight') == 1) { $t_products_weight = gm_prepare_number($t_weight, $xtPrice->currencies[$xtPrice->actualCurr]['decimal_point']); } else { $t_products_weight = gm_prepare_number($t_weight + $p_products_array[$i]['weight'], $xtPrice->currencies[$xtPrice->actualCurr]['decimal_point']); } if ($coo_products->get_data_value('use_properties_combis_shipping_time') == 1) { $t_shipping_time = $coo_properties_control->get_properties_combis_shipping_time($t_combis_id); } $t_combi_model = $coo_properties_control->get_properties_combis_model($t_combis_id); if (APPEND_PROPERTIES_MODEL == "true") { // Artikelnummer (Kombi) an Artikelnummer (Artikel) anhängen if ($t_products_model != '' && $t_combi_model != '') { $t_products_model = $t_products_model . '-' . $t_combi_model; } else { if ($t_combi_model != '') { $t_products_model = $t_combi_model; } } } else { // Artikelnummer (Artikel) durch Artikelnummer (Kombi) ersetzen if ($t_combi_model != '') { $t_products_model = $t_combi_model; } } } else { $t_properties_html = ''; } $module_content[$i] = array('PRODUCTS_NAME' => $p_products_array[$i]['name'] . $mark_stock, 'PRODUCTS_QTY' => xtc_draw_input_field('cart_quantity[]', gm_convert_qty($p_products_array[$i]['quantity'], false), ' size="2" onblur="gm_qty_is_changed(' . $p_products_array[$i]['quantity'] . ', this.value, \'' . GM_QTY_CHANGED_MESSAGE . '\')"', 'text', true, "gm_cart_data gm_class_input") . xtc_draw_hidden_field('products_id[]', $p_products_array[$i]['id'], 'class="gm_cart_data"') . xtc_draw_hidden_field('old_qty[]', $p_products_array[$i]['quantity']), 'PRODUCTS_OLDQTY_INPUT_NAME' => 'old_qty[]', 'PRODUCTS_QTY_INPUT_NAME' => 'cart_quantity[]', 'PRODUCTS_QTY_VALUE' => gm_convert_qty($p_products_array[$i]['quantity'], false), 'PRODUCTS_ID_INPUT_NAME' => 'products_id[]', 'PRODUCTS_ID_EXTENDED' => $p_products_array[$i]['id'], 'PRODUCTS_MODEL' => $t_products_model, 'SHOW_PRODUCTS_MODEL' => SHOW_PRODUCTS_MODEL, 'PRODUCTS_SHIPPING_TIME' => $t_shipping_time, 'PRODUCTS_TAX' => (double) $p_products_array[$i]['tax'], 'PRODUCTS_IMAGE' => $image, 'IMAGE_ALT' => $p_products_array[$i]['name'], 'BOX_DELETE' => xtc_draw_checkbox_field('cart_delete[]', $p_products_array[$i]['id'], false, 'id="gm_delete_product_' . $gm_products_id . '"'), 'PRODUCTS_LINK' => $gm_product_link, 'PRODUCTS_PRICE' => $xtPrice->xtcFormat($p_products_array[$i]['price'] * $p_products_array[$i]['quantity'], true), 'PRODUCTS_SINGLE_PRICE' => $xtPrice->xtcFormat($p_products_array[$i]['price'], true), 'PRODUCTS_SHORT_DESCRIPTION' => xtc_get_short_description($p_products_array[$i]['id']), 'ATTRIBUTES' => '', 'PROPERTIES' => $t_properties_html, 'GM_WEIGHT' => $t_products_weight, 'PRODUCTS_ID' => $gm_products_id, 'UNIT' => $p_products_array[$i]['unit_name']); //eof gm // Product options names $attributes_exist = isset($p_products_array[$i]['attributes']) ? 1 : 0; if ($attributes_exist == 1) { reset($p_products_array[$i]['attributes']); while (list($option, $value) = each($p_products_array[$i]['attributes'])) { if (ATTRIBUTE_STOCK_CHECK == 'true' && STOCK_CHECK == 'true' && $value != 0) { $attribute_stock_check = xtc_check_stock_attributes($p_products_array[$i][$option]['products_attributes_id'], $p_products_array[$i]['quantity']); if ($attribute_stock_check) { $_SESSION['any_out_of_stock'] = 1; } } $module_content[$i]['ATTRIBUTES'][] = array('ID' => $p_products_array[$i][$option]['products_attributes_id'], 'MODEL' => xtc_get_attributes_model(xtc_get_prid($p_products_array[$i]['id']), $p_products_array[$i][$option]['products_options_values_name'], $p_products_array[$i][$option]['products_options_name']), 'NAME' => $p_products_array[$i][$option]['products_options_name'], 'VALUE_NAME' => $p_products_array[$i][$option]['products_options_values_name'] . $attribute_stock_check); // BOF GM_MOD GX-Customizer: require DIR_FS_CATALOG . 'gm/modules/gm_gprint_order_details_cart_2.php'; } } } $total_content = ''; $total = $_SESSION['cart']->show_total(); if ($_SESSION['customers_status']['customers_status_ot_discount_flag'] == '1' && $_SESSION['customers_status']['customers_status_ot_discount'] != '0.00') { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $price = $total - $_SESSION['cart']->show_tax(false); } else { $price = $total; } // BOF GM_MOD $discount = round($xtPrice->xtcGetDC($price, $_SESSION['customers_status']['customers_status_ot_discount']), 2); $total_content = $_SESSION['customers_status']['customers_status_ot_discount'] . ' % ' . SUB_TITLE_OT_DISCOUNT . ' -' . xtc_format_price($discount, $price_special = 1, $calculate_currencies = false) . '<br />'; $this->set_content_data('DISCOUNT_TEXT', round((double) $_SESSION['customers_status']['customers_status_ot_discount'], 2) . '% ' . SUB_TITLE_OT_DISCOUNT); $this->set_content_data('DISCOUNT_VALUE', '-' . xtc_format_price($discount, $price_special = 1, $calculate_currencies = false)); } if ($_SESSION['customers_status']['customers_status_show_price'] == '1') { if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 0) { $total -= $discount; } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 0 && $_SESSION['customers_status']['customers_status_add_tax_ot'] == 1) { $total -= $discount; } if ($_SESSION['customers_status']['customers_status_show_price_tax'] == 1) { $total -= $discount; } $total_content .= SUB_TITLE_SUB_TOTAL . $xtPrice->xtcFormat($total, true) . '<br />'; $t_total = $xtPrice->xtcFormat($total + $discount, true); } else { $total_content .= NOT_ALLOWED_TO_SEE_PRICES . '<br />'; } // display only if there is an ot_discount if ($customer_status_value['customers_status_ot_discount'] != 0) { $total_content .= TEXT_CART_OT_DISCOUNT . $customer_status_value['customers_status_ot_discount'] . '%'; } if (SHOW_SHIPPING == 'true') { $this->set_content_data('SHIPPING_INFO', ' ' . SHIPPING_EXCL . '<a href="' . $coo_main->gm_get_shipping_link(true) . '" target="_blank" class="lightbox_iframe"> ' . SHIPPING_COSTS . '</a>'); } if ($_SESSION['customers_status']['customers_status_show_price'] == '1') { $gm_cart_tax_info = ''; if (gm_get_conf('TAX_INFO_TAX_FREE') == 'true') { $gm_cart_tax_info = GM_TAX_FREE . '<br />'; $this->set_content_data('TAX_FREE_TEXT', GM_TAX_FREE); } else { $gm_cart_tax_info = $_SESSION['cart']->show_tax(); if (!empty($gm_cart_tax_info) && $_SESSION['customers_status']['customers_status_show_price_tax'] == '0' && $_SESSION['customers_status']['customers_status_add_tax_ot'] == '1') { if (!defined(MODULE_ORDER_TOTAL_SUBTOTAL_TITLE_NO_TAX)) { include_once DIR_FS_CATALOG . 'lang/' . $_SESSION['language'] . '/modules/order_total/ot_subtotal.php'; } $t_gm_tax = 0; foreach ($_SESSION['cart']->tax as $t_gm_key => $t_gm_value) { $t_gm_tax += $t_gm_value['value']; } $gm_cart_tax_info = MODULE_ORDER_TOTAL_SUBTOTAL_TITLE_NO_TAX . ': ' . $xtPrice->xtcFormat((double) $total - (double) $t_gm_tax, true) . '<br />' . $gm_cart_tax_info; $t_total = $xtPrice->xtcFormat((double) $total - (double) $t_gm_tax + $discount, true); } } $this->set_content_data('UST_CONTENT', $gm_cart_tax_info, 1); } $t_taxes_data_array = explode('<br />', $_SESSION['cart']->show_tax(true)); $t_tax_array = array(); for ($i = 0; $i < count($t_taxes_data_array); $i++) { if (!empty($t_taxes_data_array[$i])) { $t_tax_data_array = explode(':', $t_taxes_data_array[$i]); $t_tax_array[] = array('TEXT' => $t_tax_data_array[0], 'VALUE' => $t_tax_data_array[1]); } } $this->set_content_data('tax_data', $t_tax_array); $this->set_content_data('SUBTOTAL', $t_total); $this->set_content_data('TOTAL', $xtPrice->xtcFormat($total, true)); $this->set_content_data('TOTAL_CONTENT', $total_content, 1); $this->set_content_data('language', $_SESSION['language']); $this->set_content_data('module_content', $module_content); $coo_gift_cart = MainFactory::create_object('GiftCartContentView'); $t_view_html = $coo_gift_cart->get_html(); $this->set_content_data('MODULE_gift_cart', $t_view_html); // Bitcoin Payment - Commerce Coding - BEGIN $multiplier = 1; $digits = 8; switch (MODULE_PAYMENT_BITCOIN_UNITS) { case 'uBTC': $multiplier *= 1000; $digits -= 3; case 'mBTC': $multiplier *= 1000; $digits -= 3; case 'BTC': $btcPrice = number_format($total / MODULE_PAYMENT_BITCOIN_BTCEUR * $multiplier, $digits, '.', ''); $this->set_content_data('BITCOIN_PRICE', $btcPrice . ' ' . MODULE_PAYMENT_BITCOIN_UNITS); } // Bitcoin Payment - Commerce Coding - END $t_html_output = $this->build_html(); return $t_html_output; }
/** * 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; }
/** * get total number of items in cart disregard gift vouchers * * amend count_contents to show nil contents for shipping * as we don't want to quote for 'virtual' item * GLOBAL CONSTANTS if NO_COUNT_ZERO_WEIGHT is true then we don't count any product with a weight * which is less than or equal to MINIMUM_WEIGHT * otherwise we just don't count gift certificates * * @return integer */ function count_contents_virtual() { $total_items = 0; if (is_array($this->contents)) { reset($this->contents); while (list($products_id, ) = each($this->contents)) { $no_count = false; $gv_query = xtc_db_query("select products_model from " . TABLE_PRODUCTS . " where products_id = '" . $products_id . "'"); $gv_result = xtc_db_fetch_array($gv_query); if (preg_match('/^GIFT/', $gv_result['products_model'])) { // Hetfield - 2009-08-19 - replaced deprecated function ereg with preg_match to be ready for PHP >= 5.3 $no_count = true; } //BOF - DokuMan - 2010-03-26 - check for defined variable if (defined('NO_COUNT_ZERO_WEIGHT') && NO_COUNT_ZERO_WEIGHT == 1) { //if (NO_COUNT_ZERO_WEIGHT == 1) { //EOF - DokuMan - 2010-03-26 - check for defined variable $gv_query = xtc_db_query("select products_weight from " . TABLE_PRODUCTS . " where products_id = '" . xtc_get_prid($products_id) . "'"); $gv_result = xtc_db_fetch_array($gv_query); if ($gv_result['products_weight'] <= MINIMUM_WEIGHT) { $no_count = true; } } if (!$no_count) { $total_items += $this->get_quantity($products_id); } } } return $total_items; }