Beispiel #1
0
 public static function isBarCodeValid($arParams)
 {
     $bResult = false;
     $arBasket = array();
     if (intval($arParams["basketItemId"]) > 0) {
         $dbBasket = CSaleBasket::GetList(array("ID" => "DESC"), array("ID" => $arParams["basketItemId"]), false, false, array("ID", "PRODUCT_ID", "PRODUCT_PROVIDER_CLASS", "MODULE", "BARCODE_MULTI"));
         $arBasket = $dbBasket->GetNext();
     } else {
         $arBasket = array("PRODUCT_PROVIDER_CLASS" => $arParams["productProvider"], "MODULE" => $arParams["moduleName"], "PRODUCT_ID" => $arParams["productId"], "BARCODE_MULTI" => $arParams["barcodeMult"]);
     }
     if (!empty($arBasket) && is_array($arBasket)) {
         /** @var $productProvider IBXSaleProductProvider */
         if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
             $arCheckBarcodeFields = array("BARCODE" => $arParams["barcode"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "ORDER_ID" => $arParams["orderId"]);
             if ($arBasket["BARCODE_MULTI"] == "Y") {
                 $arCheckBarcodeFields["STORE_ID"] = $arParams["storeId"];
             }
             $res = $productProvider::CheckProductBarcode($arCheckBarcodeFields);
             if ($res) {
                 $bResult = true;
             }
         }
     }
     return $bResult;
 }
Beispiel #2
0
function GetBasketList($bSkipFUserInit = true)
{
    $fUserID = (int) CSaleBasket::GetBasketUserID($bSkipFUserInit);
    $arRes = array();
    if ($fUserID > 0) {
        $basketID = array();
        $db_res = CSaleBasket::GetList(array(), array("FUSER_ID" => $fUserID, "LID" => SITE_ID, "ORDER_ID" => false), false, false, array('ID', 'CALLBACK_FUNC', 'PRODUCT_PROVIDER_CLASS', 'MODULE', 'PRODUCT_ID', 'QUANTITY', 'NOTES'));
        while ($res = $db_res->Fetch()) {
            $res['CALLBACK_FUNC'] = (string) $res['CALLBACK_FUNC'];
            $res['PRODUCT_PROVIDER_CLASS'] = (string) $res['PRODUCT_PROVIDER_CLASS'];
            if ($res['CALLBACK_FUNC'] != '' || $res['PRODUCT_PROVIDER_CLASS'] != '') {
                CSaleBasket::UpdatePrice($res["ID"], $res["CALLBACK_FUNC"], $res["MODULE"], $res["PRODUCT_ID"], $res["QUANTITY"], 'N', $res["PRODUCT_PROVIDER_CLASS"], $res['NOTES']);
            }
            $basketID[] = $res['ID'];
        }
        unset($res, $db_res);
        if (!empty($basketID)) {
            $basketIterator = CSaleBasket::GetList(array('NAME' => 'ASC'), array('ID' => $basketID));
            while ($basket = $basketIterator->GetNext()) {
                $arRes[] = $basket;
            }
            unset($basket, $basketIterator);
        }
        unset($basketID);
    }
    return $arRes;
}
Beispiel #3
0
    /**
     *
    * return array() BasketList - experation - Send Order
    **/
    public static function OrderBasket($experation = NULL,$sort = array("ID" => "ASC"), $limit = NULL){
        global $DB;
        $arItems = array();
        if(! $experation){
            $experation = 30*24*60*60;
        }
        $time = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL", SITE_ID)), time() - $experation);
        $arPages = false;
        if(! empty($limit)){
            $arPages = array('nTopCount' =>  $limit);
        }
        $arFilter = array('>=DATE_UPDATE' => $time,
                          "ORDER_ID" => true,
                          "CAN_BUY" => "Y");
        $arSelect = array("ID", "USER_ID", "PRODUCT_ID", "CAN_BUY", "DELAY", "SUBSCRIBE", "QUANTITY","DATE_UPDATE","DETAIL_PAGE_URL");
        $dbBasketList = CSaleBasket::GetList(
				$sort,
				$arFilter,
				false,
				$arPages,
				$arSelect
			);
			while($_arItems = $dbBasketList->Fetch()){
				$arItems[] = $_arItems;
			}
        return $arItems;
    }
Beispiel #4
0
    function AddGoogleAnaliticsEcommerceCode($orderId, $arOrder, $arParams){

        global $APPLICATION;

        if(isset($_SESSION['GA_ORDER_ID']) && $_SESSION['GA_ORDER_ID'] == $orderId) return;

        $gaOutput = array();

        $arSite = CSite::GetByID($arOrder['LID'])->Fetch();

        $gaOutput[] = "<script>";
        $gaOutput[] = "ga('require', 'ecommerce', 'ecommerce.js');";

        $gaOutput[] = sprintf(
            "ga('ecommerce:addTransaction', {
                'id': '%s',
                'affiliation': '%s',
                'revenue': '%s',
                'shipping': '%s',
                'tax': ''
            });",
            $orderId,
            $arSite['NAME'],
            $arOrder['PRICE'],
            $arOrder['PRICE_DELIVERY']
        );

        $dbBasket = CSaleBasket::GetList(
            array("NAME" => "ASC"),
            array("ORDER_ID" => $orderId)
        );

        while($basketItem = $dbBasket->fetch()){

            $gaOutput[] = sprintf(
                "ga('ecommerce:addItem', {
                    'id': '%s',
                    'name': '%s',
                    'sku': '%s',
                    'category': '',
                    'price': '%s',
                    'quantity': '%s'
                });",
                $orderId,
                $basketItem['NAME'],
                $basketItem['PRODUCT_ID'],
                $basketItem['PRICE'],
                $basketItem['QUANTITY']
            );

        }

        $gaOutput[] = "ga('ecommerce:send');";
        $gaOutput[] = "</script>";

        $APPLICATION->AddHeadString(implode("\n", $gaOutput), true);

        $_SESSION['GA_ORDER_ID'] = $orderId;

    }
Beispiel #5
0
function getUserDelay ($userId){
    // Получаем список корзины
    $arBasketItems = array();
    $dbBasketItems = CSaleBasket::GetList(
            array(
                    "NAME" => "ASC",
                    "ID" => "ASC"
                ),
            array(
                    "FUSER_ID" =>$userId,
                    "LID" => SITE_ID,
                    "ORDER_ID" => "NULL"
                ),
            false,
            false,
            array("ID", "CALLBACK_FUNC", "MODULE", "NAME", 
                  "PRODUCT_ID", "QUANTITY", "DELAY", 
                  "CAN_BUY", "PRICE", "DATE_INSERT", "DATE_UPDATE")
        );
    while ($arItems = $dbBasketItems->Fetch())
    {
        if (strlen($arItems["CALLBACK_FUNC"]) > 0)
        {
            CSaleBasket::UpdatePrice($arItems["ID"], 
                                     $arItems["CALLBACK_FUNC"], 
                                     $arItems["MODULE"], 
                                     $arItems["PRODUCT_ID"], 
                                     $arItems["QUANTITY"]);
            $arItems = CSaleBasket::GetByID($arItems["ID"]);
        }

        $arBasketItems[] = $arItems;
    }

    // Печатаем массив, содержащий актуальную на текущий момент корзину
   /* echo "<pre>";
    print_r($arBasketItems);
    echo "</pre>"; */ 
    
    $whishlist="";
    foreach ($arBasketItems as $delay){  
        $notBuy="Y"; // флаг для проверки покупался ли данный товар,
       $difference = floor(intval(abs( time() - strtotime($delay[DATE_INSERT]) ))/(3600 * 24));  
        // перебираем отложенные элементы, срок которых менее 30 дней        
        if ($delay["DELAY"]=="Y" && $difference < 30){
            foreach ($arBasketItems as $notDelay){
                //перебираем купленные элементы и сравниваем с отложенными
                if ($notDelay["DELAY"]!="Y" && $delay[PRODUCT_ID]==$notDelay[PRODUCT_ID] && $difference < 30){
                   $notBuy="N";  // товар уже покупался                  
                }                
            }
            if($notBuy=="Y"){
            $whishlist .= ' '.$delay["NAME"].',';    
            }
        }        
    }
    $whishlist = trim($whishlist, ",");
    return  $whishlist;    
}
Beispiel #6
0
 public static function OnBeforeBasketAdd(array $fields)
 {
     if (Loader::includeModule('conversion')) {
         if ($row = \CSaleBasket::GetList(array(), array('LID' => $fields['LID'], 'FUSER_ID' => $fields['FUSER_ID'], 'PRODUCT_ID' => $fields['PRODUCT_ID'], 'ORDER_ID' => 'NULL'), false, false, array('PRICE', 'QUANTITY'))->Fetch()) {
             self::$cartSum = $row['PRICE'] * $row['QUANTITY'];
         } else {
             self::$cartSum = 0;
         }
     }
 }
