function loadCurrentCustomerCart($customerID)
    {
        $this->Items = new xmlNodeX('items');
        /**
         * Select all items from SHOPPING_CARTS_TABLE
         */
        $dbq = '
				SELECT itemID, Quantity, sample FROM ?#SHOPPING_CARTS_TABLE WHERE customerID=?
			';
        $q_items = db_phquery($dbq, $customerID);
        while ($item = db_fetch_assoc($q_items)) {
            $productID = GetProductIdByItemId($item["itemID"]);
            if ($productID == null || trim($productID) == "") {
                continue;
            }
            $dbr = db_phquery('SELECT * FROM ?#PRODUCTS_TABLE WHERE productID=?', $productID);
            if (!db_num_rows($dbr['resource'])) {
                continue;
            }
            $product = db_fetch_assoc($dbr);
            if ($item['sample']) {
                $product['free_shipping'] = 1;
            }
            $aItem =& $this->Items->child('item');
            $aItem->attribute('id', $item['itemID']);
            $aProduct =& $aItem->child('product', array('id' => $productID, 'free-shipping' => $product['free_shipping']));
            if ($product['shipping_freight']) {
                $aProduct->child('freight', array('currency' => ''), $product['shipping_freight']);
            }
            $aItem->child('quantity', null, $item['Quantity']);
            $aItem->child('sample', null, $item['sample']);
            $variants = array();
            $variants = GetConfigurationByItemId($item["itemID"]);
            $aVariants =& $aItem->child('variants');
            foreach ($variants as $v) {
                $aVariants->child('variant', array('id' => $v));
            }
            $aPrice =& $aItem->child('price');
            $aPrice->attribute('currency', '');
            $aPrice->setData(GetPriceProductWithOption($variants, $productID));
        }
    }
