AnonSec Shell
Server IP : 85.193.89.191  /  Your IP : 3.142.166.206
Web Server : Apache
System : Linux 956367-cx40159.tmweb.ru 3.10.0-1160.105.1.el7.x86_64 #1 SMP Thu Dec 7 15:39:45 UTC 2023 x86_64
User : bitrix ( 600)
PHP Version : 8.1.27
Disable Function : NONE
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/bitrix/www/local/php_interface/include/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     

Current File : /home/bitrix/www/local/php_interface/include/basketCatalogProductProvider.php
<?
use \Bitrix\Main\Loader,
    \Bitrix\Main\Localization\Loc;

Loader::includeModule('catalog');
Loader::includeModule('sale');

class basketCatalogProductProvider extends CCatalogProductProvider{
    private static function checkProductCost($productId, $quantity, $arBasketItem){

		$optPriceTypeID = COption::GetOptionString('main', 'basket_id_price_opt', '', SITE_ID);
		$basePriceTypeID = COption::GetOptionString('main', 'basket_id_price_base', '', SITE_ID);

		$sumOpt = COption::GetOptionString('main', 'basket_recalc_summ', '10000', SITE_ID);

		if($optPriceTypeID && $basePriceTypeID && $sumOpt){
		
			//текущая сумма корзины
			$summ = 0;
			$dbBasketItems = CSaleBasket::GetList(
				array(),
				array(
						"FUSER_ID" => CSaleBasket::GetBasketUserID(),
						"LID" => SITE_ID,
						"ORDER_ID" => "NULL",
						"!DELAY" => "Y"
					),
				false,
				false,
				array("ID", "QUANTITY", "PRODUCT_ID", 'NAME')
			);
			
			$isCh = false;
			$k = 0;
			
			while ($arRow = $dbBasketItems->Fetch())
			{
				$k++;
				$arPriceBase = CPrice::GetList(
					array(),
					array(
							"PRODUCT_ID" => $arRow['PRODUCT_ID'],
							"CATALOG_GROUP_ID" => $basePriceTypeID				
						)
				)->Fetch();
				

				$quantity = $arRow['QUANTITY'];
				if($arRow['NAME'] == $arBasketItem['NAME'] && $arRow['QUANTITY'] != $arBasketItem['QUANTITY']){
					$_SESSION['custom_price_id'] = '';
					$_SESSION['custom_price_summ'] = '';
					$quantity = $arBasketItem['QUANTITY'];
					$isCh = true;
				}
				$summ += $quantity * $arPriceBase['PRICE'] ;			
				
			}
			
			if(empty($_SESSION['custom_basket_count'])){
				$_SESSION['custom_basket_count'] = $k;
			}
		
			
			if(!$isCh && $_SESSION['custom_price_id'] > 0){
				$_SESSION['custom_price_id'] = '';
				$_SESSION['custom_price_summ'] = '';
			}

			/*if($_SESSION['custom_basket_count'] != $k){
				$_SESSION['custom_price_id'] = '';
				$_SESSION['custom_price_summ'] = '';
				$_SESSION['custom_basket_count'] = '';
			}*/
			
			if(!empty($_SESSION['custom_price_summ'])){
				$summ = $_SESSION['custom_price_summ'];
			}
			
			if($summ >= $sumOpt){
				$priceTypeID = $optPriceTypeID;
			}else{
				$priceTypeID = $basePriceTypeID;
			}
			

			if(empty($_SESSION['custom_price_id'])){
				$_SESSION['custom_price_id'] = $priceTypeID;
				$_SESSION['custom_price_summ'] = $summ;
			}else{
				$priceTypeID = $_SESSION['custom_price_id'];
			}
			$arPrice = CPrice::GetList(
				array(),
				array(
						"PRODUCT_ID" => $productId,
						"CATALOG_GROUP_ID" => $priceTypeID				
					)
			)->Fetch();

			if($arPrice['ID'] != $arBasketItem['PRICE_TYPE_ID']){
				$arResultPrice['PRICE_TYPE_ID'] =  $priceTypeID;
				$arResultPrice['PRODUCT_PRICE_ID'] = $arPrice['ID'];
				$arResultPrice['BASE_PRICE'] =  $arPrice['PRICE'];
				$arResultPrice['PRICE'] =  $arPrice['PRICE'];
			}else{
				$arResultPrice['PRICE_TYPE_ID'] =  $arBasketItem['PRICE_TYPE_ID'];
				$arResultPrice['BASE_PRICE'] =  $arBasketItem['PRICE'];
				$arResultPrice['PRICE'] =  $arBasketItem['PRICE'];
			}
		}else{
			$arResultPrice['BASE_PRICE'] =  $arBasketItem['PRICE'];
			$arResultPrice['PRICE'] =  $arBasketItem['PRICE'];
		}

		$arPriceType = CCatalogGroup::GetList(
			array("SORT" => "ASC"),
			array('ID' => $priceTypeID)
		)->Fetch();

		$arResultPrice['NOTES'] =  $arPriceType['NAME_LANG'];

        return $arResultPrice;
    }
 
    public static function GetProductData($arParams){
		

        $basketId = $arParams['BASKET_ID'];
		
		$data = CCatalogProductProvider::GetProductData($arParams);
		$arPrice = self::checkProductCost($arParams['PRODUCT_ID'], $arParams['QUANTITY'], $data);
		$data = array_merge($data, $arPrice); 



        return $data;
         
    }
}

Anon7 - 2022
AnonSec Team