コード例 #1
0
/**
 * Add to cart product with options
 *
 * @param int $productID
 * @param array $variants  - row is variantID
 * @param int $qty
 */
function cartAddToCart($productID, $variants, $qty = 1, $sample = 0)
{
    if ($qty === '') {
        $qty = 1;
    }
    $qty = max(0, intval($qty));
    $productID = intval($productID);
    $product_data = GetProduct($productID);
    if (!$product_data['ordering_available']) {
        return false;
    }
    if (!$product_data['enabled']) {
        return false;
    }
    $is = intval($product_data['in_stock']);
    $min_order_amount = $product_data['min_order_amount'];
    //$min_order_amount = db_phquery_fetch(DBRFETCH_FIRST, "SELECT min_order_amount FROM ?#PRODUCTS_TABLE WHERE productID=?", $productID );
    if (!isset($_SESSION["log"])) {
        //save shopping cart in the session variables
        //$_SESSION["gids"] contains product IDs
        //$_SESSION["counts"] contains product quantities
        //($_SESSION["counts"][$i] corresponds to $_SESSION["gids"][$i])
        //$_SESSION["configurations"] contains variants
        //$_SESSION[gids][$i] == 0 means $i-element is 'empty'
        if (!isset($_SESSION["gids"])) {
            $_SESSION["gids"] = array();
            $_SESSION["counts"] = array();
            $_SESSION["configurations"] = array();
            $_SESSION["sample"] = array();
        }
        //check for current item in the current shopping cart content
        $item_index = SearchConfigurationInSessionVariable($variants, $productID);
        if ($item_index != -1) {
            //increase current product's quantity
            /*if($_SESSION["counts"][$item_index]+$qty<$min_order_amount){
            	 $qty=$min_order_amount-$_SESSION["counts"][$item_index];
            	 }*/
            //$qty = max($qty,$min_order_amount - $_SESSION["counts"][$item_index],0);
            if (CONF_CHECKSTOCK != 0) {
                $qty = min($qty, $is - $_SESSION["counts"][$item_index]);
            }
            $qty = max($qty, 0);
            $_SESSION["sample"][$item_index] = $sample;
            if (CONF_CHECKSTOCK == 0 || $_SESSION["counts"][$item_index] + $qty <= $is && $is && $qty) {
                if ($sample) {
                    $_SESSION["counts"][$item_index] = 1;
                } else {
                    $_SESSION["counts"][$item_index] += $qty;
                }
            } else {
                return $_SESSION["counts"][$item_index];
            }
        } else {
            //no item - add it to $gids array
            $qty = max($qty, $min_order_amount, 0);
            if (CONF_CHECKSTOCK != 0) {
                $qty = min($qty, $is);
            }
            $qty = max($qty, 0);
            if ($sample) {
                $qty = 1;
            }
            $_SESSION["sample"][] = $sample;
            if (CONF_CHECKSTOCK == 0 || $is >= $qty && $qty) {
                $_SESSION["gids"][] = $productID;
                $_SESSION["counts"][] = $qty;
                $_SESSION["configurations"][] = $variants;
                cartUpdateAddCounter($productID);
            } else {
                return 0;
            }
        }
    } else {
        //authorized customer - get cart from database
        $itemID = SearchConfigurationInDataBase($variants, $productID);
        $customerEntry = Customer::getAuthedInstance();
        if (is_null($customerEntry)) {
            return false;
        }
        if ($itemID != -1) {
            // if this configuration exists in database
            $quantity = db_phquery_fetch(DBRFETCH_FIRST, "SELECT Quantity FROM ?#SHOPPING_CARTS_TABLE WHERE customerID=? AND itemID=?", $customerEntry->customerID, $itemID);
            /*if($quantity+$qty<$min_order_amount){
            	 $qty=$min_order_amount-$quantity;
            	 }*/
            //$qty = max($qty,$min_order_amount - $quantity);
            if (CONF_CHECKSTOCK != 0) {
                $qty = min($qty, $is - $quantity);
            }
            $qty = max($qty, 0);
            if (CONF_CHECKSTOCK == 0 || $quantity + $qty <= $is && $is) {
                if ($sample) {
                    db_phquery("UPDATE ?#SHOPPING_CARTS_TABLE SET Quantity=?, sample=? WHERE customerID=? AND itemID=?", 1, $sample, $customerEntry->customerID, $itemID);
                } else {
                    db_phquery("UPDATE ?#SHOPPING_CARTS_TABLE SET Quantity=?, sample=? WHERE customerID=? AND itemID=?", $quantity + $qty, $sample, $customerEntry->customerID, $itemID);
                }
            } else {
                return $quantity;
            }
        } else {
            //insert new item
            $qty = max($qty, $min_order_amount);
            if (CONF_CHECKSTOCK != 0 && $qty > $is) {
                $qty = min($qty, $is);
            }
            if ($sample) {
                $qty = 1;
            }
            if ((CONF_CHECKSTOCK == 0 || $is >= $qty) && $qty > 0) {
                $itemID = InsertNewItem($variants, $productID);
                InsertItemIntoCart($itemID);
                if ($sample) {
                    db_phquery("UPDATE ?#SHOPPING_CARTS_TABLE SET Quantity=?, sample=? WHERE customerID=? AND itemID=?", 1, $sample, $customerEntry->customerID, $itemID);
                } else {
                    db_phquery("UPDATE ?#SHOPPING_CARTS_TABLE SET Quantity=?, sample=? WHERE customerID=? AND itemID=?", $qty, $sample, $customerEntry->customerID, $itemID);
                }
                cartUpdateAddCounter($productID);
            } else {
                return 0;
            }
        }
    }
    //db_phquery("UPDATE ?#PRODUCTS_TABLE SET add2cart_counter=(add2cart_counter+1) WHERE productID=?",$productID);
    return true;
}
コード例 #2
0
include '../../includes/classes/log.class.php';
include '../../includes/classes/category.tree.class.php';
$log = new log();
$action = $_REQUEST['act'];
$error = '';
$data = '';
$user_id = $_COOKIE['USERID'];
$_log = Logger::instance('../../log/view/catalog/', Logger::OFF);
switch ($action) {
    case 'get_add_page':
        $page = GetPage();
        $data = array('page' => $page);
        break;
    case 'get_edit_page':
        $prod_id = $_REQUEST['id'];
        $page = GetPage(GetProduct($prod_id));
        $data = array('page' => $page);
        break;
    case 'get_list':
        $count = $_REQUEST['count'];
        $hidden = $_REQUEST['hidden'];
        $rResult = mysql_query("SELECT \t\t`PR`.`id`,\r\n\t\t\t\t\t\t\t\t\t\t\t`PR`.`code`,\r\n\t\t\t\t\t\t\t\t\t\t\t`PR`.`name`,\r\n\t\t\t\t\t\t\t\t\t\t\t`UN`.`name`,\r\n\t\t\t\t\t\t\t\t\t\t\t`CAT`.`name`,\r\n\t\t\t\t\t\t\t\t\t\t\t`PR`.`comment`\r\n\t\t\t\t\t\t\t\tFROM \t\t`production` AS `PR`\r\n\t\t\t\t\t\t\t\tLEFT JOIN \t`production_category` AS `CAT` ON `PR`.`category` = `CAT`.`id`\r\n\t\t\t\t\t\t\t\tLEFT JOIN \t`production_unit` AS `UN`  ON `PR`.`unit` = `UN`.`id`\r\n\t    \t\t\t\t\t\tWHERE\t\t`PR`.`actived` = 1");
        $data = array("aaData" => array());
        while ($aRow = mysql_fetch_array($rResult)) {
            $row = array();
            for ($i = 0; $i < $count; $i++) {
                /* General output */
                $row[] = $aRow[$i];
                if ($i == $count - 1) {
                    $row[] = '<input type="checkbox" name="check_' . $aRow[$hidden] . '" class="check" value="' . $aRow[$hidden] . '" />';
                }
コード例 #3
0
ファイル: order_functions.php プロジェクト: gblok/rsc
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;
}
コード例 #4
0
ファイル: admin.php プロジェクト: gblok/rsc
 if (isset($_POST["AddProductAndOpenConfigurator"])) {
     if ($_POST["AddProductAndOpenConfigurator"] == 1) {
         if (CONF_BACKEND_SAFEMODE) {
             //this action is forbidden when SAFE MODE is ON
             Redirect(ADMIN_FILE . "?safemode=yes&productID=" . $_GET["productID"] . "&eaction=prod");
         }
         $productID = AddProduct($_POST["categoryID"], $_POST["name"], $_POST["price"], $_POST["description"], $_POST["in_stock"], $_POST["brief_description"], $_POST["list_price"], $_POST["product_code"], $_POST["sort_order"], isset($_POST["ProductIsProgram"]), "eproduct_filename", $_POST["eproduct_available_days"], $_POST["eproduct_download_times"], $_POST["weight"], $_POST["meta_description"], $_POST["meta_keywords"], isset($_POST["free_shipping"]), $_POST["min_order_amount"], $_POST["shipping_freight"], $_POST["tax_class"], $_POST["currencyID"], $_POST["opt_margin"], $_POST["sef"], $_POST["title"]);
         $_GET["productID"] = $productID;
         $updatedValues = ScanPostVariableWithId(array("option_value", "option_radio_type"));
         configUpdateOptionValue($productID, $updatedValues);
         OpenConfigurator($_POST["optionID"], $productID);
     }
 }
 // show product
 if ($_GET["productID"] != 0) {
     $product = GetProduct($_GET["productID"]);
     $product["description"] = html_spchars($product["description"]);
     $product["brief_description"] = html_spchars($product["brief_description"]);
     $product["sef"] = html_spchars($product["sef"]);
     if (!$product["title"]) {
         $product["title"] = "";
     }
     $title = ADMIN_PRODUCT_EDITN;
 } else {
     $product = array();
     $title = ADMIN_PRODUCT_NEW;
     $cat = isset($_GET["categoryID"]) ? $_GET["categoryID"] : 0;
     $product["categoryID"] = $cat;
     $product["name"] = "";
     $product["title"] = "";
     $product["description"] = "";
コード例 #5
0
ファイル: product_detailed.php プロジェクト: gblok/rsc
            }
            unset($_SESSION['captcha_keystring']);
            if ($error_p == 1) {
                xMailTxtHTML(CONF_GENERAL_EMAIL, $message_subject, $message_text, $customer_email, $customer_name);
                Redirect("index.php?productID=" . $productID . "&sent=yes");
            }
        } else {
            xMailTxtHTML(CONF_GENERAL_EMAIL, $message_subject, $message_text, $customer_email, $customer_name);
            Redirect("index.php?productID=" . $productID . "&sent=yes");
        }
    } else if (isset($_POST["request_information"]))
        $smarty->assign("error", 1);
}*/
//show product information
if (isset($productID) && $productID > 0 && !isset($_POST["add_topic"]) && !isset($_POST["discuss"])) {
    $product = GetProduct($productID);
    if (!$product || $product["enabled"] == 0) {
        header("HTTP/1.0 404 Not Found");
        header("HTTP/1.1 404 Not Found");
        header("Status: 404 Not Found");
        die(ERROR_404_HTML);
    } else {
        if (!isset($_GET["vote"])) {
            IncrementProductViewedTimes($productID);
        }
        $dontshowcategory = 1;
        $smarty->assign("main_content_template", "product_detailed.tpl");
        $a = $product;
        if ((double) $a["shipping_freight"] > 0) {
            $a["shipping_freightUC"] = show_price($a["shipping_freight"]);
        }
コード例 #6
0
function _importProduct($row, $dbc, $identity_column, $dbcPhotos, $updated_extra_option, $currentCategoryID)
{
    $row["not defined"] = "";
    $row[$identity_column] = trim($row[$identity_column]);
    //search for product within current category
    $q = db_query("select productID, categoryID, customers_rating  from " . PRODUCTS_TABLE . " where categoryID=" . (int) $currentCategoryID . " and " . xEscSQL($_POST["update_column"]) . " LIKE '" . xEscSQL(trim($row[$identity_column])) . "'");
    $rowdb = db_fetch_row($q);
    if (!$rowdb && $_POST["update_column"] == 'product_code') {
        //not found
        //search for product in all categories
        $q = db_query("select productID, categoryID, customers_rating  from " . PRODUCTS_TABLE . " where " . xEscSQL($_POST["update_column"]) . " LIKE '" . xEscSQL(trim($row[$identity_column])) . "'");
        $rowdb = db_fetch_row($q);
    }
    $currency = $_POST['currencyISO'] ? $_POST['currencyISO'] : CONF_DEFAULT_CURRENCY;
    if (strcmp($dbc['ISO'], "not defined")) {
        $currencyID = getCurrencyID($row[$dbc['ISO']]);
        $currency = $currencyID ? $currencyID : $currency;
    }
    if ($rowdb) {
        //update product info
        $productID = $rowdb["productID"];
        $rowdb = GetProduct($productID);
        if (strcmp($dbc["Price"], "not defined")) {
            $Price = $row[$dbc["Price"]];
            $Price = str_replace(" ", "", $Price);
            $Price = str_replace(",", ".", $Price);
            $Price = (double) $Price;
        } else {
            $Price = $rowdb["Price_admin"];
        }
        if (strcmp($dbc["list_price"], "not defined")) {
            $list_price = $row[$dbc["list_price"]];
            $list_price = str_replace(" ", "", $list_price);
            $list_price = str_replace(",", ".", $list_price);
            $list_price = (double) $list_price;
        } else {
            $list_price = $rowdb["list_price_base"];
        }
        if (strcmp($dbc["sort_order"], "not defined")) {
            $sort_order = (int) $row[$dbc["sort_order"]];
        } else {
            $sort_order = $rowdb["sort_order"];
        }
        if (strcmp($dbc["in_stock"], "not defined")) {
            $in_stock = (int) $row[$dbc["in_stock"]];
        } else {
            $in_stock = $rowdb["in_stock"];
        }
        if (strcmp($dbc["eproduct_filename"], "not defined")) {
            $eproduct_filename = $row[$dbc["eproduct_filename"]];
        } else {
            $eproduct_filename = $rowdb["eproduct_filename"];
        }
        if (strcmp($dbc["eproduct_available_days"], "not defined")) {
            $eproduct_available_days = (int) $row[$dbc["eproduct_available_days"]];
        } else {
            $eproduct_available_days = $rowdb["eproduct_available_days"];
        }
        if (strcmp($dbc["eproduct_download_times"], "not defined")) {
            $eproduct_download_times = (int) $row[$dbc["eproduct_download_times"]];
        } else {
            $eproduct_download_times = $rowdb["eproduct_download_times"];
        }
        if (strcmp($dbc["weight"], "not defined")) {
            $weight = (double) $row[$dbc["weight"]];
        } else {
            $weight = $rowdb["weight"];
        }
        if (strcmp($dbc["free_shipping"], "not defined")) {
            $free_shipping = trim($row[$dbc["free_shipping"]]) == "+" ? 1 : 0;
        } else {
            $free_shipping = $rowdb["free_shipping"];
        }
        if (strcmp($dbc["min_order_amount"], "not defined")) {
            $min_order_amount = (int) $row[$dbc["min_order_amount"]];
        } else {
            $min_order_amount = $rowdb["min_order_amount"];
        }
        if (strcmp($dbc["shipping_freight"], "not defined")) {
            $shipping_freight = (double) $row[$dbc["shipping_freight"]];
        } else {
            $shipping_freight = $rowdb["shipping_freight"];
        }
        if (strcmp($dbc["description"], "not defined")) {
            $description = $row[$dbc["description"]];
        } else {
            $description = $rowdb["description"];
        }
        if (strcmp($dbc["brief_description"], "not defined")) {
            $brief_description = $row[$dbc["brief_description"]];
        } else {
            $brief_description = $rowdb["brief_description"];
        }
        if (strcmp($dbc["product_code"], "not defined")) {
            $product_code = $row[$dbc["product_code"]];
        } else {
            $product_code = xHtmlSpecialCharsDecode($rowdb["product_code"]);
        }
        if (strcmp($dbc["meta_description"], "not defined")) {
            $meta_description = $row[$dbc["meta_description"]];
        } else {
            $meta_description = xHtmlSpecialCharsDecode($rowdb["meta_description"]);
        }
        if (strcmp($dbc["meta_keywords"], "not defined")) {
            $meta_keywords = $row[$dbc["meta_keywords"]];
        } else {
            $meta_keywords = xHtmlSpecialCharsDecode($rowdb["meta_keywords"]);
        }
        if (strcmp($dbc["name"], "not defined")) {
            $name = $row[$dbc["name"]];
        } else {
            $name = xHtmlSpecialCharsDecode($rowdb["name"]);
        }
        if (strcmp($dbc["title"], "not defined")) {
            $title = $row[$dbc["title"]];
        } else {
            $title = xHtmlSpecialCharsDecode($rowdb["title"]);
        }
        if (strcmp($dbc["sef"], "not defined")) {
            $sef = $row[$dbc["sef"]];
        } else {
            $sef = xHtmlSpecialCharsDecode($rowdb["sef"]);
        }
        $opt_margin = $rowdb["opt_margin"];
        $categoryID = $rowdb["categoryID"];
        $customers_rating = $rowdb["customers_rating"];
        $ProductIsProgram = trim($eproduct_filename) != "";
        UpdateProduct($productID, $categoryID, $name, $Price, $description, $in_stock, $customers_rating, $brief_description, $list_price, $product_code, $sort_order, $ProductIsProgram, "", $eproduct_available_days, $eproduct_download_times, $weight, $meta_description, $meta_keywords, $free_shipping, $min_order_amount, $shipping_freight, null, $currency, $opt_margin, $sef, $title, 0);
    } else {
        // add new product
        $Price = 0.0;
        $list_price = 0.0;
        $sort_order = 0;
        $in_stock = 0;
        $eproduct_filename = "";
        $eproduct_available_days = 0;
        $eproduct_download_times = 0;
        $weight = 0.0;
        $free_shipping = 0;
        $min_order_amount = 1;
        $shipping_freight = 0.0;
        if (strcmp($dbc["Price"], "not defined")) {
            $Price = (double) $row[$dbc["Price"]];
        }
        if (strcmp($dbc["list_price"], "not defined")) {
            $list_price = (double) $row[$dbc["list_price"]];
        }
        if (strcmp($dbc["sort_order"], "not defined")) {
            $sort_order = (int) $row[$dbc["sort_order"]];
        }
        if (strcmp($dbc["in_stock"], "not defined")) {
            $in_stock = (int) $row[$dbc["in_stock"]];
        }
        if (strcmp($dbc["eproduct_filename"], "not defined")) {
            $eproduct_filename = $row[$dbc["eproduct_filename"]];
        }
        if (strcmp($dbc["eproduct_available_days"], "not defined")) {
            $eproduct_available_days = (int) $row[$dbc["eproduct_available_days"]];
        }
        if (strcmp($dbc["eproduct_download_times"], "not defined")) {
            $eproduct_download_times = (int) $row[$dbc["eproduct_download_times"]];
        }
        if (strcmp($dbc["weight"], "not defined")) {
            $weight = (double) $row[$dbc["weight"]];
        }
        if (strcmp($dbc["free_shipping"], "not defined")) {
            $free_shipping = trim($row[$dbc["free_shipping"]]) == "+" ? 1 : 0;
        }
        if (strcmp($dbc["min_order_amount"], "not defined")) {
            $min_order_amount = (int) $row[$dbc["min_order_amount"]];
        }
        if (strcmp($dbc["shipping_freight"], "not defined")) {
            $shipping_freight = (double) $row[$dbc["shipping_freight"]];
        }
        $ProductIsProgram = trim($row[$dbc["eproduct_filename"]]) != "";
        $sef = $row[$dbc["sef"]];
        $productID = AddProduct($currentCategoryID, $row[$dbc["name"]], $Price, $row[$dbc["description"]], $in_stock, $row[$dbc["brief_description"]], $list_price, $row[$dbc["product_code"]], $sort_order, $ProductIsProgram, "", $eproduct_available_days, $eproduct_download_times, $weight, $row[$dbc["meta_description"]], $row[$dbc["meta_keywords"]], $free_shipping, $min_order_amount, $shipping_freight, CONF_DEFAULT_TAX_CLASS, $currency, 1, $sef, $row[$dbc["title"]], 0);
    }
    if (strlen($eproduct_filename)) {
        SetProductFile($productID, $eproduct_filename);
    }
    _importExtraOptionValues($row, $productID, $updated_extra_option);
    if (count($dbcPhotos) > 0) {
        _importProductPictures($row, $dbcPhotos, $productID);
    }
    if (!empty($sef)) {
        fu_generate_product($productID, $sef);
    }
}
コード例 #7
0
 /**
  * Emulate cartGetCartContent function not fully: doesnt fill feight_cost
  *
  * @return array: (cart_content, total_price, freight_cost)
  */
 function emulate_cartGetCartContent()
 {
     $cart_content = array();
     $freight_cost = 0;
     $r_aItem = $this->Items->getChildNodes('item');
     foreach ($r_aItem as $aItem) {
         /* @var $aItem xmlNodeX */
         $aProduct =& $aItem->getFirstChildByName('product');
         $aPrice =& $aItem->getFirstChildByName('price');
         $product = GetProduct($aProduct->attribute('id'));
         $strOptions = GetStrOptions($this->emulate_GetConfigurationByItemId($aItem));
         if (trim($strOptions) != '') {
             $product['name'] .= '  (' . $strOptions . ')';
         }
         $sample = $aItem->getChildData('sample');
         if ($sample == 1) {
             $product['name'] .= " [SAMPLE]";
             $q_sample_price = db_phquery('SELECT sample_price FROM SC_categories WHERE categoryID=(SELECT categoryID FROM SC_products WHERE productID=?)', $aProduct->attribute('id'));
             $sample_price = db_fetch_assoc($q_sample_price);
             $costUC = $sample_price["sample_price"];
             $quantity = 1;
             $cost = show_price($quantity * PaymentModule::_convertCurrency($costUC, $aPrice->attribute('currency'), 0), 0);
             $free_shipping = 1;
         } else {
             $costUC = $aPrice->getData();
             $cost = show_price($aItem->getChildData('quantity') * PaymentModule::_convertCurrency($aPrice->getData(), $aPrice->attribute('currency'), 0), 0);
             $quantity = $aItem->getChildData('quantity');
             $free_shipping = $aProduct->attribute('free-shipping');
         }
         $cart_content[] = array('productID' => $aProduct->attribute('id'), 'id' => $aItem->attribute('id') ? $aItem->attribute('id') : 0, 'name' => $product['name'], 'quantity' => $quantity, 'free_shipping' => $free_shipping, 'costUC' => $costUC, 'cost' => $cost, 'product_code' => $product['product_code']);
         $aFreight = $aProduct->getFirstChildByName('freight');
         if (!is_null($aFreight)) {
             $freight_cost += $aItem->getChildData('quantity') * virtualModule::_convertCurrency($aFreight->getData(), $aFreight->attribute('currency'), 0);
         }
     }
     $cart = array('cart_content' => $cart_content, 'total_price' => $this->calculateTotalPrice(), 'freight_cost' => $freight_cost);
     return $cart;
 }
 function _getOrderWeight(&$Order)
 {
     $TC = count($Order['orderContent']['cart_content']);
     $OrderWeight = 0;
     $ShippingProducts = 0;
     for ($i = 0; $i < $TC; $i++) {
         $Product = GetProduct($Order['orderContent']['cart_content'][$i]['productID']);
         if ($Order['orderContent']['cart_content'][$i]['free_shipping']) {
             continue;
         }
         $ShippingProducts++;
         if (!isset($Product['weight'])) {
             continue;
         }
         if (!$Product['weight']) {
             continue;
         }
         $OrderWeight += $Order['orderContent']['cart_content'][$i]['quantity'] * $Product['weight'];
     }
     if ($OrderWeight <= 0 && $ShippingProducts) {
         $OrderWeight = 0.1;
     }
     return $OrderWeight;
 }
コード例 #9
0
 function _getOrderpSumm(&$Order)
 {
     $TC = count($Order['orderContent']['cart_content']);
     $OrderpSumm = 0;
     $ShippingProducts = 0;
     for ($i = 0; $i < $TC; $i++) {
         $Product = GetProduct($Order['orderContent']['cart_content'][$i]['productID']);
         if ($Product['free_shipping']) {
             continue;
         }
         $ShippingProducts++;
         $OrderpSumm += $Order['orderContent']['cart_content'][$i]['quantity'] * $Order['orderContent']['cart_content'][$i]['costUC'];
     }
     return $OrderpSumm;
 }
コード例 #10
0
 function main()
 {
     $Register =& Register::getInstance();
     $smarty =& $Register->get(VAR_SMARTY);
     /*@var $smarty Smarty*/
     // shopping cart
     //iframe cookie security workaround
     if (isset($_GET['check_cookie'])) {
         if ($_GET['check_cookie'] != session_id()) {
             $productID = (int) $_GET['productID'];
             $product_data = GetProduct($productID);
             $product_slug = $product_data && isset($product_data['slug']) ? $product_data['slug'] : '';
             $url = "?ukey=product_widget&productID={$productID}&product_slug={$product_slug}&check_cookie&";
             $widgets = false;
             $Register->set('widgets', $widgets);
             $_SERVER['REQUEST_URI'] = preg_replace('/(^|&)widgets=1/', '', $_SERVER['REQUEST_URI']);
             RedirectSQ($url);
         } else {
             renderURL('check_cookie&productID', '', true);
         }
     }
     if (isset($_GET["make_more_exact_cart_content"])) {
         $smarty->assign("make_more_exact_cart_content", 1);
     }
     if (isset($_GET["remove"]) && $_GET["remove"] > 0) {
         //remove from cart product with productID == $remove
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $cartEntry->setItemQuantity($_GET['remove'], 0);
         $cartEntry->saveCurrentCart();
         if ($cartEntry->isEmpty()) {
             //remove coupon from empty cart
             ClassManager::includeClass('discount_coupon');
             discount_coupon::remove();
         }
         RedirectSQ('remove=');
     }
     $cart_view = $this->_detect_cart_view();
     if (isset($_POST["update"]) || isset($_POST["recalculate"])) {
         //update shopping cart content
         if ($_POST['discount_coupon_code'] != '') {
             $this->_check_and_apply_coupon($_POST['discount_coupon_code']);
         }
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $upd_data = scanArrayKeysForID($_POST, 'count');
         foreach ($upd_data as $_itemID => $_data) {
             $cartEntry->setItemQuantity($_itemID, intval($_data['count']));
         }
         $cartEntry->saveCurrentCart();
         if ($cartEntry->isEmpty()) {
             //remove coupon from empty cart
             ClassManager::includeClass('discount_coupon');
             discount_coupon::remove();
         }
         if (cartCheckMinOrderAmount() && cartCheckMinTotalOrderAmount()) {
             switch ($cart_view) {
                 case CARTVIEW_FRAME:
                     if (isset($_POST['checkout']) && $Register->get('store_mode') == 'facebook') {
                         $store_mode = false;
                         $Register->set('store_mode', $store_mode);
                         $jsgoto = '?ukey=checkout&view=noframe';
                         RedirectSQ($jsgoto ? 'jsgoto=' . base64_encode(set_query($jsgoto)) : '');
                     }
                     RedirectSQ(isset($_POST['checkout']) ? '?ukey=checkout' : (isset($_POST['ppe_checkout_x']) ? 'ppexpresscheckout2=1' : (isset($_POST['google_checkout_x']) ? 'googlecheckout2=1' : '')));
                     break;
                 case CARTVIEW_WIDGET:
                 case CARTVIEW_FADE:
                     $jsgoto = isset($_POST['checkout']) ? '?ukey=checkout&view=noframe' : (isset($_POST['ppe_checkout_x']) ? 'ppexpresscheckout2=1&view=frame' : (isset($_POST['google_checkout_x']) ? 'googlecheckout2=1&view=frame' : ''));
                     RedirectSQ($jsgoto ? 'jsgoto=' . base64_encode(set_query($jsgoto)) : '');
                     break;
             }
         } elseif (isset($_POST['checkout']) || isset($_POST['google_checkout_x']) || isset($_POST['ppe_checkout_x'])) {
             $smarty->assign('cart_error_show', '1');
         }
     }
     if (isset($_GET["clear_cart"])) {
         //completely clear shopping cart
         $cartEntry = new ShoppingCart();
         $cartEntry->loadCurrentCart();
         $cartEntry->cleanCurrentCart('erase');
         //remove coupon from empty cart
         ClassManager::includeClass('discount_coupon');
         discount_coupon::remove();
         RedirectSQ('clear_cart=');
     }
     if (isset($_POST['checkout'])) {
         if (SystemSettings::is_hosted() && file_exists(WBS_DIR . '/kernel/classes/class.metric.php')) {
             include_once WBS_DIR . '/kernel/classes/class.metric.php';
             $DB_KEY = SystemSettings::get('DB_KEY');
             $U_ID = sc_getSessionData('U_ID');
             $metric = metric::getInstance();
             $metric->addAction($DB_KEY, $U_ID, 'SC', 'CHECKOUT', isset($_GET['widgets']) ? 'WIDGET' : 'STOREFRONT', '');
         }
     }
     $resCart = cartGetCartContent();
     $resDiscount = dscGetCartDiscounts($resCart["total_price"], isset($_SESSION["log"]) ? $_SESSION["log"] : "");
     $currencyEntry = Currency::getSelectedCurrencyInstance();
     $cart_discount_show = $resDiscount['other_discounts']['cu'] > 0 ? $currencyEntry->getView($resDiscount['other_discounts']['cu']) : '';
     $coupon_discount_show = $resDiscount['coupon_discount']['cu'] > 0 ? $currencyEntry->getView($resDiscount['coupon_discount']['cu']) : '';
     $smarty->assign("cart_content", xHtmlSpecialChars($resCart["cart_content"], null, 'name'));
     $smarty->assign("cart_amount", $resCart["total_price"] - $resDiscount["discount_standart_unit"]);
     $smarty->assign('cart_min', show_price(CONF_MINIMAL_ORDER_AMOUNT));
     $smarty->assign("cart_total", $currencyEntry->getView($resDiscount['total']['cu']));
     $smarty->assign('cart_discount', $cart_discount_show);
     $smarty->assign('discount_percent', round($resDiscount['discount_percent'], 1));
     $smarty->assign('coupon_discount', $coupon_discount_show);
     $smarty->assign("current_coupon", discount_coupon::getCurrentCoupon());
     if (isset($_SESSION['log'])) {
         $smarty->assign('shippingAddressID', regGetDefaultAddressIDByLogin($_SESSION['log']));
     }
     if (isset($_GET['min_order'])) {
         $smarty->assign('minOrder', 'error');
     }
     if (isset($_GET['jsgoto'])) {
         $smarty->assign('jsgoto', base64_decode($_GET['jsgoto']));
     }
     $smarty->assign('main_content_template', 'shopping_cart.html');
     $smarty->assign('main_body_style', 'style="' . (CONF_SHOPPING_CART_VIEW == 2 || $cart_view == CARTVIEW_FRAME ? '' : 'background:#FFFFFF;') . 'min-width:auto;width:auto;_width:auto;"');
 }