Beispiel #7
0
 public function addProductToCart(Product $product, $quantity)
 {
     Loader::includeModule('sale');
     $price = reset($product['PRICES']);
     $properties = array();
     foreach ($product->getShopParameters() as $name => $value) {
         $properties[] = array('NAME' => $name, 'VALUE' => $value);
     }
     /** @noinspection PhpDynamicAsStaticMethodCallInspection */
     \CSaleBasket::Add(array('PRODUCT_ID' => $product['ID'], 'PRODUCT_PRICE_ID' => $price['ID'], 'PRICE' => $price['PRICE'], 'CURRENCY' => $price['CURRENCY'], 'QUANTITY' => $quantity, 'LID' => SITE_ID, 'NAME' => $product['NAME'], 'NOTES' => $product['DETAIL_TEXT'], 'PROPS' => $properties));
 }
 /**
  * Returns quantity of product in current user's basket
  *
  * @param integer $productID
  * @return float
  */
 public static function getProductInBasketParams($productID)
 {
     global $DB;
     CModule::IncludeModule('sale');
     $id = intval($productID);
     $fuserID = CSaleBasket::GetBasketUserID();
     $strSql = "SELECT ID, QUANTITY " . "FROM b_sale_basket " . "WHERE PRODUCT_ID = " . $id . " AND FUSER_ID = " . $fuserID . " AND ORDER_ID IS NULL";
     $rsBasket = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($arBasket = $rsBasket->Fetch()) {
         return array("ID" => $arBasket["ID"], "QUANTITY" => floatval($arBasket["QUANTITY"]));
     }
     return false;
 }
Beispiel #9
0
function GetBasketList($_1845591150 = False)
{
    $_485605884 = CSaleBasket::GetBasketUserID($_1845591150);
    $_1557116546 = array();
    if ($_485605884 > 142 * 2 - 284) {
        $_1231685078 = CSaleBasket::$GLOBALS['_____964307792'][3](array(___1555869721(415) => ___1555869721(416)), array(___1555869721(417) => $_485605884, ___1555869721(418) => SITE_ID, ___1555869721(419) => ___1555869721(420)));
        while ($_895052442 = $_1231685078->{$GLOBALS}['_____964307792'][4]()) {
            if ($GLOBALS['____1838596344'][1]($_895052442[___1555869721(421)]) > 1216 / 2 - 608) {
                CSaleBasket::UpdatePrice($_895052442[___1555869721(422)], $_895052442[___1555869721(423)], $_895052442[___1555869721(424)], $_895052442[___1555869721(425)], $_895052442[___1555869721(426)]);
                $_895052442 = CSaleBasket::$GLOBALS['_____964307792'][5]($_895052442[___1555869721(427)]);
            }
            $_1557116546[] = $_895052442;
        }
    }
    return $_1557116546;
}
Beispiel #10
0
function GetBasketList($bSkipFUserInit = False)
{
    $fUserID = CSaleBasket::GetBasketUserID($bSkipFUserInit);
    $arRes = array();
    if ($fUserID > 0) {
        $db_res = CSaleBasket::GetList(array("NAME" => "ASC"), array("FUSER_ID" => $fUserID, "LID" => SITE_ID, "ORDER_ID" => "NULL"));
        while ($res = $db_res->GetNext()) {
            if (strlen($res["CALLBACK_FUNC"]) > 0 || strlen($res["PRODUCT_PROVIDER_CLASS"]) > 0) {
                CSaleBasket::UpdatePrice($res["ID"], $res["CALLBACK_FUNC"], $res["MODULE"], $res["PRODUCT_ID"], $res["QUANTITY"], $res["PRODUCT_PROVIDER_CLASS"]);
                $res = CSaleBasket::GetByID($res["ID"]);
            }
            $arRes[] = $res;
        }
    }
    return $arRes;
}
 public static function onGenerateInitialData(Date $from, Date $to)
 {
     $data = array();
     // 1. Payments
     $result = \CSaleOrder::GetList(array(), array('PAYED' => 'Y', 'CANCELED' => 'N', '>=DATE_PAYED' => $from, '<=DATE_PAYED' => $to), false, false, array('LID', 'DATE_PAYED', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_PAYED']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_payment_add_day'] += 1;
             $counters['sale_payment_sum_add'] += $sum;
         } else {
             $counters = array('sale_payment_add_day' => 1, 'sale_payment_sum_add' => $sum);
         }
     }
     // 2. Orders
     $result = \CSaleOrder::GetList(array(), array('CANCELED' => 'N', '>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_order_add_day'] += 1;
             $counters['sale_order_sum_add'] += $sum;
         } else {
             $counters = array('sale_order_add_day' => 1, 'sale_order_sum_add' => $sum);
         }
     }
     // 3. Cart
     $result = \CSaleBasket::GetList(array(), array('>=DATE_INSERT' => $from, '<=DATE_INSERT' => $to), false, false, array('LID', 'DATE_INSERT', 'PRICE', 'CURRENCY', 'QUANTITY'));
     while ($row = $result->Fetch()) {
         $day = new DateTime($row['DATE_INSERT']);
         $sum = Utils::convertToBaseCurrency($row['PRICE'] * $row['QUANTITY'], $row['CURRENCY']);
         if ($counters =& $data[$row['LID']][$day->format('Y-m-d')]) {
             $counters['sale_cart_add_day'] += 1;
             $counters['sale_cart_sum_add'] += $sum;
         } else {
             $counters = array('sale_cart_add_day' => 1, 'sale_cart_sum_add' => $sum);
         }
     }
     // Result
     unset($counters);
     $result = array();
     foreach ($data as $siteId => $dayCounters) {
         $result[] = array('ATTRIBUTES' => array('conversion_site' => $siteId), 'DAY_COUNTERS' => $dayCounters);
     }
     return $result;
 }
 function getNmuBasket(){
     $dbBasketItems = CSaleBasket::GetList(
     array(
             "NAME" => "ASC",
             "ID" => "ASC"
             ),
     array(
             "FUSER_ID" => CSaleBasket::GetBasketUserID(),
             "LID" => SITE_ID,
             "ORDER_ID" => "NULL"
             ),
     false,
     false,
     array()
     );
     $num=0;
     while($basket=$dbBasketItems->Fetch()) $num++;
     return $num;
 }
Beispiel #13
0
	public static function OnBasketChange($ID, $arFields = false)
	{
		if(isset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID]))
		{
			$num_products = $_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID];
		}
		else
		{
			if(!CModule::IncludeModule("sale"))
			{
				return;
			}
			$fUserID = CSaleBasket::GetBasketUserID(True);
			$fUserID = IntVal($fUserID);
			$num_products = 0;
			if ($fUserID > 0)
			{
				$dbRes = CSaleBasket::GetList(
					array(),
					array(
						"FUSER_ID" => $fUserID,
						"LID" => SITE_ID,
						"ORDER_ID" => "NULL",
						"CAN_BUY" => "Y",
						"DELAY" => "N",
						"SUBSCRIBE" => "N"
					)
				);
				while ($arItem = $dbRes->GetNext())
				{
					if (!CSaleBasketHelper::isSetItem($arItem))
						$num_products++;
				}
			}
			$_SESSION["SALE_BASKET_NUM_PRODUCTS"][SITE_ID] = intval($num_products);
		}

		echo "<script>
			if (document.getElementById('bx_cart_num'))
				document.getElementById('bx_cart_num').innerHTML = '".(($num_products > 0) ? " (".$num_products.")" : "")."';
			</script>";
	}
Beispiel #14
0
 public static function OnSalePayOrder($ID, $val)
 {
     $ID = intval($ID);
     if ($ID > 0 && $val == 'Y') {
         $arOrder = array();
         $dbBasketItems = CSaleBasket::GetList(array(), array('ORDER_ID' => $ID), false, false, array('ID', 'MODULE', 'CATALOG_XML_ID', 'QUANTITY'));
         while ($arItems = $dbBasketItems->Fetch()) {
             if ($arItems['MODULE'] == 'asd.money' && !empty($arItems['CATALOG_XML_ID']) && strpos($arItems['CATALOG_XML_ID'], '@') !== false) {
                 if (empty($arOrder)) {
                     $rsOrders = CSaleOrder::GetList(array(), array('ID' => $ID), false, false, array('ID', 'USER_ID'));
                     $arOrder = $rsOrders->Fetch();
                     if (empty($arOrder)) {
                         return;
                     }
                 }
                 list($amount, $curr) = explode('@', $arItems['CATALOG_XML_ID']);
                 CSaleUserAccount::UpdateAccount($arOrder['USER_ID'], doubleval($amount) * doubleval($arItems['QUANTITY']), $curr, GetMessage('ASD_MODULE_TRANSACT_PREPAID'), $ID);
             }
         }
     }
 }
