В каталоге цена отображается персональная, но в корзине почему-то выводится базовая.
- Пересчёта цены не будет никогда, ни в корзине, ни в админке. Товар положен в корзину "намертво", при смене цены товара этот товар не бует пересчитан
public function changeBasket()
{
if (\Bitrix\Main\Loader::includeModule( "sale" ) && \Bitrix\Main\Loader::includeModule( "catalog" ))
{
global $USER;
$catalog_groups = array();
$db_res = \CCatalogGroup::GetGroupsList(array("GROUP_ID"=>$USER->GetUserGroupArray(), "BUY"=>"Y"));
while($arRes = $db_res->Fetch())
{
array_push($catalog_groups, $arRes['CATALOG_GROUP_ID']);
}
$result = \Bitrix\Sale\Internals\BasketTable::getList(
array (
'select' => array (
'BASE_PRICE',
'PRODUCT_ID',
'LID',
'ID'
),
'filter' => array (
'LID' => SITE_ID,
'FUSER_ID' => \CSaleBasket::GetBasketUserID(),
"ORDER_ID" => "NULL"
)
) );
while ( $BasketItem = $result->fetch() )
{
$Prices = array ();
$dbPrice = \CPrice::GetList( array (
"QUANTITY_FROM" => "ASC",
"QUANTITY_TO" => "ASC",
"SORT" => "ASC"
), array (
"PRODUCT_ID" => $BasketItem['PRODUCT_ID'],
'CATALOG_GROUP_ID' => $catalog_groups
), false, false, array (
"ID",
"CATALOG_GROUP_ID",
"PRICE",
"CURRENCY"
) );
while ( $arPrice = $dbPrice->Fetch() )
{
$arDiscounts = \CCatalogDiscount::GetDiscountByPrice( $arPrice["ID"],
$USER->GetUserGroupArray(), "N", $BasketItem['LID'] );
$discountPrice = \CCatalogProduct::CountPriceWithDiscount( $arPrice["PRICE"], $arPrice["CURRENCY"], $arDiscounts );
$Prices[$arPrice['CATALOG_GROUP_ID']]["DISCOUNT_PRICE"] = $discountPrice;
$Prices[$arPrice['CATALOG_GROUP_ID']]["PRICE"] = $arPrice;
unset( $Prices[$arPrice['ID']]["PRICE"]['ID'] );
}
if($Prices)
{
foreach($Prices as $i => $price)
{
if($_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'])
{
switch ($_SESSION['SOTBIT_REGIONS']['PRICE_VALUE_TYPE'])
{
case 'PROCENT_UP':
$price['DISCOUNT_PRICE'] = $price['DISCOUNT_PRICE'] + ($price['DISCOUNT_PRICE'] / 100) * $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
$price['PRICE']['PRICE'] = $price['PRICE']['PRICE'] + ($price['PRICE']['PRICE'] / 100) * $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
break;
case 'PROCENT_DOWN':
$price['DISCOUNT_PRICE'] = $price['DISCOUNT_PRICE'] - ($price['DISCOUNT_PRICE'] / 100) * $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
$price['PRICE']['PRICE'] = $price['PRICE']['PRICE'] - ($price['PRICE']['PRICE'] / 100) * $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE']; break;
case 'FIX_UP':
$price['DISCOUNT_PRICE'] = $price['DISCOUNT_PRICE'] + $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
$price['PRICE']['PRICE'] = $price['PRICE']['PRICE'] + $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
break;
case 'FIX_DOWN':
$price['DISCOUNT_PRICE'] = $price['DISCOUNT_PRICE'] - $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
$price['PRICE']['PRICE'] = $price['PRICE']['PRICE'] - $_SESSION['SOTBIT_REGIONS']['PRICE_VALUE'];
break;
}
}
if($price['PRICE']['PRICE'] != $BasketItem['BASE_PRICE'])
{
\Bitrix\Sale\Internals\BasketTable::Update( $BasketItem['ID'], array (
'PRICE' => $price['DISCOUNT_PRICE'],
'CURRENCY' => $price['PRICE']['CURRENCY'],
'CUSTOM_PRICE' => 'Y'
) );
}
}
}
}
}
}
array(2) {
[78]=>
array(2) {
["DISCOUNT_PRICE"]=>
float(292.6)
["PRICE"]=>
array(4) {
["ID"]=>
string(8) "13916530"
["CATALOG_GROUP_ID"]=>
string(2) "78"
["PRICE"]=>
string(6) "292.60"
["CURRENCY"]=>
string(3) "RUB"
}
}
[1]=>
array(2) {
["DISCOUNT_PRICE"]=>
float(308)
["PRICE"]=>
array(4) {
["ID"]=>
string(8) "13371316"
["CATALOG_GROUP_ID"]=>
string(1) "1"
["PRICE"]=>
string(6) "308.00"
["CURRENCY"]=>
string(3) "RUB"
}
}
}
всё-таки дело в методе \Bitrix\Sale\Internals\BasketTable::getList()
Я не могу уйти от используемого решения от Сотбит
Почему же этот метод может не видеть величину базовой цены товара?