Ejemplo n.º 1
0
 function add_product()
 {
     $variants = array();
     foreach ($this->getData() as $key => $val) {
         if (!strstr($key, 'option_')) {
             continue;
         }
         $variants[] = $val;
     }
     if (isset($_GET['sample']) && $_GET['sample'] == 1 || isset($_POST['sample']) && $_POST['sample'] == 1) {
         $sample = 1;
     } else {
         $sample = 0;
     }
     $res = cartAddToCart($this->getData('productID'), $variants, $this->getData('product_qty'), $sample);
     $Register =& Register::getInstance();
     /*@var $Register Register*/
     if ($res === false) {
         RedirectSQ('?ukey=product_not_found&view=&external=');
     } elseif ($res === 0) {
         RedirectSQ('?ukey=product_out_of_stock&view=&external=');
     } else {
         //iframe cookie security workaround
         $url_chunk = '';
         if (isset($_GET['widgets']) && $_GET['widgets'] && !strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'])) {
             $url_chunk .= '&check_cookie=' . session_id() . '';
             $url_chunk .= '&productID=' . $this->getData('productID');
             $Register =& Register::getInstance();
             $widgets = false;
             $Register->set('widgets', $widgets);
             $_SERVER['REQUEST_URI'] = preg_replace('/(^|&)widgets=1/', '', $_SERVER['REQUEST_URI']);
         }
         RedirectSQ('?ukey=cart&view=&external=' . $url_chunk);
     }
 }
Ejemplo n.º 2
0
Archivo: podbor.php Proyecto: gblok/rsc
if (isset($_POST['relatedID'])) {
    $relatedID = $_POST['relatedID'];
    $related = psGetRelated($relatedID);
    if (!empty($related)) {
        $sort_related = psGetSortRelated($related);
        sort($sort_related);
    }
    $response['related'] = $sort_related;
}
if (isset($_POST['2cart'])) {
    $productID = $_POST['2cart'];
    if (!empty($productID)) {
        if (empty($qty)) {
            $qty = 1;
        }
        for ($i = 0; $i < $qty; $i++) {
            cartAddToCart($productID, array());
        }
        $cart = cartGetCartContent();
        if (!empty($cart['cart_content'])) {
            $qty = 0;
            foreach ($cart['cart_content'] as $k => $v) {
                $qty += $v['quantity'];
            }
            $_SESSION['special_set']['cart'][] = $id;
        }
        $response['basket'] = array('sc_qty' => (int) $qty, 'sc_val' => show_price($cart['total_price']));
    }
}
echo json_encode($response);
exit;
 function saveToCurrentSessionCart()
 {
     $this->cleanCurrentCart('recalculate');
     $r_aItem = $this->Items->getChildNodes('item');
     $tc = count($r_aItem);
     for ($i = 0; $i < $tc; $i++) {
         $aItem =& $r_aItem[$i];
         /* @var $aItem xmlNodeX */
         $aProduct =& $aItem->getFirstChildByName('product');
         $productID = $aProduct->attribute('id');
         $aVariants =& $aItem->getFirstChildByName('variants');
         $r_aVariant = $aVariants->getChildrenByName('variant');
         $variants = array();
         foreach ($r_aVariant as $aVariant) {
             /* @var $aVariant xmlNodeX */
             $variants[] = $aVariant->attribute('id');
         }
         cartAddToCart($productID, $variants, $aItem->getChildData('quantity'), $aItem->getChildData('sample'));
     }
     cartMinimizeCart();
 }
