xos_redirect(xos_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL')); } } include DIR_FS_SMARTY . 'catalog/languages/' . $_SESSION['language'] . '/' . FILENAME_CHECKOUT_PROCESS; // load selected payment module require DIR_WS_CLASSES . 'payment.php'; $payment_modules = new payment($_SESSION['payment']); // load the selected shipping module require DIR_WS_CLASSES . 'shipping.php'; $shipping_modules = new shipping($_SESSION['shipping']); require DIR_WS_CLASSES . 'order.php'; $order = new order(); // Stock Check if (STOCK_CHECK == 'true' && STOCK_ALLOW_CHECKOUT != 'true' && !isset($_GET['return_from'])) { for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { if (xos_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) { xos_redirect(xos_href_link(FILENAME_SHOPPING_CART), false); break; } } } $payment_modules->update_status(); if ($payment_modules->selected_module != $_SESSION['payment'] || is_array($payment_modules->modules) && sizeof($payment_modules->modules) > 1 && !is_object(${$_SESSION['payment']}) || is_object(${$_SESSION['payment']}) && ${$_SESSION['payment']}->enabled == false) { xos_redirect(xos_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . urlencode(ERROR_NO_PAYMENT_MODULE_SELECTED), 'SSL')); } require DIR_WS_CLASSES . 'order_total.php'; $order_total_modules = new order_total(); $order_totals = $order_total_modules->process(); // load the before_process function from the payment modules $payment_modules->before_process(); $sql_data_array = array('customers_id' => $_SESSION['customer_id'], 'customers_c_id' => $order->customer['c_id'], 'customers_name' => $order->customer['firstname'] . ' ' . $order->customer['lastname'], 'customers_company' => $order->customer['company'], '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' => trim($order->delivery['firstname'] . ' ' . $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_address_format_id' => $order->delivery['format_id'], 'billing_name' => $order->billing['firstname'] . ' ' . $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_address_format_id' => $order->billing['format_id'], 'payment_method' => $order->info['payment_method'], 'cc_type' => $order->info['cc_type'], 'cc_owner' => $order->info['cc_owner'], 'cc_expires' => $order->info['cc_expires'], 'date_purchased' => 'now()', 'orders_status' => $order->info['order_status'], 'language_id' => $_SESSION['languages_id'], 'language_directory' => $_SESSION['language'], 'currency' => $order->info['currency'], 'currency_value' => $order->info['currency_value']);
if (!isset($_SESSION['customer_id'])) { $_SESSION['navigation']->remove_current_page(); $_SESSION['navigation']->set_snapshot(); xos_redirect(xos_href_link(FILENAME_LOGIN, '', 'SSL')); } // restore cart contents $_SESSION['cart']->restore_contents(); // if there is nothing in the customers cart, redirect them to the shopping cart page if ($_SESSION['cart']->count_contents() < 1) { xos_redirect(xos_href_link(FILENAME_SHOPPING_CART), false); } // Stock Check if (STOCK_CHECK == 'true' && STOCK_ALLOW_CHECKOUT != 'true') { $products = $_SESSION['cart']->get_products(); for ($i = 0, $n = sizeof($products); $i < $n; $i++) { if (xos_check_stock($products[$i]['id'], $products[$i]['quantity'])) { xos_redirect(xos_href_link(FILENAME_SHOPPING_CART), false); break; } } } // if no shipping destination address was selected, use the customers own address as default if (!isset($_SESSION['sendto'])) { $_SESSION['sendto'] = $_SESSION['customer_default_address_id']; } else { // verify the selected shipping address if (is_array($_SESSION['sendto']) && empty($_SESSION['sendto']) || is_numeric($_SESSION['sendto'])) { $check_address_query = xos_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int) $_SESSION['customer_id'] . "' and address_book_id = '" . (int) $_SESSION['sendto'] . "'"); $check_address = xos_db_fetch_array($check_address_query); if ($check_address['total'] != '1') { $_SESSION['sendto'] = $_SESSION['customer_default_address_id'];