Example #2
0
 }
 if (isset($_POST["submitgo"])) {
     $cc_number = "";
     $cc_holdername = "";
     $cc_expires = "";
     $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) {
Example #3
0
function ordAccessToLoadFile($orderID, $productID, &$pathToProductFile, &$productFileShortName)
{
    $order = ordGetOrder($orderID);
    $product = GetProduct($productID);
    if (strlen($product['eproduct_filename']) == 0 || !file_exists('core/files/' . $product['eproduct_filename']) || $product['eproduct_filename'] == null) {
        return 4;
    }
    if ((int) $order['statusID'] != (int) ostGetCompletedOrderStatus()) {
        return 3;
    }
    $orderContent = ordGetOrderContent($orderID);
    foreach ($orderContent as $item) {
        if (GetProductIdByItemId($item['itemID']) == $productID) {
            if ($item['load_counter'] < $product['eproduct_download_times'] || $product['eproduct_download_times'] == 0) {
                $date1 = dtGetParsedDateTime($order['order_time_mysql']);
                //$order['order_time']
                $date2 = dtGetParsedDateTime(get_current_time());
                $countDay = _getDayBetweenDate($date1, $date2);
                if ($countDay >= $product['eproduct_available_days']) {
                    return 2;
                }
                if ($product['eproduct_download_times'] != 0) {
                    db_query('update ' . ORDERED_CARTS_TABLE . ' set load_counter=load_counter+1 ' . ' where itemID=' . (int) $item['itemID'] . ' AND orderID=' . (int) $orderID);
                }
                $pathToProductFile = 'core/files/' . $product['eproduct_filename'];
                $productFileShortName = $product['eproduct_filename'];
                return 0;
            } else {
                return 1;
            }
        }
    }
    return -1;
}
Example #4
0
function cartMoveContentFromShoppingCartsToOrderedCarts($orderID, $shippingMethodID, $paymentMethodID, $shippingAddressID, $billingAddressID, $shippingModuleFiles, $paymentModulesFiles, &$smarty_mail)
{
    $sql = '
        SELECT
        statusID
        FROM ' . ORDERS_TABLE . '
        WHERE orderID=' . (int) $orderID;
    $q = db_query($sql);
    $order = db_fetch_row($q);
    $statusID = $order['statusID'];
    // select all items from SHOPPING_CARTS_TABLE
    $sql = '
        SELECT
        itemID,
        Quantity
        FROM ' . SHOPPING_CARTS_TABLE . '
        WHERE customerID=' . (int) regGetIdByLogin($_SESSION['log']);
    $q_items = db_query($sql);
    while ($item = db_fetch_row($q_items)) {
        $productID = GetProductIdByItemId($item['itemID']);
        if ($productID == null || trim($productID) == '') {
            continue;
        }
        // get product by ID
        $sql = '
            SELECT
            name,
            product_code,
            opt_margin
            FROM ' . PRODUCTS_TABLE . '
            WHERE productID=' . (int) $productID;
        $q_product = db_query($sql);
        $product = db_fetch_row($q_product);
        // get full product name ( complex product name - $productComplexName ) -
        // name with configurator options
        $variants = GetConfigurationByItemId($item['itemID']);
        $options = GetStrOptions($variants);
        $productComplexName = $options != '' ? $product['name'] . '(' . $options . ')' : $product['name'];
        if (strlen($product['product_code']) > 0) {
            $productComplexName = '[' . $product['product_code'] . '] ' . $productComplexName;
        }
        $price = GetPriceProductWithOption($variants, $productID);
        $tax = taxCalculateTax($productID, $shippingAddressID, $billingAddressID);
        if (!empty($product['opt_margin']) && $paymentMethodID == 2) {
            $price += $price / 100 * CONF_PERCENT_MARGIN;
        }
        $sql = '
            INSERT INTO ' . ORDERED_CARTS_TABLE . '
            SET
            itemID = ' . (int) $item['itemID'] . ',
            orderID=' . (int) $orderID . ',
            name = "' . xEscSQL($productComplexName) . '",
            Price = "' . xEscSQL($price) . '",
            Quantity = ' . (int) $item['Quantity'] . ',
            tax="' . xEscSQL($tax) . '"';
        db_query($sql);
        if ($statusID != ostGetCanceledStatusId() && CONF_CHECKSTOCK) {
            $sql = '
                   UPDATE ' . PRODUCTS_TABLE . '
                   SET in_stock = in_stock - ' . (int) $item['Quantity'] . '
                   WHERE productID=' . (int) $productID;
            db_query($sql);
            $sql = '
                   SELECT
                   name,
                   in_stock
                   FROM ' . PRODUCTS_TABLE . '
                   WHERE productID=' . (int) $productID;
            $q = db_query($sql);
            $productsta = db_fetch_row($q);
            if ($productsta['in_stock'] == 0) {
                if (CONF_AUTOOFF_STOCKADMIN) {
                    $sql = '
                           UPDATE ' . PRODUCTS_TABLE . '
                           SET enabled=0
                           WHERE productID=' . (int) $productID;
                    db_query($sql);
                }
                if (CONF_NOTIFY_STOCKADMIN) {
                    $smarty_mail->assign('productstaname', $productsta['name']);
                    $smarty_mail->assign('productstid', $productID);
                    $stockadmin = $smarty_mail->fetch('notify_stockadmin.tpl');
                    $ressta = xMailTxtHTMLDATA(CONF_ORDERS_EMAIL, CUSTOMER_ACTIVATE_99, $stockadmin);
                }
            }
        }
    }
    db_query('DELETE FROM ' . SHOPPING_CARTS_TABLE . ' WHERE customerID=' . (int) regGetIdByLogin($_SESSION['log']));
}
Example #5
0
         if ($i != -1) {
             $_SESSION["gids"][$i] = 0;
         }
     }
     //        unset($_SESSION['special_set']['cart'][(int) $_GET['remove']]);
     //
     //        fbug((int) $_GET['remove']);
     Redirect($cart_reguest . "&shopping_cart=yes");
 }
 if (isset($_POST["update"])) {
     //update shopping cart content
     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));