if (isset($_POST["add2cart_x"]) || isset($_POST["add2cart"])) {
    //add product to cart
    $variants = array();
    foreach ($_POST as $key => $val) {
        if (!strstr($key, 'option_')) {
            continue;
        }
        $variants[] = $val;
    }
    $qty = max(1, isset($_POST['product_qty']) ? intval($_POST['product_qty']) : 1);
    if (isset($_GET['sample']) && $_GET['sample'] == 1 || isset($_POST['sample']) && $_POST['sample'] == 1) {
        $sample = 1;
    } else {
        $sample = 0;
    }
    $res = cartAddToCart($productID, $variants, $qty, $sample);
    $Register =& Register::getInstance();
    /*@var $Register Register*/
    if ($res === false) {
        RedirectSQ('?ukey=product_not_found&view=&external=');
    } elseif ($res === 0) {
        RedirectSQ('?ukey=product_out_of_stock&view=&external=');
    } else {
        RedirectSQ('?ukey=cart&view=&external=');
    }
}
// product detailed information view
if (isset($_GET["vote"]) && isset($productID)) {
    //vote for a product
    if (isset($_SESSION["vote_completed"][$productID]) && !$_SESSION["vote_completed"][$productID] && isset($_GET["mark"]) && strlen($_GET["mark"]) > 0) {
        $mark = (double) $_GET["mark"];
Ejemplo n.º 5
0
 $smarty->assign("cart_reguest", $cart_reguest);
 if (isset($_GET["make_more_exact_cart_content"])) {
     $smarty->assign("make_more_exact_cart_content", 1);
 }
 //add product to cart with productID=$add
 if (isset($_GET["add2cart"]) && $_GET["add2cart"] > 0) {
     if (isset($_SESSION["variants"])) {
         $variants = $_SESSION["variants"];
         unset($_SESSION["variants"]);
         session_unregister("variants");
         //calling session_unregister() is required since unset() may not work on some systems
     } else {
         $variants = array();
     }
     for ($mcn = 0; $mcn < $_GET["multyaddcount"]; $mcn++) {
         cartAddToCart($_GET["add2cart"], $variants);
     }
     Redirect($cart_reguest . "&shopping_cart=yes");
 }
 if (isset($_GET["remove"])) {
     //remove from cart product with productID == $remove
     if (isset($_SESSION["log"])) {
         $sql = '
             DELETE
             FROM ' . SHOPPING_CARTS_TABLE . '
             WHERE customerID=' . regGetIdByLogin($_SESSION['log']) . ' AND itemID=' . (int) $_GET['remove'];
         db_query($sql);
         db_query("DELETE FROM " . SHOPPING_CART_ITEMS_TABLE . " where itemID=" . (int) $_GET["remove"]);
         db_query("DELETE FROM " . SHOPPING_CART_ITEMS_CONTENT_TABLE . " where itemID=" . (int) $_GET["remove"]);
         db_query("DELETE FROM " . ORDERED_CARTS_TABLE . " where itemID=" . (int) $_GET["remove"]);
     } else {
Ejemplo n.º 6
0
Archivo: cart.php Proyecto: gblok/rsc
     }
 }
 unset($_SESSION["variants"]);
 $_SESSION["variants"] = $variants;
 //add product to cart with productID=$add
 if (isset($_GET["addproduct"]) && (int) $_GET["addproduct"] > 0) {
     if (isset($_SESSION["variants"])) {
         $variants = $_SESSION["variants"];
         unset($_SESSION["variants"]);
         session_unregister("variants");
         //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"];
Ejemplo n.º 7
0
Archivo: crt.php Proyecto: gblok/rsc
<?php

if (isset($_GET["do"]) && $_GET["do"] === 'crt') {
    $id = (int) $_GET['id'];
    $qty = (int) $_GET['qty'];
    if (!empty($id)) {
        if (empty($qty)) {
            $qty = 1;
        }
        for ($i = 0; $i < $qty; $i++) {
            cartAddToCart($id, array());
        }
        $cart = cartGetCartContent();
        if (!empty($cart['cart_content'])) {
            $qty = 0;
            foreach ($cart['cart_content'] as $k => $v) {
                $qty += $v['quantity'];
            }
            $_SESSION['special_set']['cart'][] = $id;
        }
        $response = array('sc_qty' => (int) $qty, 'sc_val' => show_price($cart['total_price']));
        echo json_encode($response);
    }
    exit;
}