function getOrderSummarize($shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $shServiceID = 0) { // result this function $sumOrderContent = array(); $q = db_query('select email_comments_text from ' . PAYMENT_TYPES_TABLE . ' where PID=' . (int) $paymentMethodID); $payment_email_comments_text = db_fetch_row($q); $payment_email_comments_text = $payment_email_comments_text[0]; $q = db_query('select email_comments_text from ' . SHIPPING_METHODS_TABLE . ' where SID=' . (int) $shippingMethodID); $shipping_email_comments_text = db_fetch_row($q); $shipping_email_comments_text = $shipping_email_comments_text[0]; $cartContent = cartGetCartContent(); $pred_total = oaGetClearPrice($cartContent); if (isset($_SESSION['log'])) { $log = $_SESSION['log']; } else { $log = null; } $d = oaGetDiscountPercent($cartContent, $log); $discount = $pred_total / 100 * $d; // ordering with registration if ($shippingAddressID != 0 || isset($log)) { $addresses = array($shippingAddressID, $billingAddressID); $shipping_address = regGetAddressStr($shippingAddressID); $billing_address = regGetAddressStr($billingAddressID); $shaddr = regGetAddress($shippingAddressID); $sh_firstname = $shaddr['first_name']; $sh_lastname = $shaddr['last_name']; } else { if (!isset($_SESSION['receiver_countryID']) || !isset($_SESSION['receiver_zoneID'])) { return NULL; } $shippingAddress = array('countryID' => $_SESSION['receiver_countryID'], 'zoneID' => $_SESSION['receiver_zoneID']); $billingAddress = array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID']); $addresses = array($shippingAddress, $billingAddress); $shipping_address = quickOrderGetReceiverAddressStr(); $billing_address = quickOrderGetBillingAddressStr(); $sh_firstname = $_SESSION['receiver_first_name']; $sh_lastname = $_SESSION['receiver_last_name']; } foreach ($cartContent['cart_content'] as $key => $cartItem) { // if conventional ordering if ($shippingAddressID != 0) { $productID = GetProductIdByItemId($cartItem['id']); $cartItem['tax'] = taxCalculateTax($productID, $addresses[0], $addresses[1]); } else { $productID = $cartItem['id']; $cartItem['tax'] = taxCalculateTax2($productID, $addresses[0], $addresses[1]); } if (!empty($cartItem['opt_margin']) && $paymentMethodID == 2) { $cost = $cartItem['costUC']; $margin = $cost / 100 * CONF_PERCENT_MARGIN; $cost += $margin; $costShow = show_price($cost * $cartItem['quantity']); $pred_total += $margin * $cartItem['quantity']; $cartContent['cart_content'][$key]['costUC'] = $cost; $cartContent['cart_content'][$key]['cost'] = $costShow; $cartItem['costUC'] = $cost; $cartItem['cost'] = $costShow; } $sumOrderContent[] = $cartItem; } $shipping_method = shGetShippingMethodById($shippingMethodID); if (!$shipping_method) { $shipping_name = '-'; } else { $shipping_name = $shipping_method['Name']; } $payment_method = payGetPaymentMethodById($paymentMethodID); if (!$payment_method) { $payment_name = '-'; } else { $payment_name = $payment_method['Name']; } //do not calculate tax for this payment type! if (isset($payment_method['calculate_tax']) && (int) $payment_method['calculate_tax'] == 0) { foreach ($sumOrderContent as $key => $val) { $sumOrderContent[$key]['tax'] = 0; } $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE, $shServiceID)); $tax = 0; $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, FALSE, $shServiceID); $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, FALSE, $shServiceID); } else { $orderDetails = array('first_name' => $sh_firstname, 'last_name' => $sh_lastname, 'email' => '', 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE)); $tax = oaGetProductTax($cartContent, $d, $addresses); $total = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID); $shipping_cost = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, TRUE, $shServiceID); } $tServiceInfo = null; if (is_array($shipping_cost)) { $_T = array_shift($shipping_cost); $tServiceInfo = $_T['name']; $shipping_cost = $_T['rate']; } $payment_form_html = ''; $paymentModule = modGetModuleObj($payment_method['module_id'], PAYMENT_MODULE); if ($paymentModule) { $order = array(); $address = array(); if ($shippingAddressID != 0) { $payment_form_html = $paymentModule->payment_form_html(array('BillingAddressID' => $billingAddressID)); } else { $payment_form_html = $paymentModule->payment_form_html(array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID'], 'first_name' => $_SESSION['billing_first_name'], 'last_name' => $_SESSION['billing_last_name'], 'city' => $_SESSION['billing_city'], 'address' => $_SESSION['billing_address'])); } } return array('sumOrderContent' => $sumOrderContent, 'discount' => $discount, 'discount_percent' => $d, 'discount_show' => show_price($discount), 'pred_total_disc' => show_price($pred_total * ((100 - $d) / 100)), 'pred_total' => show_price($pred_total), 'totalTax' => show_price($tax), 'totalTaxUC' => $tax, 'shipping_address' => $shipping_address, 'billing_address' => $billing_address, 'shipping_name' => $shipping_name, 'payment_name' => $payment_name, 'shipping_cost' => show_price($shipping_cost), 'shipping_costUC' => $shipping_cost, 'payment_form_html' => $payment_form_html, 'total' => show_price($total), 'totalUC' => $total, 'payment_email_comments_text' => $payment_email_comments_text, 'shipping_email_comments_text' => $shipping_email_comments_text, 'orderContentCartProductsCount' => count($sumOrderContent), 'shippingServiceInfo' => $tServiceInfo); }
for (; $_t >= 0; $_t--) { if ($shipping_costs[$_i][$_t]['rate'] > 0) { $shipping_costs[$_i][$_t]['rate'] = show_price($shipping_costs[$_i][$_t]['rate']); } else { if (count($shipping_costs[$_i]) == 1 && $shipping_costs[$_i][$_t]['rate'] < 0) { $shipping_costs[$_i] = 'n/a'; } else { $shipping_costs[$_i][$_t]['rate'] = ''; } } } } return $shipping_costs; } $order = _getOrder(); $strAddress = quickOrderGetReceiverAddressStr(); $shipping_methods = shGetAllShippingMethods(true); if (isset($_POST["continue_button"])) { $_POST['shServiceID'] = isset($_POST['shServiceID'][$_POST['select_shipping_method']]) ? $_POST['shServiceID'][$_POST['select_shipping_method']] : 0; RedirectProtected("index.php?order3_billing_quick=yes&shippingMethodID=" . $_POST["select_shipping_method"] . "&shServiceID=" . $_POST['shServiceID']); } if (count($shipping_methods) == 0) { RedirectProtected("index.php?order3_billing_quick=yes&shippingMethodID=0"); } $shipping_costs = _getShippingCosts($shipping_methods, $order, $moduleFiles); $result_methods = array(); $result_costs = array(); foreach ($shipping_methods as $key => $shipping_method) { if ($shipping_costs[$key] != 'n/a') { $result_methods[] = $shipping_method; $result_costs[] = $shipping_costs[$key];