Пример #1
0
 function _setCallBackParamsToSearchOrders(&$callBackParam)
 {
     $callBackParam = array("customerID" => regGetIdByLogin($_SESSION["log"]));
     if (isset($_GET["sort"])) {
         $callBackParam["sort"] = xEscSQL($_GET["sort"]);
         if (isset($_GET["direction"])) {
             $callBackParam["direction"] = xEscSQL($_GET["direction"]);
         }
     } else {
         $callBackParam["sort"] = "order_time";
         $callBackParam["direction"] = "DESC";
     }
     if ($_GET["order_search_type"] == "SearchByOrderID") {
         $callBackParam["orderID"] = (int) $_GET["orderID_textbox"];
     } else {
         if ($_GET["order_search_type"] == "SearchByStatusID") {
             $orderStatuses = array();
             $data = ScanGetVariableWithId(array("checkbox_order_status"));
             foreach ($data as $key => $val) {
                 if ($val["checkbox_order_status"] == "1") {
                     $orderStatuses[] = (int) $key;
                 }
             }
             $callBackParam["orderStatuses"] = $orderStatuses;
         }
     }
 }
Пример #2
0
function stGetVisitsCount($log)
{
    $customerID = regGetIdByLogin($log);
    $q = db_query("select count(*) customer_logtime from " . CUSTOMER_LOG_TABLE . " where customerID=" . (int) $customerID);
    $row = db_fetch_row($q);
    return $row[0];
}
Пример #3
0
function ordOrderProcessing($shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $customers_comment, $cc_number, $cc_holdername, $cc_expires, $cc_cvv, $log, $smarty_mail, $shServiceID = 0)
{
    $customerID = $log != null ? regGetIdByLogin($log) : NULL;
    if ($log != null) {
        $customerInfo = regGetCustomerInfo2($log);
    } else {
        $customerInfo['first_name'] = $_SESSION['first_name'];
        $customerInfo['last_name'] = $_SESSION['last_name'];
        $customerInfo['Email'] = $_SESSION['email'];
        $customerInfo['affiliationLogin'] = $_SESSION['affiliationLogin'];
    }
    $order_time = get_current_time();
    $frandl = mt_rand(3, 999);
    $order_active_link = md5($order_time) . $frandl;
    $customer_ip = stGetCustomerIP_Address();
    $statusID = CONF_ACTIVE_ORDER == 1 ? 0 : ostGetNewOrderStatus();
    $customer_affiliationLogin = isset($customerInfo['affiliationLogin']) ? $customerInfo['affiliationLogin'] : '';
    $customer_email = $customerInfo['Email'];
    $currencyID = currGetCurrentCurrencyUnitID();
    if ($currencyID != 0) {
        $currentCurrency = currGetCurrencyByID($currencyID);
        $currency_code = $currentCurrency['currency_iso_3'];
        $currency_value = $currentCurrency['currency_value'];
        $currency_round = $currentCurrency['roundval'];
    } else {
        $currency_code = '';
        $currency_value = 1;
        $currency_round = 2;
    }
    // get shipping address
    if ($shippingAddressID != 0) {
        $shippingAddress = regGetAddress($shippingAddressID);
        $shippingAddressCountry = cnGetCountryById($shippingAddress['countryID']);
        $shippingAddress['country_name'] = $shippingAddressCountry['country_name'];
    } else {
        $shippingCountryName = cnGetCountryById($_SESSION['receiver_countryID']);
        $shippingCountryName = $shippingCountryName['country_name'];
        $shippingAddress['first_name'] = $_SESSION['receiver_first_name'];
        $shippingAddress['last_name'] = $_SESSION['receiver_last_name'];
        $shippingAddress['country_name'] = $shippingCountryName;
        $shippingAddress['state'] = $_SESSION['receiver_state'];
        $shippingAddress['city'] = $_SESSION['receiver_city'];
        $shippingAddress['address'] = $_SESSION['receiver_address'];
        $shippingAddress['zoneID'] = $_SESSION['receiver_zoneID'];
    }
    if (is_null($shippingAddress['state']) || trim($shippingAddress['state']) == '') {
        $zone = znGetSingleZoneById($shippingAddress['zoneID']);
        $shippingAddress['state'] = $zone['zone_name'];
    }
    // get billing address
    if ($billingAddressID != 0) {
        $billingAddress = regGetAddress($billingAddressID);
        $billingAddressCountry = cnGetCountryById($billingAddress['countryID']);
        $billingAddress['country_name'] = $billingAddressCountry['country_name'];
    } else {
        $billingCountryName = cnGetCountryById($_SESSION['billing_countryID']);
        $billingCountryName = $billingCountryName['country_name'];
        $billingAddress['first_name'] = $_SESSION['billing_first_name'];
        $billingAddress['last_name'] = $_SESSION['billing_last_name'];
        $billingAddress['country_name'] = $billingCountryName;
        $billingAddress['state'] = $_SESSION['billing_state'];
        $billingAddress['city'] = $_SESSION['billing_city'];
        $billingAddress['address'] = $_SESSION['billing_address'];
        $billingAddress['zoneID'] = $_SESSION['billing_zoneID'];
    }
    if (is_null($billingAddress['state']) || trim($billingAddress['state']) == '') {
        $zone = znGetSingleZoneById($billingAddress['zoneID']);
        $billingAddress['state'] = $zone['zone_name'];
    }
    $cartContent = cartGetCartContent();
    foreach ($cartContent['cart_content'] as $key => $cartItem) {
        if (!empty($cartItem['opt_margin']) && $paymentMethodID == 2) {
            $cost = $cartItem['costUC'];
            $margin = $cost / 100 * CONF_PERCENT_MARGIN;
            $cost += $margin;
            $costShow = show_price($cost * $cartItem['quantity']);
            $cartContent['cart_content'][$key]['costUC'] = $cost;
            $cartContent['cart_content'][$key]['cost'] = $costShow;
        }
    }
    if ($log != null) {
        $addresses = array($shippingAddressID, $billingAddressID);
    } else {
        $addresses = array(array('countryID' => $_SESSION['receiver_countryID'], 'zoneID' => $_SESSION['receiver_zoneID']), array('countryID' => $_SESSION['billing_countryID'], 'zoneID' => $_SESSION['billing_zoneID']));
    }
    $orderDetails = array('first_name' => $shippingAddress['first_name'], 'last_name' => $shippingAddress['last_name'], 'email' => $customerInfo['Email'], 'order_amount' => oaGetOrderAmountExShippingRate($cartContent, $addresses, $log, FALSE));
    $shippingMethod = shGetShippingMethodById($shippingMethodID);
    $shipping_email_comments_text = $shippingMethod['email_comments_text'];
    $shippingName = $shippingMethod['Name'];
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    $paymentName = $paymentMethod['Name'];
    $payment_email_comments_text = $paymentMethod['email_comments_text'];
    if (isset($paymentMethod['calculate_tax']) && (int) $paymentMethod['calculate_tax'] == 0) {
        $order_amount = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $d = oaGetDiscountPercent($cartContent, $log);
        $tax = 0;
        $shipping_costUC = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, FALSE, $shServiceID, TRUE);
        $discount_percent = oaGetDiscountPercent($cartContent, $log);
    } else {
        $order_amount = oaGetOrderAmount($cartContent, $addresses, $shippingMethodID, $log, $orderDetails, TRUE, $shServiceID);
        $d = oaGetDiscountPercent($cartContent, $log);
        $tax = oaGetProductTax($cartContent, $d, $addresses);
        $shipping_costUC = oaGetShippingCostTakingIntoTax($cartContent, $shippingMethodID, $addresses, $orderDetails, TRUE, $shServiceID, TRUE);
        $discount_percent = oaGetDiscountPercent($cartContent, $log);
    }
    $shServiceInfo = '';
    if (is_array($shipping_costUC)) {
        list($shipping_costUC) = $shipping_costUC;
        $shServiceInfo = $shipping_costUC['name'];
        $shipping_costUC = $shipping_costUC['rate'];
    }
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    if ($paymentMethod) {
        $currentPaymentModule = modGetModuleObj($paymentMethod['module_id'], PAYMENT_MODULE);
    } else {
        $currentPaymentModule = null;
    }
    if ($currentPaymentModule != null) {
        //define order details for payment module
        $order_payment_details = array('customer_email' => $customer_email, 'customer_ip' => $customer_ip, 'order_amount' => $order_amount, 'currency_code' => $currency_code, 'currency_value' => $currency_value, 'shipping_cost' => $shipping_costUC, 'order_tax' => $tax, 'shipping_info' => $shippingAddress, 'billing_info' => $billingAddress);
        $process_payment_result = $currentPaymentModule->payment_process($order_payment_details);
        //gets payment processing result
        if (!($process_payment_result == 1)) {
            //die ($process_payment_result);
            if (isset($_POST)) {
                $_SESSION['order4confirmation_post'] = $_POST;
            }
            xSaveData('PaymentError', $process_payment_result);
            if (!$customerID) {
                RedirectProtected('index.php?order4_confirmation_quick=yes' . '&shippingMethodID=' . $_GET['shippingMethodID'] . '&paymentMethodID=' . $_GET['paymentMethodID'] . '&shServiceID=' . $shServiceID);
            } else {
                RedirectProtected('index.php?order4_confirmation=yes' . '&shippingAddressID=' . $_GET['shippingAddressID'] . '&shippingMethodID=' . $_GET['shippingMethodID'] . '&billingAddressID=' . $_GET['billingAddressID'] . '&paymentMethodID=' . $_GET['paymentMethodID'] . '&shServiceID=' . $shServiceID);
            }
            return false;
        }
    }
    $customerID = (int) $customerID;
    //    debug($cartContent['cart_content']);
    //
    //    exit;
    $sql = 'INSERT INTO ' . ORDERS_TABLE . '
    SET
    customerID =  ' . (int) $customerID . ',
    order_time = "' . xEscSQL($order_time) . '",
    customer_ip = "' . xToText($customer_ip) . '",
    shipping_type = "' . xToText($shippingName) . '",
    payment_type = "' . xToText($paymentName) . '",
    customers_comment = "' . xToText($customers_comment) . '",
    statusID = ' . (int) $statusID . ',
    shipping_cost = "' . (double) $shipping_costUC . '",
    order_discount = "' . (double) $discount_percent . '",
    order_amount= "' . (double) $order_amount . '",
    currency_code = "' . xEscSQL($currency_code) . '",
    currency_value = "' . (double) $currency_value . '",
    customer_firstname = "' . xToText($customerInfo['first_name']) . '",
    customer_lastname = "' . xToText($customerInfo['last_name']) . '",
    customer_email = "' . xToText($customer_email) . '",
    shipping_firstname = "' . xToText($shippingAddress['first_name']) . '",
    shipping_lastname = "' . xToText($shippingAddress['last_name']) . '",
    shipping_country= "' . xToText($shippingAddress['country_name']) . '",
    shipping_state= "' . xToText($shippingAddress['state']) . '",
    shipping_city= "' . xToText($shippingAddress['city']) . '",
    shipping_address= "' . xToText($shippingAddress['address']) . '",
    billing_firstname= "' . xToText($billingAddress['first_name']) . '",
    billing_lastname= "' . xToText($billingAddress['last_name']) . '",
    billing_country= "' . xToText($billingAddress['country_name']) . '",
    billing_state= "' . xToText($billingAddress['state']) . '",
    billing_city= "' . xToText($billingAddress['city']) . '",
    billing_address= "' . xToText($billingAddress['address']) . '",
    cc_number= "' . xEscSQL($cc_number) . '",
    cc_holdername= "' . xToText($cc_holdername) . '",
    cc_expires= "' . xEscSQL($cc_expires) . '",
    cc_cvv= "' . xEscSQL($cc_cvv) . '",
    affiliateID= "' . (isset($_SESSION['refid']) ? $_SESSION['refid'] : regGetIdByLogin($customer_affiliationLogin)) . '",
    shippingServiceInfo= "' . $shServiceInfo . '",
    custlink= "' . xEscSQL($order_active_link) . '",
    currency_round= "' . (int) $currency_round . '",
    paymethod= ' . (int) $paymentMethodID;
    db_query($sql);
    $orderID = db_insert_id(ORDERS_TABLE);
    if (!CONF_ACTIVE_ORDER) {
        stChangeOrderStatus($orderID, $statusID);
    }
    $paymentMethod = payGetPaymentMethodById($paymentMethodID);
    if ($paymentMethod) {
        $currentPaymentModule = modGetModuleObj($paymentMethod['module_id'], PAYMENT_MODULE);
        //                $currentPaymentModule = payGetPaymentModuleById( $paymentMethod['module_id'], $paymentModulesFiles );
    } else {
        $currentPaymentModule = null;
    }
    //save shopping cart content to database and update in-stock information
    if ($log != null) {
        cartMoveContentFromShoppingCartsToOrderedCarts($orderID, $shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, $smarty_mail);
    } else {
        _moveSessionCartContentToOrderedCart($orderID, $paymentMethodID);
        //update in-stock information
        if ($statusID != ostGetCanceledStatusId() && CONF_CHECKSTOCK) {
            $q1 = db_query('select itemID, Quantity FROM ' . ORDERED_CARTS_TABLE . ' WHERE orderID=' . (int) $orderID);
            while ($item = db_fetch_row($q1)) {
                $q2 = db_query('select productID FROM ' . SHOPPING_CART_ITEMS_TABLE . ' WHERE itemID=' . (int) $item['itemID']);
                $pr = db_fetch_row($q2);
                if ($pr) {
                    db_query('update ' . PRODUCTS_TABLE . ' set in_stock = in_stock - ' . (int) $item['Quantity'] . ' where productID=' . (int) $pr[0]);
                    $q = db_query('select name, in_stock FROM ' . PRODUCTS_TABLE . ' WHERE productID=' . (int) $pr[0]);
                    $productsta = db_fetch_row($q);
                    if ($productsta[1] == 0) {
                        if (CONF_AUTOOFF_STOCKADMIN) {
                            db_query('update ' . PRODUCTS_TABLE . ' set enabled=0 where productID=' . (int) $pr[0]);
                        }
                        if (CONF_NOTIFY_STOCKADMIN) {
                            $smarty_mail->assign('productstaname', $productsta[0]);
                            $smarty_mail->assign('productstid', $pr[0]);
                            $stockadmin = $smarty_mail->fetch('notify_stockadmin.tpl');
                            $ressta = xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, CUSTOMER_ACTIVATE_99 . ' - ' . CONF_SHOP_NAME, $stockadmin);
                        }
                    }
                }
            }
        }
        //now save registration form aux fields into CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG
        //for quick checkout orders these fields are stored separately than for registered customer (SS_customers)
        db_query('delete from ' . CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG . ' where orderID=' . (int) $orderID);
        foreach ($_SESSION as $key => $val) {
            if (strstr($key, 'additional_field_') && strlen(trim($val)) > 0) {
                $id = (int) str_replace('additional_field_', '', $key);
                if ($id > 0) {
                    db_query('insert into ' . CUSTOMER_REG_FIELDS_VALUES_TABLE_QUICKREG . ' (orderID, reg_field_ID, reg_field_value) values (' . (int) $orderID . ', ' . (int) $id . ', "' . xToText(trim($val)) . '");');
                }
            }
        }
    }
    if ($currentPaymentModule != null) {
        $currentPaymentModule->after_processing_php($orderID);
    }
    _sendOrderNotifycationToAdmin($orderID, $smarty_mail, $tax);
    _sendOrderNotifycationToCustomer($orderID, $smarty_mail, $customerInfo['Email'], $log, $payment_email_comments_text, $shipping_email_comments_text, $tax, $order_active_link);
    if ($log == null) {
        _quickOrderUnsetSession();
    }
    unset($_SESSION['order4confirmation_post']);
    return $orderID;
}
Пример #4
0
<?php

