function oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, $CALC_TAX = TRUE) { $clearPrice = oaGetClearPrice($cartContent); $d = oaGetDiscountPercent($cartContent, $log); $res = $clearPrice - $clearPrice / 100 * $d; if ($CALC_TAX) { $res += oaGetProductTax($cartContent, $d, $addresses); } return $res; }
function _getOrder() { if (!isset($_SESSION["first_name"]) || !isset($_SESSION["last_name"]) || !isset($_SESSION["email"])) { return NULL; } $order["first_name"] = $_SESSION["first_name"]; $order["last_name"] = $_SESSION["last_name"]; $order["email"] = $_SESSION["email"]; $res = cartGetCartContent(); $order["orderContent"] = $res["cart_content"]; $d = oaGetDiscountPercent($res, ""); $order["order_amount"] = $res["total_price"] - $res["total_price"] / 100 * $d; return $order; }
function _getOrder() { $cust_password = ""; $Email = ""; $first_name = ""; $last_name = ""; $subscribed4news = ""; $additional_field_values = ""; $countryID = ""; $zoneID = ""; $state = ""; $city = ""; $address = ""; regGetCustomerInfo($_SESSION["log"], $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values, $countryID, $zoneID, $state, $city, $address); $order["first_name"] = $first_name; $order["last_name"] = $last_name; $order["email"] = $Email; $res = cartGetCartContent(); $order["orderContent"] = $res["cart_content"]; $d = oaGetDiscountPercent($res, $_SESSION["log"]); $order["order_amount"] = $res["total_price"] - $res["total_price"] / 100 * $d; return $order; }
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); }
function cartCheckMinTotalOrderAmount() { $res = cartGetCartContent(); $d = oaGetDiscountPercent($res, ''); $order['order_amount'] = $res['total_price'] - $res['total_price'] / 100 * $d; if ($order['order_amount'] < CONF_MINIMAL_ORDER_AMOUNT) { return false; } else { return true; } }