Beispiel #15
0
function getProductDataToFillBasket($productId, $quantity, $userId, $LID, $userColumns, $tmpId = "")
{
	if (!\Bitrix\Main\Loader::includeModule("catalog"))
		return array();

	$arParams = array();

	$productId = (int)$productId;
	if ($productId <= 0)
	{
		return $arParams;
	}
	$iblockId = (int)CIBlockElement::GetIBlockByID($productId);
	if ($iblockId <= 0)
	{
		return $arParams;
	}

	$arSku2Parent = array();
	$arElementId = array();

	$arElementId[] = $productId;
	$arParent = CCatalogSku::GetProductInfo($productId, $iblockId);
	if ($arParent)
	{
		$arElementId[] = $arParent["ID"];
		$arSku2Parent[$productId] = $arParent["ID"];
	}

	$arPropertyInfo = array();
	$userColumns = (string)$userColumns;
	$arUserColumns = ($userColumns != '') ? explode(",", $userColumns) : array();
	foreach ($arUserColumns as $key => $column)
	{
		if (strncmp($column, 'PROPERTY_', 9) != 0)
		{
			unset($arUserColumns[$key]);
		}
		else
		{
			$propertyCode = substr($column, 9);
			if ($propertyCode == '')
			{
				unset($arUserColumns[$key]);
				continue;
			}
			$dbres = CIBlockProperty::GetList(array(), array("CODE" => $propertyCode));
			if ($arPropData = $dbres->GetNext())
				$arPropertyInfo[$column] = $arPropData;
		}
	}

	$arSelect = array_merge(
		array("ID", "NAME", "LID", "IBLOCK_ID", "IBLOCK_SECTION_ID", "DETAIL_PICTURE", "PREVIEW_PICTURE", "DETAIL_PAGE_URL", "XML_ID", "IBLOCK_XML_ID"),
		$arUserColumns
	);

	$arProductData = getProductProps($arElementId, $arSelect);

	$defaultMeasure = CCatalogMeasure::getDefaultMeasure(true, true);

	if (!empty($arProductData))
	{
		$arElementInfo = array();
		foreach ($arProductData as $elemId => &$arElement)
		{
			foreach ($arElement as $key => $value)
			{
				if (strncmp($key, 'PROPERTY_', 9) == 0 && substr($key, -6) == "_VALUE")
				{
					$columnCode = str_replace("_VALUE", "", $key);
					$arElement[$key] = getIblockPropInfo($value, $arPropertyInfo[$columnCode], array("WIDTH" => 90, "HEIGHT" => 90));
				}
			}
		}
		unset($arElement);

		if (isset($arProductData[$productId]))
			$arElementInfo = $arProductData[$productId];

		if (isset( $arSku2Parent[$productId]))
			$arParent = $arProductData[$arSku2Parent[$productId]];

		if (!empty($arSku2Parent)) // if sku element doesn't have value of some property - we'll show parent element value instead
		{
			foreach ($arUserColumns as $field)
			{
				$fieldVal = $field."_VALUE";
				$parentId = $arSku2Parent[$productId];

				if ((!isset($arElementInfo[$fieldVal]) || (isset($arElementInfo[$fieldVal]) && strlen($arElementInfo[$fieldVal]) == 0))
					&& (isset($arProductData[$parentId][$fieldVal]) && !empty($arProductData[$parentId][$fieldVal]))) // can be array or string
				{
					$arElementInfo[$fieldVal] = $arProductData[$parentId][$fieldVal];
				}
			}
			if (strpos($arElementInfo["~XML_ID"], '#') === false)
			{
				$arElementInfo["~XML_ID"] = $arParent['~XML_ID'].'#'.$arElementInfo["~XML_ID"];
			}
		}

		$arElementInfo["MODULE"] = "catalog";
		$arElementInfo["PRODUCT_PROVIDER_CLASS"] = "CCatalogProductProvider";

		$arElementInfo["PRODUCT_ID"] = $arElementInfo["ID"];

		if ($arElementInfo["IBLOCK_ID"] > 0)
		{
			$arElementInfo["EDIT_PAGE_URL"] = CIBlock::GetAdminElementEditLink($arElementInfo["IBLOCK_ID"], $arElementInfo["PRODUCT_ID"], array(
				"find_section_section" => $arElementInfo["IBLOCK_SECTION_ID"],
				'WF' => 'Y',
			));
		}

		$arBuyerGroups = CUser::GetUserGroup($userId);

		// price
		$arPrice = CCatalogProduct::GetOptimalPrice($arElementInfo["ID"], 1, $arBuyerGroups, "N", array(), $LID);
		$currentPrice = $arPrice["DISCOUNT_PRICE"];
		$arElementInfo["PRICE"] = $currentPrice;
		$arElementInfo["CURRENCY"] = $arPrice["PRICE"]["CURRENCY"];
		$arElementInfo["DISCOUNT_PRICE"] = $arPrice["PRICE"]["PRICE"] - $arPrice["DISCOUNT_PRICE"];
		$currentTotalPrice = ($arElementInfo["PRICE"] + $arElementInfo["DISCOUNT_PRICE"]);
		$discountPercent = 0;
		if ($arElementInfo["DISCOUNT_PRICE"] > 0)
			$discountPercent = intval(($arElementInfo["DISCOUNT_PRICE"] * 100) / $currentTotalPrice);

		$rsProducts = CCatalogProduct::GetList(
			array(),
			array('ID' => $productId),
			false,
			false,
			array('ID', 'QUANTITY', 'WEIGHT', 'MEASURE', 'TYPE', 'BARCODE_MULTI')
		);
		if (!($arProduct = $rsProducts->Fetch()))
		{
			return array();
		}
		$balance = floatval($arProduct["QUANTITY"]);

		// sku props
		$arSkuData = array();
		$arProps[] = array(
			"NAME" => "Catalog XML_ID",
			"CODE" => "CATALOG.XML_ID",
			"VALUE" => $arElementInfo['~IBLOCK_XML_ID']
		);
		$arSkuProperty = CSaleProduct::GetProductSkuProps($productId, '', true);
		if (!empty($arSkuProperty))
		{
			foreach ($arSkuProperty as &$val)
			{
				$arSkuData[] = array(
					'NAME' => $val['NAME'],
					'VALUE' => $val['VALUE'],
					'CODE' => $val['CODE']
				);
			}
			unset($val);
		}
		$arSkuData[] = array(
			"NAME" => "Product XML_ID",
			"CODE" => "PRODUCT.XML_ID",
			"VALUE" => $arElementInfo["~XML_ID"]
		);

		// currency
		$arCurFormat = CCurrencyLang::GetCurrencyFormat($arElementInfo["CURRENCY"]);
		$priceValutaFormat = str_replace("#", "", $arCurFormat["FORMAT_STRING"]);

		$arElementInfo["WEIGHT"] = $arProduct["WEIGHT"];

		// measure
		$arElementInfo["MEASURE_TEXT"] = "";
		if ((int)$arProduct["MEASURE"] > 0)
		{
			$dbMeasure = CCatalogMeasure::GetList(array(), array("ID" => intval($arProduct["MEASURE"])), false, false, array("ID", "SYMBOL_RUS", "SYMBOL_INTL"));
			if ($arMeasure = $dbMeasure->Fetch())
				$arElementInfo["MEASURE_TEXT"] = ($arMeasure["SYMBOL_RUS"] != '' ? $arMeasure["SYMBOL_RUS"] : $arMeasure["SYMBOL_INTL"]);
		}
		if ($arElementInfo["MEASURE_TEXT"] == '')
		{
			$arElementInfo["MEASURE_TEXT"] = ($defaultMeasure["SYMBOL_RUS"] != '' ? $defaultMeasure["SYMBOL_RUS"] : $defaultMeasure["SYMBOL_INTL"]);
		}


		// ratio
		$arElementInfo["RATIO"] = 1;
		$dbratio = CCatalogMeasureRatio::GetList(array(), array("PRODUCT_ID" => $productId));
		if ($arRatio = $dbratio->Fetch())
			$arElementInfo["RATIO"] = $arRatio["RATIO"];

		// image
		if ($arElementInfo["PREVIEW_PICTURE"] > 0)
			$imgCode = $arElementInfo["PREVIEW_PICTURE"];
		elseif ($arElementInfo["DETAIL_PICTURE"] > 0)
			$imgCode = $arElementInfo["DETAIL_PICTURE"];

		if ($imgCode == "" && count($arParent) > 0)
		{
			if ($arParent["PREVIEW_PICTURE"] > 0)
				$imgCode = $arParent["PREVIEW_PICTURE"];
			elseif ($arParent["DETAIL_PICTURE"] > 0)
				$imgCode = $arParent["DETAIL_PICTURE"];
		}

		if ($imgCode > 0)
		{
			$arFile = CFile::GetFileArray($imgCode);
			$arImgProduct = CFile::ResizeImageGet($arFile, array('width'=>80, 'height'=>80), BX_RESIZE_IMAGE_PROPORTIONAL, false, false);
			if (is_array($arImgProduct))
				$imgUrl = $arImgProduct["src"];
		}

		$arSetInfo = array();
		$arStores = array();

		/** @var $productProvider IBXSaleProductProvider */
		if ($productProvider = CSaleBasket::GetProductProvider(array("MODULE" => $arElementInfo["MODULE"], "PRODUCT_PROVIDER_CLASS" => $arElementInfo["PRODUCT_PROVIDER_CLASS"])))
		{
			// get set items if it is set
			if ($arProduct["TYPE"] == CCatalogProduct::TYPE_SET)
			{
				if (method_exists($productProvider, "GetSetItems"))
				{
					$arSets = $productProvider::GetSetItems($productId, CSaleBasket::TYPE_SET);

					if ($tmpId == "")
						$tmpId = randString(7);

					if (!empty($arSets))
					{
						foreach ($arSets as $arSetData)
						{
							foreach ($arSetData["ITEMS"] as $setItem)
							{
								$arSetItemParams = getProductDataToFillBasket($setItem["PRODUCT_ID"], $setItem["QUANTITY"], $userId, $LID, $userColumns, $tmpId); // recursive call

								// re-define some fields with set data values
								$arSetItemParams["id"] = $setItem["PRODUCT_ID"];
								$arSetItemParams["name"] = $setItem["NAME"];
								$arSetItemParams["module"] = $setItem["MODULE"];
								$arSetItemParams["productProviderClass"] = $setItem["PRODUCT_PROVIDER_CLASS"];
								$arSetItemParams["url"] = $setItem["DETAIL_PAGE_URL"];
								$arSetItemParams["quantity"] = $setItem["QUANTITY"] * $quantity;
								$arSetItemParams["barcodeMulti"] = $setItem["BARCODE_MULTI"];
								$arSetItemParams["productType"] = $setItem["TYPE"];
								$arSetItemParams["weight"] = $setItem["WEIGHT"];
								$arSetItemParams["vatRate"] = $setItem["VAT_RATE"];
								$arSetItemParams["setItems"] = "";

								$arSetItemParams["setParentId"] = $productId."_tmp".$tmpId;
								$arSetItemParams["isSetItem"] = "Y";
								$arSetItemParams["isSetParent"] = "N";

								$arSetInfo[] = $arSetItemParams;
							}
						}
					}
				}
			}

			// get stores
			$storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID)); // with exact SITE_ID or SITE_ID = NULL

			if ($storeCount > 0)
			{
				if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $productId, "SITE_ID" => $LID)))
					$arStores = $arProductStore;
			}
		}

		$currentTotalPrice = (float)$currentTotalPrice;
		// params array
		$arParams["id"] = $productId;
		$arParams["name"] = $arElementInfo["~NAME"];
		$arParams["url"] = htmlspecialcharsex($arElementInfo["~DETAIL_PAGE_URL"]);
		$arParams["urlEdit"] = $arElementInfo["EDIT_PAGE_URL"];
		$arParams["urlImg"] = $imgUrl;
		$arParams["price"] = floatval($arElementInfo["PRICE"]);
		$arParams["priceBase"] = $currentTotalPrice;
		$arParams["priceBaseFormat"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], false);
		$arParams["priceFormated"] = CCurrencyLang::CurrencyFormat(floatval($arElementInfo["PRICE"]), $arElementInfo["CURRENCY"], false);
		$arParams["valutaFormat"] = $priceValutaFormat;
		$arParams["dimensions"] = serialize(array("WIDTH" => $arElementInfo["WIDTH"], "HEIGHT" => $arElementInfo["HEIGHT"], "LENGTH" => $arElementInfo["LENGTH"]));
		$arParams["priceDiscount"] = floatval($arElementInfo["DISCOUNT_PRICE"]);
		$arParams["priceTotalFormated"] = CCurrencyLang::CurrencyFormat($currentTotalPrice, $arElementInfo["CURRENCY"], true);
		$arParams["discountPercent"] = $discountPercent;
		$arParams["summaFormated"] = CCurrencyLang::CurrencyFormat($arElementInfo["PRICE"], $arElementInfo["CURRENCY"], false);
		$arParams["quantity"] = $quantity;
		$arParams["module"] = $arElementInfo["MODULE"];
		$arParams["currency"] = $arElementInfo["CURRENCY"];
		$arParams["weight"] = $arElementInfo["WEIGHT"];
		$arParams["vatRate"] = $arPrice["PRICE"]["VAT_RATE"];
		$arParams["priceType"] = $arPrice["PRICE"]["CATALOG_GROUP_NAME"];
		$arParams["balance"] = $balance;
		$arParams["notes"] = (is_array($arPrice["PRICE"]) && array_key_exists("CATALOG_GROUP_NAME", $arPrice["PRICE"])) ? $arPrice["PRICE"]["CATALOG_GROUP_NAME"] : "";
		$arParams["catalogXmlID"] = $arElementInfo["~IBLOCK_XML_ID"];
		$arParams["productXmlID"] = $arElementInfo["~XML_ID"];
		$arParams["callback"] = "";
		$arParams["orderCallback"] = "";
		$arParams["cancelCallback"] = "";
		$arParams["payCallback"] = "";
		$arParams["productProviderClass"] = $arElementInfo["PRODUCT_PROVIDER_CLASS"];
		$arParams["skuProps"] = $arSkuData;
		$arParams["measureText"] = $arElementInfo["MEASURE_TEXT"];
		$arParams["ratio"] = $arElementInfo["RATIO"];
		$arParams["barcodeMulti"] = $arProduct["BARCODE_MULTI"];

		$arParams["productType"] = empty($arSetInfo) ? "" : CSaleBasket::TYPE_SET;
		$arParams["setParentId"] = empty($arSetInfo) ? "" : $productId."_tmp".$tmpId;

		$arParams["setItems"] = $arSetInfo;
		$arParams["isSetItem"] = "N";
		$arParams["isSetParent"] = empty($arSetInfo) ? "N" : "Y";

		$arParams["stores"] = empty($arSetInfo) ? $arStores : array();
		$arParams["productPropsValues"] = $arElementInfo; // along with other information also contains values of properties with correct keys (after getProductProps)
	}

	return $arParams;
}
Beispiel #16
0
 public function obtainBasketProps(&$arBasketItems)
 {
     // prepare some indexes
     $arElementIds = array();
     // a collection of PRODUCT_IDs and parent PRODUCT_IDs
     $arSku2Parent = array();
     // a mapping SKU PRODUCT_IDs to PARENT PRODUCT_IDs
     $arParents = array();
     // also
     $arSkuProps = array();
     if (self::isNonemptyArray($arBasketItems)) {
         foreach ($arBasketItems as &$arItem) {
             // get sale properties: which was added with CSaleBasket::Add(array('PROP' => array(...)))
             $arItem["PROPS"] = array();
             $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $arItem["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
             while ($arProp = $dbProp->GetNext()) {
                 $arItem["PROPS"][] = $arProp;
             }
             // catalog-specific logic farther: iblocks, catalogs and other friends
             if (!$this->cameFromCatalog($arItem)) {
                 continue;
             }
             $arElementIds[] = $arItem["PRODUCT_ID"];
             if ($arItem['PARENT']) {
                 $arElementIds[] = $arItem['PARENT']["ID"];
                 $arSku2Parent[$arItem["PRODUCT_ID"]] = $arItem['PARENT']["ID"];
                 $arParents[$arItem["PRODUCT_ID"]]["PRODUCT_ID"] = $arItem['PARENT']["ID"];
                 $arParents[$arItem["PRODUCT_ID"]]["IBLOCK_ID"] = $arItem['PARENT']["IBLOCK_ID"];
             }
             if (self::isNonemptyArray($arItem['PROPS'])) {
                 foreach ($arItem['PROPS'] as $prop) {
                     $arSkuProps[$prop['CODE']] = 1;
                 }
             }
         }
         $arSkuProps = array_keys($arSkuProps);
         // fetching iblock props
         $this->obtainBasketPropsElement($arBasketItems, $arElementIds, $arSku2Parent);
         // fetching sku props, if any
         $this->obtainBasketPropsSKU($arBasketItems, $arSkuProps, $arParents);
     }
     return $arBasketItems;
 }
Beispiel #17
0
$weight = 0;
$price = 0;
$price_total = 0;
$arProdIds = array();
//http://jabber.bx/view.php?id=37744
$arProdIdsPrIds = array();
$useStores = false;
while ($arBasket = $dbBasket->Fetch()) {
    $arProdIds[] = $arBasket["PRODUCT_ID"];
    $arProdIdsPrIds[$arBasket["PRODUCT_ID"]] = $arBasket["ID"];
    $arBasket["BALANCE"] = "0";
    $arBasket["STORES"] = array();
    $arBasket["HAS_SAVED_QUANTITY"] = "N";
    $arBasket["HAS_SAVED_BARCODES"] = false;
    /** @var $productProvider IBXSaleProductProvider */
    if ($productProvider = CSaleBasket::GetProductProvider($arBasket)) {
        $storeCount = $productProvider::GetStoresCount(array("SITE_ID" => $LID));
        if ($storeCount > 0) {
            if ($arProductStore = $productProvider::GetProductStores(array("PRODUCT_ID" => $arBasket["PRODUCT_ID"], "SITE_ID" => $LID, 'BASKET_ID' => $arBasket['ID']))) {
                foreach ($arProductStore as $arStore) {
                    $arBasket["STORES"][$arStore["STORE_ID"]] = $arStore;
                }
                if (!$useStores && $storeCount != -1) {
                    $useStores = true;
                }
                // if barcodes/store quantity are already saved for this product,
                // then check if barcodes are still valid and save them to the store array
                $ind = 0;
                $dbres = CSaleStoreBarcode::GetList(array(), array("BASKET_ID" => $arBasket["ID"]), false, false, array("ID", "BASKET_ID", "BARCODE", "STORE_ID", "ORDER_ID", "QUANTITY", "DEDUCTED"));
                while ($arRes = $dbres->GetNext()) {
                    $arCheckBarcodeFields = array("BARCODE" => $arRes["BARCODE"], "PRODUCT_ID" => $arBasket["PRODUCT_ID"], "ORDER_ID" => $arParams["ORDER_ID"]);
<?php

// в модуле интернет-магазина нужно включить на стройку - "Использовать совместимость для просмотренных товаров каталога"
$countViewedProducts = 0;
$GLOBALS['arViewedProducts'] = array();
if (\Bitrix\Main\Loader::includeModule("catalog") && \Bitrix\Main\Loader::includeModule("sale")) {
    $arFilter["FUSER_ID"] = CSaleBasket::GetBasketUserID();
    if (\Bitrix\Main\Config\Option::get("sale", "viewed_capability", "") == "Y") {
        $viewedIterator = \Bitrix\Catalog\CatalogViewedProductTable::getList(array("filter" => $arFilter, "select" => array("ID", "PRODUCT_ID"), "order" => array("DATE_VISIT" => "DESC")));
        while ($row = $viewedIterator->fetch()) {
            $GLOBALS['arViewedProducts'][] = $row['PRODUCT_ID'];
            $countViewedProducts++;
        }
    }
}
Beispiel #19
0
						<td align="center">Цена, руб</td>
						<td align="center">Cумма, руб</td>
					</tr>
					<?php 
    $priceTotal = 0;
    $bUseVat = false;
    $arBasketOrder = array();
    for ($i = 0, $countBasketIds = count($arBasketIDs); $i < $countBasketIds; $i++) {
        $arBasketTmp = CSaleBasket::GetByID($arBasketIDs[$i]);
        if (floatval($arBasketTmp["VAT_RATE"]) > 0) {
            $bUseVat = true;
        }
        $priceTotal += $arBasketTmp["PRICE"] * $arBasketTmp["QUANTITY"];
        $arBasketTmp["PROPS"] = array();
        if (isset($_GET["PROPS_ENABLE"]) && $_GET["PROPS_ENABLE"] == "Y") {
            $dbBasketProps = CSaleBasket::GetPropsList(array("SORT" => "ASC", "NAME" => "ASC"), array("BASKET_ID" => $arBasketTmp["ID"]), false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT"));
            while ($arBasketProps = $dbBasketProps->GetNext()) {
                $arBasketTmp["PROPS"][$arBasketProps["ID"]] = $arBasketProps;
            }
        }
        $arBasketOrder[] = $arBasketTmp;
    }
    //разбрасываем скидку на заказ по товарам
    if (floatval($arOrder["DISCOUNT_VALUE"]) > 0) {
        $arBasketOrder = GetUniformDestribution($arBasketOrder, $arOrder["DISCOUNT_VALUE"], $priceTotal);
    }
    //налоги
    $arTaxList = array();
    $db_tax_list = CSaleOrderTax::GetList(array("APPLY_ORDER" => "ASC"), array("ORDER_ID" => $ORDER_ID));
    $iNds = -1;
    $i = 0;
Beispiel #20
0
$arParams['SHOW_DELAY'] = isset($arParams['SHOW_DELAY']) && $arParams['SHOW_DELAY'] == 'N' ? 'N' : 'Y';
$arParams['SHOW_NOTAVAIL'] = isset($arParams['SHOW_NOTAVAIL']) && $arParams['SHOW_NOTAVAIL'] == 'N' ? 'N' : 'Y';
$arParams['SHOW_SUBSCRIBE'] = isset($arParams['SHOW_SUBSCRIBE']) && $arParams['SHOW_SUBSCRIBE'] == 'N' ? 'N' : 'Y';
$bReady = false;
$bDelay = false;
$bNotAvail = false;
$bSubscribe = false;
$arItems = array();
$arReadyItems = array();
$allSum = 0.0;
$allWeight = 0.0;
$arBasketItems = array();
$arSetParentWeight = array();
$fuserId = (int) CSaleBasket::GetBasketUserID(true);
if ($fuserId > 0) {
    $rsBaskets = CSaleBasket::GetList(array("ID" => "ASC"), array("FUSER_ID" => $fuserId, "LID" => SITE_ID, "ORDER_ID" => "NULL"), false, false, array("ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "QUANTITY", "DELAY", "CAN_BUY", "PRICE", "WEIGHT", "DETAIL_PAGE_URL", "NOTES", "CURRENCY", "VAT_RATE", "CATALOG_XML_ID", "PRODUCT_XML_ID", "SUBSCRIBE", "DISCOUNT_PRICE", "PRODUCT_PROVIDER_CLASS", "TYPE", "SET_PARENT_ID"));
    while ($arItem = $rsBaskets->GetNext()) {
        $arBasketItems[] = $arItem;
        if (CSaleBasketHelper::isSetItem($arItem)) {
            $arSetParentWeight[$arItem["SET_PARENT_ID"]] += $arItem["WEIGHT"] * $arItem['QUANTITY'];
        }
    }
}
if (!empty($arBasketItems)) {
    // count weight for set parent products
    foreach ($arBasketItems as &$arItem) {
        if (CSaleBasketHelper::isSetParent($arItem)) {
            $arItem["WEIGHT"] = $arSetParentWeight[$arItem["ID"]] / $arItem["QUANTITY"];
        }
    }
    unset($arItem);
Beispiel #21
0
 function RemindPayment()
 {
     $reminder = COption::GetOptionString("sale", "pay_reminder", "");
     $arReminder = unserialize($reminder);
     if (!empty($arReminder)) {
         $arSites = array();
         $minDay = mktime();
         foreach ($arReminder as $key => $val) {
             if ($val["use"] == "Y") {
                 $arSites[] = $key;
                 $days = array();
                 for ($i = 0; $i <= floor($val["period"] / $val["frequency"]); $i++) {
                     $day = AddToTimeStamp(array("DD" => -($val["after"] + $val["period"] - $val["frequency"] * $i)));
                     if ($day < mktime()) {
                         if ($minDay > $day) {
                             $minDay = $day;
                         }
                         $day = ConvertTimeStamp($day);
                         $days[] = $day;
                     }
                 }
                 $arReminder[$key]["days"] = $days;
             }
         }
         if (!empty($arSites)) {
             $bTmpUser = False;
             if (!isset($GLOBALS["USER"]) || !is_object($GLOBALS["USER"])) {
                 $bTmpUser = True;
                 $GLOBALS["USER"] = new CUser();
             }
             $arFilter = array("LID" => $arSites, "PAYED" => "N", "CANCELED" => "N", "ALLOW_DELIVERY" => "N", ">=DATE_INSERT" => ConvertTimeStamp($minDay));
             $dbOrder = CSaleOrder::GetList(array("ID" => "DESC"), $arFilter, false, false, array("ID", "DATE_INSERT", "PAYED", "USER_ID", "LID", "PRICE", "CURRENCY"));
             while ($arOrder = $dbOrder->GetNext()) {
                 $date_insert = ConvertDateTime($arOrder["DATE_INSERT"], CSite::GetDateFormat("SHORT"));
                 if (in_array($date_insert, $arReminder[$arOrder["LID"]]["days"])) {
                     $strOrderList = "";
                     $dbBasketTmp = CSaleBasket::GetList(array("NAME" => "ASC"), array("ORDER_ID" => $arOrder["ID"]), false, false, array("ID", "NAME", "QUANTITY"));
                     while ($arBasketTmp = $dbBasketTmp->Fetch()) {
                         $strOrderList .= $arBasketTmp["NAME"] . " (" . $arBasketTmp["QUANTITY"] . ")";
                         $strOrderList .= "\n";
                     }
                     $payerEMail = "";
                     $dbOrderProp = CSaleOrderPropsValue::GetList(array(), array("ORDER_ID" => $arOrder["ID"], "PROP_IS_EMAIL" => "Y"));
                     if ($arOrderProp = $dbOrderProp->Fetch()) {
                         $payerEMail = $arOrderProp["VALUE"];
                     }
                     $payerName = "";
                     $dbUser = CUser::GetByID($arOrder["USER_ID"]);
                     if ($arUser = $dbUser->Fetch()) {
                         if (strlen($payerName) <= 0) {
                             $payerName = $arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"];
                         }
                         if (strlen($payerEMail) <= 0) {
                             $payerEMail = $arUser["EMAIL"];
                         }
                     }
                     $arFields = array("ORDER_ID" => $arOrder["ID"], "ORDER_DATE" => $date_insert, "ORDER_USER" => $payerName, "PRICE" => SaleFormatCurrency($arOrder["PRICE"], $arOrder["CURRENCY"]), "BCC" => COption::GetOptionString("sale", "order_email", "order@" . $_SERVER["SERVER_NAME"]), "EMAIL" => $payerEMail, "ORDER_LIST" => $strOrderList, "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@" . $SERVER_NAME));
                     $eventName = "SALE_ORDER_REMIND_PAYMENT";
                     $bSend = true;
                     foreach (GetModuleEvents("sale", "OnOrderRemindSendEmail", true) as $arEvent) {
                         if (ExecuteModuleEventEx($arEvent, array($arOrder["ID"], &$eventName, &$arFields)) === false) {
                             $bSend = false;
                         }
                     }
                     if ($bSend) {
                         $event = new CEvent();
                         $event->Send($eventName, $arOrder["LID"], $arFields, "N");
                     }
                 }
             }
             if ($bTmpUser) {
                 unset($GLOBALS["USER"]);
             }
         }
     }
     return "CSaleOrder::RemindPayment();";
 }
Beispiel #22
0
<?php

define("NOT_CHECK_PERMISSIONS", true);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php";
if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["basketChange"]) > 0 && check_bitrix_sessid()) {
    if (isset($_POST["site_id"])) {
        $site_id = $_POST["site_id"];
    }
    if (isset($_SESSION["SALE_BASKET_NUM_PRODUCTS"][$site_id])) {
        $num_products = $_SESSION["SALE_BASKET_NUM_PRODUCTS"][$site_id];
    } else {
        if (!CModule::IncludeModule("sale")) {
            return;
        }
        $fUserID = CSaleBasket::GetBasketUserID(True);
        $fUserID = IntVal($fUserID);
        $num_products = 0;
        if ($fUserID > 0) {
            $dbRes = CSaleBasket::GetList(array(), array("FUSER_ID" => $fUserID, "LID" => $site_id, "ORDER_ID" => "NULL", "CAN_BUY" => "Y", "DELAY" => "N", "SUBSCRIBE" => "N"));
            while ($arItem = $dbRes->GetNext()) {
                if (!CSaleBasketHelper::isSetItem($arItem)) {
                    $num_products++;
                }
            }
        }
        $_SESSION["SALE_BASKET_NUM_PRODUCTS"][$site_id] = intval($num_products);
    }
    $APPLICATION->RestartBuffer();
    echo $num_products;
    die;
}
Beispiel #23
0
<br>
<br>

<?php 
$dbBasket = CSaleBasket::GetList(array("DATE_INSERT" => "ASC", "NAME" => "ASC"), array("ORDER_ID" => $ORDER_ID), false, false, array("ID", "PRICE", "CURRENCY", "QUANTITY", "NAME", "VAT_RATE", "MEASURE_NAME"));
if ($arBasket = $dbBasket->Fetch()) {
    $arCells = array();
    $arProps = array();
    $n = 0;
    $sum = 0.0;
    $vat = 0;
    $vats = array();
    do {
        // props in product basket
        $arProdProps = array();
        $dbBasketProps = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "DESC"), array("BASKET_ID" => $arBasket["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")), false, false, array("ID", "BASKET_ID", "NAME", "VALUE", "CODE", "SORT"));
        while ($arBasketProps = $dbBasketProps->GetNext()) {
            if (!empty($arBasketProps) && $arBasketProps["VALUE"] != "") {
                $arProdProps[] = $arBasketProps;
            }
        }
        $arBasket["PROPS"] = $arProdProps;
        // @TODO: replace with real vatless price
        if (isset($arBasket['VAT_INCLUDED']) && $arBasket['VAT_INCLUDED'] === 'Y') {
            $arBasket["VATLESS_PRICE"] = roundEx($arBasket["PRICE"] / (1 + $arBasket["VAT_RATE"]), SALE_VALUE_PRECISION);
        } else {
            $arBasket["VATLESS_PRICE"] = $arBasket["PRICE"];
        }
        $productName = $arBasket["NAME"];
        if ($productName == "OrderDelivery") {
            $productName = "Envío";
Beispiel #24
0
					<?php 
            $APPLICATION->IncludeComponent("bitrix:catalog.bigdata.products", "main", array("LINE_ELEMENT_COUNT" => 4, "TEMPLATE_THEME" => isset($arParams['TEMPLATE_THEME']) ? $arParams['TEMPLATE_THEME'] : '', "DETAIL_URL" => $arResult["FOLDER"] . $arResult["URL_TEMPLATES"]["element"], "BASKET_URL" => $arParams["BASKET_URL"], "ACTION_VARIABLE" => (!empty($arParams["ACTION_VARIABLE"]) ? $arParams["ACTION_VARIABLE"] : "action") . "_cbdp", "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"], "PRODUCT_QUANTITY_VARIABLE" => $arParams["PRODUCT_QUANTITY_VARIABLE"], "ADD_PROPERTIES_TO_BASKET" => isset($arParams["ADD_PROPERTIES_TO_BASKET"]) ? $arParams["ADD_PROPERTIES_TO_BASKET"] : '', "PRODUCT_PROPS_VARIABLE" => $arParams["PRODUCT_PROPS_VARIABLE"], "PARTIAL_PRODUCT_PROPERTIES" => isset($arParams["PARTIAL_PRODUCT_PROPERTIES"]) ? $arParams["PARTIAL_PRODUCT_PROPERTIES"] : '', "SHOW_OLD_PRICE" => $arParams['SHOW_OLD_PRICE'], "SHOW_DISCOUNT_PERCENT" => $arParams['SHOW_DISCOUNT_PERCENT'], "PRICE_CODE" => $arParams["PRICE_CODE"], "SHOW_PRICE_COUNT" => $arParams["SHOW_PRICE_COUNT"], "PRODUCT_SUBSCRIPTION" => $arParams['PRODUCT_SUBSCRIPTION'], "PRICE_VAT_INCLUDE" => $arParams["PRICE_VAT_INCLUDE"], "USE_PRODUCT_QUANTITY" => $arParams['USE_PRODUCT_QUANTITY'], "SHOW_NAME" => "Y", "SHOW_IMAGE" => "Y", "CAN_BUY" => "Y", "MESS_BTN_BUY" => $arParams['MESS_BTN_BUY'], "MESS_BTN_DETAIL" => $arParams['MESS_BTN_DETAIL'], "MESS_BTN_SUBSCRIBE" => $arParams['MESS_BTN_SUBSCRIBE'], "MESS_NOT_AVAILABLE" => $arParams['MESS_NOT_AVAILABLE'], "PAGE_ELEMENT_COUNT" => $arParams['BIG_DATA_ELEMENTS'] ? $arParams['BIG_DATA_ELEMENTS'] : 8, "SHOW_FROM_SECTION" => "Y", "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"], "IBLOCK_ID" => $arParams["IBLOCK_ID"], "DEPTH" => "2", "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_GROUPS" => $arParams["CACHE_GROUPS"], "SHOW_PRODUCTS_" . $arParams["IBLOCK_ID"] => "Y", "HIDE_NOT_AVAILABLE" => $arParams["HIDE_NOT_AVAILABLE"], "CONVERT_CURRENCY" => $arParams["CONVERT_CURRENCY"], "CURRENCY_ID" => $arParams["CURRENCY_ID"], "DISPLAY_COMPARE" => $arParams["USE_COMPARE"], "DISPLAY_WISH_BUTTONS" => $arParams["DISPLAY_WISH_BUTTONS"], "COMPARE_NAME" => $arParams["COMPARE_NAME"], "USE_TITLE_BLOCK" => "Y", "TITLE_BLOCK" => GetMessage("TITLE_BLOCK"), "SECTION_ID" => $arSection["ID"], "SECTION_CODE" => "", "SECTION_ELEMENT_ID" => "", "SECTION_ELEMENT_CODE" => "", "LABEL_PROP_" . $arParams["IBLOCK_ID"] => $arParams['LABEL_PROP'], "PROPERTY_CODE_" . $arParams["IBLOCK_ID"] => $arParams["LIST_PROPERTY_CODE"], "PROPERTY_CODE_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["LIST_OFFERS_PROPERTY_CODE"], "CART_PROPERTIES_" . $arParams["IBLOCK_ID"] => $arParams["PRODUCT_PROPERTIES"], "CART_PROPERTIES_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["OFFERS_CART_PROPERTIES"], "ADDITIONAL_PICT_PROP_" . $arParams["IBLOCK_ID"] => $arParams['ADD_PICT_PROP'], "ADDITIONAL_PICT_PROP_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams['OFFER_ADD_PICT_PROP'], "OFFER_TREE_PROPS_" . $arRecomData['OFFER_IBLOCK_ID'] => $arParams["OFFER_TREE_PROPS"], "RCM_TYPE" => isset($arParams['BIG_DATA_RCM_TYPE']) ? $arParams['BIG_DATA_RCM_TYPE'] : ''), $component, array("HIDE_ICONS" => "Y"));
            ?>
				<?php 
        }
        ?>
			</div>
		</div>
		
	<?php 
    }
    ?>
	<div style="clear: both"></div>

	<?php 
    $rsBasket = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL", "CAN_BUY" => "Y", "DELAY" => "N", "SUBSCRIBE" => "N"), false, false, array("ID", "PRODUCT_ID", "QUANTITY", "SET_PARENT_ID", "TYPE"));
    while ($arBasket = $rsBasket->GetNext()) {
        if (CSaleBasketHelper::isSetItem($arBasket)) {
            continue;
        }
        if ($arBasket["DELAY"] == "Y") {
            $delay_items[] = $arBasket["PRODUCT_ID"];
        } else {
            $basket_items[] = $arBasket["PRODUCT_ID"];
        }
    }
    global $compare_items;
    ?>
	<script>
		$(document).ready(function(){
			<?php 
Beispiel #25
0
			'content' => '{"api_auth_token": "'.$secret.'"}'
		)
	));
	$api_answer = json_decode(file_get_contents($token_url, FALSE, $context));
	if (!$api_answer) { throw new Exception(GetMessage("EXCEPTION_NO_API_ANSWER", array("#URL#" => $token_url))); }
	if (!($arResult['WIDGET_TOKEN'] = $api_answer->token)) { throw new Exception(GetMessage("EXCEPTION_NO_WIDGET_TOKEN")); }
	if (!($arResult['GP_DELIVERY_DESCRIPTION'] = $api_answer->description)) { throw new Exception(GetMessage("EXCEPTION_NO_DELIVERY_DESCRIPTION")); }

	$arBasketItems = array();
	$dbBasketItems = CSaleBasket::GetList(
		array("NAME" => "ASC", "ID" => "ASC"), array("FUSER_ID" => CSaleBasket::GetBasketUserID(), "LID" => SITE_ID, "ORDER_ID" => "NULL")
	);
	while ($arItems = $dbBasketItems->Fetch()) {
		if (strlen($arItems["CALLBACK_FUNC"]) > 0) {
			CSaleBasket::UpdatePrice($arItems["ID"], $arItems["CALLBACK_FUNC"], $arItems["MODULE"], $arItems["PRODUCT_ID"], $arItems["QUANTITY"]);
			$arItems = CSaleBasket::GetByID($arItems["ID"]);
		}
		$arBasketItems[] = $arItems;
	}

	$arResult['WIDGET_ITEMS'] = array();
	$ESTIMATED_PRICE_TYPE_ID = 4;
	foreach($arBasketItems as $index=>$item) {
		$widgetItem = array();
		$widgetItem['price'] = $item['PRICE'];
		$widgetItem['shop_good_code'] = $item['PRODUCT_ID'];
		$widgetItem['count'] = $item['QUANTITY'];
		$widgetItem['weight'] = $item['WEIGHT'];
		$widgetItem['name'] = $item['NAME'];
		$rsPrices = CPrice::GetList(array(), array('PRODUCT_ID' => $item['PRODUCT_ID'], 'CATALOG_GROUP_ID' => $ESTIMATED_PRICE_TYPE_ID));
		if ($arPrice = $rsPrices->Fetch()) {
Beispiel #26
0
      <h4>Мой кабинет</h4>
     </div>
   <?php 
$APPLICATION->IncludeComponent("bitrix:menu", "vertical_left_menu", array("ROOT_MENU_TYPE" => "left", "MAX_LEVEL" => "1", "CHILD_MENU_TYPE" => "left", "USE_EXT" => "N", "DELAY" => "N", "ALLOW_MULTI_SELECT" => "N", "MENU_CACHE_TYPE" => "N", "MENU_CACHE_TIME" => "3600", "MENU_CACHE_USE_GROUPS" => "Y", "MENU_CACHE_GET_VARS" => array()));
?>
 </div>
 
  <div class="col-lg-8 col-md-8 col-sm-12 col-xs-12 col-lg-pull-4 col-md-pull-4"> <?php 
if ($USER->IsAuthorized() && CModule::IncludeModule("sale")) {
    $arOrders = array();
    $arFilter = array("USER_ID" => $USER->GetID(), "STATUS_ID" => "F");
    $rsSales = CSaleOrder::GetList(array("DATE_INSERT" => "ASC"), $arFilter);
    while ($arSales = $rsSales->Fetch()) {
        $arOrders[] = $arSales["ID"];
    }
    $dbBasketItems = CSaleBasket::GetList(array("NAME" => "ASC", "ID" => "ASC"), array("ORDER_ID" => $arOrders), false, false, array("PRODUCT_ID"));
    while ($arItems = $dbBasketItems->Fetch()) {
        $arBasketItems[] = $arItems["PRODUCT_ID"];
    }
    $arFilter = array("IBLOCK_ID" => 31, "ACTIVE" => "Y", "PROPERTY_Linked_Goods" => $arBasketItems);
}
?>
 <?php 
if (!empty($arBasketItems) && !empty($arOrders) && $USER->IsAuthorized() || $USER->isAdmin()) {
    ?>
 
    <h3>Релизы </h3>
   <?php 
    $APPLICATION->IncludeComponent("bitrix:catalog.section", "board", array("IBLOCK_TYPE" => "NewRelease", "IBLOCK_ID" => "31", "SECTION_ID" => $_REQUEST["SECTION_ID"], "SECTION_CODE" => "", "SECTION_USER_FIELDS" => array(0 => "", 1 => ""), "ELEMENT_SORT_FIELD" => "active_from", "ELEMENT_SORT_ORDER" => "desc", "FILTER_NAME" => "arFilter", "INCLUDE_SUBSECTIONS" => "Y", "SHOW_ALL_WO_SECTION" => "N", "PAGE_ELEMENT_COUNT" => "30", "LINE_ELEMENT_COUNT" => "1", "PROPERTY_CODE" => array(0 => "", 1 => ""), "OFFERS_LIMIT" => "10", "SECTION_URL" => "", "DETAIL_URL" => "", "BASKET_URL" => "", "ACTION_VARIABLE" => "action", "PRODUCT_ID_VARIABLE" => "id", "PRODUCT_QUANTITY_VARIABLE" => "quantity", "PRODUCT_PROPS_VARIABLE" => "prop", "SECTION_ID_VARIABLE" => "SECTION_ID", "AJAX_MODE" => "Y", "AJAX_OPTION_JUMP" => "Y", "AJAX_OPTION_STYLE" => "N", "AJAX_OPTION_HISTORY" => "N", "CACHE_TYPE" => "A", "CACHE_TIME" => "36000", "CACHE_GROUPS" => "Y", "META_KEYWORDS" => "-", "META_DESCRIPTION" => "-", "BROWSER_TITLE" => "-", "ADD_SECTIONS_CHAIN" => "Y", "DISPLAY_COMPARE" => "N", "SET_TITLE" => "Y", "SET_STATUS_404" => "N", "CACHE_FILTER" => "N", "PRICE_CODE" => array(), "USE_PRICE_COUNT" => "N", "SHOW_PRICE_COUNT" => "1", "PRICE_VAT_INCLUDE" => "N", "PRODUCT_PROPERTIES" => array(), "USE_PRODUCT_QUANTITY" => "N", "CONVERT_CURRENCY" => "N", "DISPLAY_TOP_PAGER" => "N", "DISPLAY_BOTTOM_PAGER" => "Y", "PAGER_TITLE" => "Дистрибутивы", "PAGER_SHOW_ALWAYS" => "N", "PAGER_TEMPLATE" => "", "PAGER_DESC_NUMBERING" => "N", "PAGER_DESC_NUMBERING_CACHE_TIME" => "36000", "PAGER_SHOW_ALL" => "Y", "AJAX_OPTION_ADDITIONAL" => ""));
    ?>
 <?php 
Beispiel #27
0
 public function checkQuantity($arBasketItem, $desiredQuantity)
 {
     global $USER;
     $arResult = array();
     /** @var $productProvider IBXSaleProductProvider */
     if ($productProvider = CSaleBasket::GetProductProvider($arBasketItem)) {
         $arFieldsTmp = $productProvider::GetProductData(array("PRODUCT_ID" => $arBasketItem["PRODUCT_ID"], "QUANTITY" => $desiredQuantity, "RENEWAL" => "N", "USER_ID" => $USER->GetID(), "SITE_ID" => SITE_ID, "BASKET_ID" => $arBasketItem["ID"], "CHECK_QUANTITY" => "Y", "CHECK_PRICE" => "N", "NOTES" => $arBasketItem["NOTES"]));
     } elseif (isset($arBasketItem["CALLBACK_FUNC"]) && !empty($arBasketItem["CALLBACK_FUNC"])) {
         $arFieldsTmp = CSaleBasket::ExecuteCallbackFunction($arBasketItem["CALLBACK_FUNC"], $arBasketItem["MODULE"], $arBasketItem["PRODUCT_ID"], $desiredQuantity, "N", $USER->GetID(), SITE_ID);
     } else {
         return $arResult;
     }
     if (empty($arFieldsTmp) || !isset($arFieldsTmp["QUANTITY"])) {
         $arResult["ERROR"] = Loc::getMessage("SBB_PRODUCT_NOT_AVAILABLE", array("#PRODUCT#" => $arBasketItem["NAME"]));
     } elseif ($desiredQuantity > doubleval($arFieldsTmp["QUANTITY"])) {
         $arResult["ERROR"] = Loc::getMessage("SBB_PRODUCT_NOT_ENOUGH_QUANTITY", array("#PRODUCT#" => $arBasketItem["NAME"], "#NUMBER#" => $desiredQuantity));
     }
     return $arResult;
 }
Beispiel #28
0
 $val["PREVIEW_TEXT"] = '';
 $val["DETAIL_TEXT"] = '';
 if ($boolIBlock) {
     $arIBlockElement = GetIBlockElement($val["PRODUCT_ID"]);
     $val["DETAIL_PAGE_URL"] = $arIBlockElement["DETAIL_PAGE_URL"];
     $val["CREATED_BY"] = $arIBlockElement["CREATED_BY"];
     $val["IBLOCK_ID"] = $arIBlockElement["IBLOCK_ID"];
     $val["IBLOCK_SECTION_ID"] = $arIBlockElement["IBLOCK_SECTION_ID"];
     $val["PREVIEW_PICTURE"] = $arIBlockElement["PREVIEW_PICTURE"];
     $val["DETAIL_PICTURE"] = $arIBlockElement["DETAIL_PICTURE"];
     $val["PREVIEW_TEXT"] = $arIBlockElement["PREVIEW_TEXT"];
     $val["DETAIL_TEXT"] = $arIBlockElement["DETAIL_TEXT"];
 }
 $val["PROPS"] = array();
 if (in_array("PROPS", $arParams["COLUMNS_LIST"]) && $val["ID"] > 0) {
     $dbProp = CSaleBasket::GetPropsList(array("SORT" => "ASC", "ID" => "ASC"), array("BASKET_ID" => $val["ID"], "!CODE" => array("CATALOG.XML_ID", "PRODUCT.XML_ID")));
     while ($arProp = $dbProp->GetNext()) {
         $val["PROPS"][] = $arProp;
     }
 }
 if ($val["DELAY"] == "N" && $val["CAN_BUY"] == "Y") {
     $arResult["ITEMS"]["AnDelCanBuy"][] = $val;
     $DISCOUNT_PRICE_ALL += $val["DISCOUNT_PRICE"] * $val["QUANTITY"];
 }
 if ($val["DELAY"] == "Y" && $val["CAN_BUY"] == "Y") {
     $arResult["ITEMS"]["DelDelCanBuy"][] = $val;
 }
 if ($val["CAN_BUY"] == "N" && $val["SUBSCRIBE"] == "N") {
     $arResult["ITEMS"]["nAnCanBuy"][] = $val;
 }
 if ($val["CAN_BUY"] == "N" && $val["SUBSCRIBE"] == "Y") {
Beispiel #29
0
	/**
	 * <p>Функция обновляет параметры товара, относящиеся к товару как к таковому.</p>
	 *
	 *
	 *
	 *
	 * @param int $ID  Код товара.
	 *
	 *
	 *
	 * @param array $arFields  Ассоциативный массив, ключами которого являются названия
	 * параметров товара, а значениями - новые значения
	 * параметров.<br>Допустимые ключи: <ul> <li> <b>QUANTITY</b> - Количество товара
	 * на складе;</li> <li> <b>QUANTITY_TRACE</b> - Флаг (Y/N/D)<b>*</b> "уменьшать ли
	 * количество при заказе";</li> <li> <b>WEIGHT</b> - вес единицы товара;</li> <li>
	 * <b>PRICE_TYPE</b> - тип цены (S - одноразовый платеж, R - регулярные платежи, T
	 * - пробная подписка);</li> <li> <b>RECUR_SCHEME_TYPE</b> - тип периода подписки ("H" -
	 * час, "D" - сутки, "W" - неделя, "M" - месяц, "Q" - квартал, "S" - полугодие, "Y" -
	 * год);</li> <li> <b>RECUR_SCHEME_LENGTH</b> - длина периода подписки;</li> <li>
	 * <b>TRIAL_PRICE_ID</b> - код товара, для которого данный товар является
	 * пробным;</li> <li> <b>WITHOUT_ORDER</b> - флаг "Продление подписки без
	 * оформления заказа";</li> <li> <b>PURCHASING_PRICE</b> - закупочная цена;</li> <li>
	 * <b>PURCHASING_CURRENCY</b> - валюта закупочной цены;</li> <li> <b>CAN_BUY_ZERO</b> - флаг
	 * (Y/N/D)<b>*</b> "разрешить покупку при отсутствии товара";</li> <li>
	 * <b>NEGATIVE_AMOUNT_TRACE</b> - флаг (Y/N/D)<b>*</b> "разрешить отрицательное
	 * количество товара".</li> </ul>
	 *
	 *
	 *
	 * @return bool <p>Возвращает <i>true</i> в случае успешного обновления параметров и
	 * <i>false</i> в противном случае.</p>
	 *
	 *
	 * <h4>Example</h4> 
	 * <pre>
	 * Обновление зарезервированного количества товара
	 * Cmodule::IncludeModule('catalog');
	 * $PRODUCT_ID = 51; // id товара
	 * $arFields = array('QUANTITY_RESERVED' =&gt; 11);// зарезервированное количество
	 * CCatalogProduct::Update($PRODUCT_ID, $arFields);
	 * </pre>
	 *
	 *
	 * @static
	 * @link http://dev.1c-bitrix.ru/api_help/catalog/classes/ccatalogproduct/ccatalogproduct__update.bc9a623b.php
	 * @author Bitrix
	 */
	static public function Update($ID, $arFields)
	{
		global $DB;

		$ID = intval($ID);
		if (0 >= $ID)
			return false;

		if (array_key_exists('ID', $arFields))
			unset($arFields["ID"]);

		foreach (GetModuleEvents("catalog", "OnBeforeProductUpdate", true) as $arEvent)
		{
			if (ExecuteModuleEventEx($arEvent, array($ID, &$arFields))===false)
				return false;
		}

		if (!CCatalogProduct::CheckFields("UPDATE", $arFields, $ID))
			return false;

		$strUpdate = $DB->PrepareUpdate("b_catalog_product", $arFields);

		$strUpdate = trim($strUpdate);
		$boolSubscribe = false;
		if (!empty($strUpdate))
		{
			if (isset($arFields["QUANTITY"]) && $arFields["QUANTITY"] > 0)
			{
				if (!isset($arFields["OLD_QUANTITY"]))
				{
					$strQuery = 'select ID, QUANTITY from b_catalog_product where ID = '.$ID;
					$rsProducts = $DB->Query($strQuery, false, "File: ".__FILE__."<br>Line: ".__LINE__);
					if ($arProduct = $rsProducts->Fetch())
					{
						$arFields["OLD_QUANTITY"] = doubleval($arProduct['QUANTITY']);
					}
				}
				if (isset($arFields["OLD_QUANTITY"]))
				{
					$boolSubscribe = !(0 < $arFields["OLD_QUANTITY"]);
				}
			}

			$strSql = "UPDATE b_catalog_product SET ".$strUpdate." WHERE ID = ".$ID;
			$DB->Query($strSql, false, "File: ".__FILE__."<br>Line: ".__LINE__);

			if (array_key_exists($ID, self::$arProductCache))
			{
				unset(self::$arProductCache[$ID]);
				if (defined('CATALOG_GLOBAL_VARS') && 'Y' == CATALOG_GLOBAL_VARS)
				{
					global $CATALOG_PRODUCT_CACHE;
					$CATALOG_PRODUCT_CACHE = self::$arProductCache;
				}
			}
		}

		foreach (GetModuleEvents("catalog", "OnProductUpdate", true) as $arEvent)
		{
			ExecuteModuleEventEx($arEvent, array($ID, $arFields));
		}

		//call subscribe
		if ($boolSubscribe && CModule::IncludeModule('sale'))
		{
			CSaleBasket::ProductSubscribe($ID, "catalog");
		}

		return true;
	}
Beispiel #30
0
</td></tr></table>
					<br>
					<div id="tabs">
						<?
						$displayNone = "block";
						$displayNoneBasket = "block";
						$displayNoneViewed = "block";

						$arRecommended = CSaleProduct::GetRecommendetProduct($str_USER_ID, $LID, $arFilterRecommended);

						$arRecommendedResult = fDeleteDoubleProduct($arRecommended, $arFilterRecommended, 'N');
						if (empty($arRecommendedResult["ITEMS"]))
							$displayNone = "none";

						$arCartWithoutSetItems = array();
						$arTmpShoppingCart = CSaleBasket::DoGetUserShoppingCart($LID, $str_USER_ID, $FUSER_ID, $arErrors, $arCoupon);

						if (is_array($arTmpShoppingCart))
						{
							foreach ($arTmpShoppingCart as $arCartItem)
							{
								if (CSaleBasketHelper::isSetItem($arCartItem))
									continue;

								$arCartWithoutSetItems[] = $arCartItem;
							}
						}
						$arShoppingCart = fDeleteDoubleProduct($arCartWithoutSetItems, $arFilterRecommended, 'N');
						if (empty($arShoppingCart["ITEMS"]))
							$displayNoneBasket = "none";