if (isset($order2_shipping)) {
    //var_dump($_GET);
    if (!cartCheckMinTotalOrderAmount()) {
        Redirect('index.php?shopping_cart=yes&min_order=error');
    }
    if (!isset($_GET["order2_shipping"]) || !isset($_GET["shippingAddressID"])) {
        Redirect("index.php?page_not_found=yes");
    }
    $_GET["shippingAddressID"] = (int) $_GET["shippingAddressID"];
    if ($_GET["shippingAddressID"] == 0) {
        $addrs = regGetAllAddressesByLogin($_SESSION["log"]);
    } else {
        if (!regAddressBelongToCustomer(regGetIdByLogin($_SESSION["log"]), $_GET["shippingAddressID"])) {
            Redirect("index.php?page_not_found=yes");
        }
    }
    if (!cartCheckMinOrderAmount()) {
        Redirect("index.php?shopping_cart=yes");
    }
    function _getOrder()
    {
        $cust_password = "";
        $Email = "";
        $first_name = "";
        $last_name = "";
        $subscribed4news = "";
        $additional_field_values = "";
        $countryID = "";
        $zoneID = "";
Пример #5
0
function regUpdateContactInfo($old_login, $login, $cust_password, $Email, $first_name, $last_name, $subscribed4news, $additional_field_values)
{
    db_query("update " . CUSTOMERS_TABLE . "  set " . " Login = '******', " . " cust_password = '******', " . " Email = '" . xToText($Email) . "', " . " first_name = '" . xToText(trim($first_name)) . "', " . " last_name = '" . xToText(trim($last_name)) . "', " . " subscribed4news = " . (int) $subscribed4news . " " . " where Login='******'");
    foreach ($additional_field_values as $key => $val) {
        SetRegField($key, $login, $val["additional_field"]);
    }
    if (!strcmp($old_login, $login)) {
        //update administrator login (core/config/connect.inc.php)
        db_query("update " . CUSTOMERS_TABLE . " set Login='******' where Login='******'");
    }
    $customerID = regGetIdByLogin($login);
    if ($subscribed4news) {
        subscrAddRegisteredCustomerEmail($customerID);
    } else {
        subscrUnsubscribeSubscriberByEmail(base64_encode($Email));
    }
}
Пример #6
0
Файл: cart.php Проект: gblok/rsc
         //calling session_unregister() is required since unset() may not work on some systems
     } else {
         $variants = array();
     }
     for ($mcn = 0; $mcn < $_GET["multyaddcount"]; $mcn++) {
         cartAddToCart((int) $_GET["addproduct"], $variants);
     }
 }
 $resCart = cartGetCartContent();
 $resDiscount = dscCalculateDiscount($resCart["total_price"], isset($_SESSION["log"]) ? $_SESSION["log"] : "");
 $discount_value = addUnitToPrice($resDiscount["discount_current_unit"]);
 $discount_percent = $resDiscount["discount_percent"];
 $k = 0;
 $cnt = 0;
 if (isset($_SESSION["log"])) {
     $q = db_query("select itemID, Quantity FROM " . SHOPPING_CARTS_TABLE . " WHERE customerID=" . (int) regGetIdByLogin($_SESSION["log"]));
     while ($row = db_fetch_row($q)) {
         $q1 = db_query("select productID from " . SHOPPING_CART_ITEMS_TABLE . " where itemID=" . (int) $row["itemID"]);
         $r1 = db_fetch_row($q1);
         $variants = GetConfigurationByItemId($row["itemID"]);
         $k += GetPriceProductWithOption($variants, $r1["productID"]) * $row["Quantity"];
         $cnt += $row["Quantity"];
     }
 } else {
     if (isset($_SESSION["gids"])) {
         for ($i = 0; $i < count($_SESSION["gids"]); $i++) {
             if ($_SESSION["gids"][$i]) {
                 $t = db_query("select Price FROM " . PRODUCTS_TABLE . " WHERE productID=" . (int) $_SESSION["gids"][$i]);
                 $rr = db_fetch_row($t);
                 $sum = $rr["Price"];
                 // $rr["Price"]
Пример #7
0
<?php

if (isset($order3_billing)) {
    if (!cartCheckMinTotalOrderAmount()) {
        Redirect('index.php?shopping_cart=yes&min_order=error');
    }
    if (!isset($_GET["order3_billing"]) || !isset($_GET["shippingAddressID"]) || !isset($_GET["shippingMethodID"]) || !isset($_GET["billingAddressID"])) {
        Redirect("index.php?page_not_found=yes");
    }
    $_GET["shippingAddressID"] = (int) $_GET["shippingAddressID"];
    $_GET["billingAddressID"] = (int) $_GET["billingAddressID"];
    $_GET["shippingMethodID"] = (int) $_GET["shippingMethodID"];
    if ($_GET["shippingAddressID"] != 0 && !regAddressBelongToCustomer(regGetIdByLogin($_SESSION["log"]), $_GET["shippingAddressID"])) {
        Redirect("index.php?page_not_found=yes");
    }
    if ($_GET["billingAddressID"] != 0 && !regAddressBelongToCustomer(regGetIdByLogin($_SESSION["log"]), $_GET["billingAddressID"])) {
        Redirect("index.php?page_not_found=yes");
    }
    if ($_GET["shippingMethodID"] != 0) {
        if (!shShippingMethodIsExist($_GET["shippingMethodID"])) {
            Redirect("index.php?page_not_found=yes");
        }
    }
    if (!cartCheckMinOrderAmount()) {
        Redirect("index.php?shopping_cart=yes");
    }
    if (isset($_POST["continue_button"])) {
        RedirectProtected("index.php?order4_confirmation=yes&" . "shippingAddressID=" . $_GET["shippingAddressID"] . "&" . "shippingMethodID=" . $_GET["shippingMethodID"] . "&" . "billingAddressID=" . $_GET["billingAddressID"] . "&" . "paymentMethodID=" . $_POST["select_payment_method"] . (isset($_GET['shServiceID']) ? "&shServiceID=" . $_GET['shServiceID'] : ''));
    }
    if (isset($_GET["selectedNewAddressID"])) {
        RedirectProtected("index.php?order3_billing=yes&" . "shippingAddressID=" . $_GET["shippingAddressID"] . "&" . "shippingMethodID=" . $_GET["shippingMethodID"] . "&" . "billingAddressID=" . $_GET["selectedNewAddressID"] . (isset($_GET['shServiceID']) ? "&shServiceID=" . $_GET['shServiceID'] : ''));
Пример #8
0
 $cc_cvv = "";
 if (CONF_ORDERING_REQUEST_BILLING_ADDRESS == 0 && $_GET["billingAddressID"] == 0) {
     $_GET["billingAddressID"] = $_GET["shippingAddressID"];
 }
 if (CONF_CHECKSTOCK) {
     $cartContent = cartGetCartContent();
     $rediractflag = false;
     foreach ($cartContent["cart_content"] as $cartItem) {
         // if conventional ordering
         if (isset($_SESSION["log"])) {
             $productID = GetProductIdByItemId($cartItem["id"]);
             $q = db_query("select name, in_stock FROM " . PRODUCTS_TABLE . " WHERE productID=" . (int) $productID);
             $left = db_fetch_row($q);
             if ($left["in_stock"] < 1) {
                 $rediractflag = true;
                 db_query("DELETE FROM " . SHOPPING_CARTS_TABLE . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) $cartItem["id"]);
                 db_query("DELETE FROM " . SHOPPING_CART_ITEMS_TABLE . " where itemID=" . (int) $cartItem["id"]);
                 db_query("DELETE FROM " . SHOPPING_CART_ITEMS_CONTENT_TABLE . " where itemID=" . (int) $cartItem["id"]);
                 db_query("DELETE FROM " . ORDERED_CARTS_TABLE . " where itemID=" . (int) $cartItem["id"]);
             }
         } else {
             // if quick ordering
             $productID = $cartItem["id"];
             $q = db_query("select name, in_stock FROM " . PRODUCTS_TABLE . " WHERE productID=" . (int) $productID);
             $left = db_fetch_row($q);
             if ($left["in_stock"] < 1) {
                 $rediractflag = true;
                 $res = DeCodeItemInClient($productID);
                 $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]);
                 if ($i != -1) {
                     $_SESSION["gids"][$i] = 0;
Пример #9
0
function dscCalculateDiscount($orderPrice, $log)
{
    $discount = array("discount_percent" => 0, "discount_standart_unit" => 0, "discount_current_unit" => 0, "rest_standart_unit" => 0, "rest_current_unit" => 0, "priceUnit" => getPriceUnit());
    $customerID = (int) regGetIdByLogin($log);
    switch (CONF_DISCOUNT_TYPE) {
        // discount is switched off
        case 1:
            return $discount;
            break;
            // discount is based on customer group
        // discount is based on customer group
        case 2:
            if (!is_bool($customerID = regGetIdByLogin($log))) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
                if ($customer_group) {
                    $discount["discount_percent"] = $customer_group["custgroup_discount"];
                } else {
                    $discount["discount_percent"] = 0;
                }
            } else {
                return $discount;
            }
            break;
            // discount is calculated with help general order price
        // discount is calculated with help general order price
        case 3:
            $discount["discount_percent"] = _calculateGeneralPriceDiscount($orderPrice, $log);
            break;
            // discount equals to discount is based on customer group plus
            //                discount calculated with help general order price
        // discount equals to discount is based on customer group plus
        //                discount calculated with help general order price
        case 4:
            if (!is_bool($customerID)) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
                if (!$customer_group) {
                    $customer_group = array("custgroup_discount" => 0);
                }
            } else {
                $customer_group["custgroup_discount"] = 0;
            }
            $discount["discount_percent"] = $customer_group["custgroup_discount"] + _calculateGeneralPriceDiscount($orderPrice, $log);
            break;
            // discount is calculated as MAX( discount is based on customer group,
            //                        discount calculated with help general order price  )
        // discount is calculated as MAX( discount is based on customer group,
        //                        discount calculated with help general order price  )
        case 5:
            if (!is_bool($customerID)) {
                $customer_group = GetCustomerGroupByCustomerId($customerID);
            } else {
                $customer_group["custgroup_discount"] = 0;
            }
            if ($customer_group["custgroup_discount"] >= _calculateGeneralPriceDiscount($orderPrice, $log)) {
                $discount["discount_percent"] = $customer_group["custgroup_discount"];
            } else {
                $discount["discount_percent"] = _calculateGeneralPriceDiscount($orderPrice, $log);
            }
            break;
    }
    $discount["discount_standart_unit"] = (double) $orderPrice / 100 * (double) $discount["discount_percent"];
    $discount["discount_current_unit"] = show_priceWithOutUnit($discount["discount_standart_unit"]);
    $discount["rest_standart_unit"] = $orderPrice - $discount["discount_standart_unit"];
    $discount["rest_current_unit"] = show_priceWithOutUnit($discount["rest_standart_unit"]);
    return $discount;
}
 function saveCurrentCart()
 {
     ClassManager::includeClass('customer');
     $customerEntry = Customer::getAuthedInstance();
     $customerID = isset($_SESSION["log"]) ? regGetIdByLogin($_SESSION["log"]) : 0;
     if ($customerEntry instanceof customer) {
         $this->saveToCurrentCustomerCart();
     } else {
         $this->saveToCurrentSessionCart();
     }
 }
Пример #11
0
function moveCartFromSession2DB()
{
    //all products in shopping cart, which are in session vars, move to the database
    if (isset($_SESSION["gids"]) && isset($_SESSION["log"])) {
        $customerID = regGetIdByLogin($_SESSION["log"]);
        $q = db_query("select itemID from " . SHOPPING_CARTS_TABLE . " where customerID=" . (int) $customerID);
        $items = array();
        while ($item = db_fetch_row($q)) {
            $items[] = (int) $item["itemID"];
        }
        //$i=0;
        foreach ($_SESSION["gids"] as $key => $productID) {
            if ($productID == 0) {
                continue;
            }
            // search product in current user's shopping cart content
            $itemID = null;
            for ($j = 0; $j < count($items); $j++) {
                $q = db_query("select count(*) from " . SHOPPING_CART_ITEMS_TABLE . " where productID=" . (int) $productID . " AND itemID=" . (int) $items[$j]);
                $count = db_fetch_row($q);
                $count = $count[0];
                if ($count != 0) {
                    // compare configuration
                    $configurationFromSession = $_SESSION["configurations"][$key];
                    $configurationFromDB = GetConfigurationByItemId($items[$j]);
                    if (CompareConfiguration($configurationFromSession, $configurationFromDB)) {
                        $itemID = $items[$j];
                        break;
                    }
                }
            }
            if ($itemID == null) {
                // create new item
                db_query("insert into " . SHOPPING_CART_ITEMS_TABLE . " (productID) values(" . (int) $productID . ")");
                $itemID = db_insert_id();
                // set content item
                foreach ($_SESSION["configurations"][$key] as $vars) {
                    db_query("insert into " . SHOPPING_CART_ITEMS_CONTENT_TABLE . " ( itemID, variantID ) " . " values( " . (int) $itemID . ", " . (int) $vars . " )");
                }
                // insert item into cart
                db_query("insert " . SHOPPING_CARTS_TABLE . " (customerID, itemID, Quantity) values ( " . (int) $customerID . ", " . (int) $itemID . ", " . (int) $_SESSION["counts"][$key] . " )");
            } else {
                db_query("update " . SHOPPING_CARTS_TABLE . " set Quantity=Quantity + " . (int) $_SESSION["counts"][$key] . " where customerID=" . (int) $customerID . " and itemID=" . (int) $itemID);
            }
        }
        unset($_SESSION["gids"]);
        unset($_SESSION["counts"]);
        unset($_SESSION["configurations"]);
        session_unregister("gids");
        //calling session_unregister() is required since unset() may not work on some systems
        session_unregister("counts");
        session_unregister("configurations");
    }
}
Пример #12
0
function GetRegFieldsValues($customer_login)
{
    //get customer
    $customerID = regGetIdByLogin($customer_login);
    if (!$customerID) {
        return array();
    }
    return GetRegFieldsValuesByCustomerID($customerID);
}
Пример #13
0
}
$orderID = null;
$order = null;
if (isset($_REQUEST["InvId"])) {
    $orderID = (int) $_REQUEST["InvId"];
}
if (isset($_REQUEST["LMI_PAYMENT_NO"])) {
    $orderID = (int) $_REQUEST["LMI_PAYMENT_NO"];
}
if (isset($_REQUEST["WMI_PAYMENT_NO"])) {
    $orderID = (int) $_REQUEST["WMI_PAYMENT_NO"];
}
$order = ordGetOrder($orderID);
if ($order != null && $orderID > 0) {
    switch ($transaction_result) {
        case 'success':
            $smarty->assign('orderID', $orderID);
            $smarty->assign('TransactionResult', $transaction_result);
            $smarty->assign("main_content_template", "transaction_result.tpl");
            if ($orderID != "" && $order["customerID"] == regGetIdByLogin($_SESSION["log"])) {
                header('Refresh: 6; url=index.php?p_order_detailed=' . $orderID);
            }
            break;
        case 'failure':
            $smarty->assign('TransactionResult', $transaction_result);
            $smarty->assign("main_content_template", "transaction_result.tpl");
            break;
        default:
            break;
    }
}
Пример #14
0
 foreach ($_POST as $key => $val) {
     if (strstr($key, "count_")) {
         if (isset($_SESSION["log"])) {
             //authorized user
             $productID = GetProductIdByItemId(str_replace("count_", "", $key));
             $is = GetProductInStockCount($productID);
             if ($val > 0) {
                 //$val is a new items count in the shopping cart
                 if (CONF_CHECKSTOCK == 1) {
                     $val = min($val, $is);
                 }
                 //check stock level
                 $q = db_query("UPDATE " . SHOPPING_CARTS_TABLE . " SET Quantity=" . floor($val) . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) str_replace("count_", "", $key));
             } else {
                 //$val<=0 => delete item from cart
                 $q = db_query("DELETE FROM " . SHOPPING_CARTS_TABLE . " WHERE customerID=" . regGetIdByLogin($_SESSION["log"]) . " AND itemID=" . (int) str_replace("count_", "", $key));
             }
         } else {
             //session vars
             $res = DeCodeItemInClient(str_replace("count_", "", $key));
             $is = GetProductInStockCount($res["productID"]);
             if ($val > 0) {
                 $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]);
                 //check stock level
                 if (CONF_CHECKSTOCK == 1) {
                     $val = min($val, $is);
                 }
                 $_SESSION["counts"][$i] = floor($val);
             } else {
                 //remove
                 $i = SearchConfigurationInSessionVariable($res["variants"], $res["productID"]);
Пример #15
0
function cartCartIsEmpty($log)
{
    $customerID = regGetIdByLogin($log);
    if ((int) $customerID > 0) {
        $customerID = (int) $customerID;
        $sql = '
            SELECT count(*)
            FROM ' . SHOPPING_CARTS_TABLE . '
            WHERE customerID=' . (int) $customerID;
        $q_count = db_query($sql);
        $count = db_fetch_row($q_count);
        $count = $count[0];
        return $count == 0;
    } else {
        return true;
    }
}
Пример #16
0
/**
 *
 * @param $log customer login
 * @return boolean returns true if cart is empty for this customer
 */
function cartCartIsEmpty($log)
{
    $customerID = regGetIdByLogin($log);
    if ((int) $customerID > 0) {
        $customerID = (int) $customerID;
        $q_count = db_query("select count(*) from " . SHOPPING_CARTS_TABLE . " where customerID=" . $customerID);
        $count = db_fetch_row($q_count);
        $count = $count[0];
        return $count == 0;
    } else {
        return true;
    }
}
Пример #17
0
function moveCartFromSession2DB()
{
    if (isset($_SESSION["gids"]) && isset($_SESSION["log"])) {
        $customerID = regGetIdByLogin($_SESSION["log"]);
        $q = db_query("select itemID from " . SHOPPING_CARTS_TABLE . " where customerID=" . $customerID);
        $items = array();
        while ($item = db_fetch_row($q)) {
            $items[] = $item["itemID"];
        }
        //$i=0;
        foreach ($_SESSION["gids"] as $key => $productID) {
            if ($productID == 0) {
                continue;
            }
            // search product in current user's shopping cart content
            $itemID = null;
            for ($j = 0; $j < count($items); $j++) {
                $q = db_query("select count(*) from " . SHOPPING_CART_ITEMS_TABLE . " where productID=" . $productID . " AND " . " itemID=" . $items[$j]);
                $count = db_fetch_row($q);
                $count = $count[0];
                if ($count != 0) {
                    // compare configuration
                    $configurationFromSession = $_SESSION["configurations"][$key];
                    $configurationFromDB = GetConfigurationByItemId($items[$j]);
                    if (CompareConfiguration($configurationFromSession, $configurationFromDB)) {
                        $itemID = $items[$j];
                        break;
                    }
                    $itemID = $items[$j];
                }
            }
            if ($itemID == null) {
                // create new item
                db_query("insert into " . SHOPPING_CART_ITEMS_TABLE . " (productID) values('" . $productID . "')\n");
                $itemID = db_insert_id();
                // set content item
                foreach ($_SESSION["configurations"][$key] as $var) {
                    db_query("insert into " . SHOPPING_CART_ITEMS_CONTENT_TABLE . " ( itemID, variantID ) " . " values( '" . $itemID . "', '" . $var . "' )\n");
                }
                if ($_SESSION["sample"][$key]) {
                    $quantity = 1;
                    $sample = 1;
                } else {
                    $quantity = $_SESSION["counts"][$key];
                    $sample = 0;
                }
                // insert item into cart
                db_query("insert " . SHOPPING_CARTS_TABLE . "(customerID, itemID, Quantity, sample)" . "values( '" . $customerID . "', '" . $itemID . "', '" . $quantity . "', '" . $sample . "' )\n");
            } else {
                if (!$_SESSION["sample"][$key]) {
                    db_query("update " . SHOPPING_CARTS_TABLE . " set Quantity=Quantity + " . $_SESSION["counts"][$key] . " " . " where customerID=" . $customerID . " and itemID=" . $itemID . "\n");
                }
            }
        }
        unset($_SESSION["gids"]);
        unset($_SESSION["counts"]);
        unset($_SESSION["configurations"]);
        unset($_SESSION["sample"]);
    }
}
Пример #18
0
<?php

// shopping cart brief info
//calculate shopping cart value
$k = 0;
$cnt = 0;
//taking products from database
if (isset($_SESSION['log'])) {
    $sql = '
        SELECT
        itemID,
        Quantity
        FROM ' . SHOPPING_CARTS_TABLE . '
        WHERE customerID= ' . regGetIdByLogin($_SESSION['log']);
    $q = db_query($sql);
    unset($_SESSION['special_set']['cart']);
    while ($row = db_fetch_row($q)) {
        $sql = '
            SELECT
            productID
            FROM ' . SHOPPING_CART_ITEMS_TABLE . '
            WHERE itemID=' . $row['itemID'];
        $q1 = db_query($sql);
        $r1 = db_fetch_row($q1);
        if ($r1['productID']) {
            $_SESSION['special_set']['cart'][] = $r1['productID'];
            $variants = GetConfigurationByItemId($row['itemID']);
            $k += GetPriceProductWithOption($variants, $r1['productID']) * $row['Quantity'];
            $cnt += $row['Quantity'];
        }
    }
Пример #19
0
     Redirect(set_query('delete_commission=ok', $_POST['fREDIRECT']));
     break;
 case 'SAVE_COMMISSION':
     #check date
     if (!isTemplateDate($_POST['COMMISSION']['xDateTime'], CONF_DATE_FORMAT)) {
         $error_message = AFFP_MSG_ERROR_DATE_FORMAT;
         break;
     } else {
         $xDateTime = TransformTemplateToDATE($_POST['COMMISSION']['xDateTime'], CONF_DATE_FORMAT) . date(" H:i:s");
     }
     #check user
     if (!regGetIdByLogin($_POST['COMMISSION']['customerLogin'])) {
         $error_message = ERROR_INPUT_LOGIN;
         break;
     } else {
         $_POST['COMMISSION']['customerID'] = regGetIdByLogin($_POST['COMMISSION']['customerLogin']);
         unset($_POST['COMMISSION']['customerLogin']);
     }
     $_POST['COMMISSION']['Amount'] = isset($_POST['COMMISSION']['Amount']) ? round($_POST['COMMISSION']['Amount'], 2) : 0;
     $_POST['COMMISSION']['xDateTime'] = $xDateTime;
     affp_saveCommission($_POST['COMMISSION']);
     print '
                                         <script language="javascript" type="text/javascript">
                                         <!--
                                         window.opener.document.location.href = window.opener.reloadURL;
                                         window.opener.focus();
                                         window.close();
                                         //-->
                                         </script>
                                         ';
     exit(1);
Пример #20
0
<?php

#handler for new customers by links
if (isset($_GET['refid'])) {
    $_RefererLogin = regGetLoginById(intval($_GET['refid']));
    if ($_RefererLogin) {
        session_register('s_RefererLogin');
        $_SESSION['s_RefererLogin'] = $_RefererLogin;
        $_SESSION['refid'] = intval($_GET['refid']);
        Redirect(set_query(''));
    }
}
if (isset($_SESSION["log"]) && (isset($_GET["affiliate"]) || isset($_POST["affiliate"])) && CONF_AFFILIATE_PROGRAM_ENABLED) {
    $SubPage = isset($_GET['sub']) ? $_GET['sub'] : 'balance';
    $fACTION = isset($_POST['fACTION']) ? $_POST['fACTION'] : '';
    $customerID = regGetIdByLogin($_SESSION["log"]);
    $affp_CustomersNum = affp_getCustomersNum($customerID);
    #post-requests handler
    switch ($fACTION) {
        case 'SAVE_SETTINGS':
            affp_saveSettings($customerID, isset($_POST['EmailOrders']), isset($_POST['EmailPayments']));
            Redirect(set_query('save_settings=ok'));
            break;
    }
    #loading data for subpages
    switch ($SubPage) {
        case 'balance':
            $Commissions = affp_getCommissionsAmount($customerID);
            $Payments = affp_getPaymentsAmount($customerID);
            $smarty->assign('CommissionsNumber', count($Commissions));
            $smarty->assign('PaymentsNumber', count($Payments));
Пример #21
0
    $smarty->force_compile = true;
}
$relaccess = checklogin();
//set Smarty include files dir
$smarty->template_dir = "core/tpl/admin";
$error = "";
// validate order and user
if (CONF_BACKEND_SAFEMODE != 1 && !isset($_SESSION["log"]) || !isset($_GET["orderID"])) {
    $error = ERROR_FORBIDDEN;
} else {
    $orderID = (int) $_GET["orderID"];
    $order = ordGetOrder($orderID);
    $order["discount_value"] = round((double) $order["order_discount"] * $order["clear_total_priceToShow"]) / 100;
    if (!$order) {
        $error = ERROR_CANT_FIND_REQUIRED_PAGE;
    } else {
        //administrator is allowed to access all orders invoices
        //and if logged user is not administrator, check if order belongs to this user.
        if (CONF_BACKEND_SAFEMODE != 1 && !in_array(100, $relaccess) && $order["customerID"] != regGetIdByLogin($_SESSION["log"])) {
            $error = ERROR_FORBIDDEN;
        } else {
            $orderContent = ordGetOrderContent($orderID);
            $smarty->assign("orderContent", $orderContent);
            $smarty->assign("order", $order);
            $smarty->assign("completed_order_status", ostGetCompletedOrderStatus());
        }
    }
}
$smarty->assign("error", $error);
//show Smarty output
$smarty->display("invoice.tpl");