CModule::IncludeModule('iblock');
$IBLOCK_ID = 49;
$elDB = CIBlockElement::GetList(
array('SORT' => 'asc'),
array('IBLOCK_ID'=> $IBLOCK_ID),
false,
false,
array('ID', 'NAME', 'CODE', 'PROPERTY_CML2_ARTICLE')
);
while($arEl = $elDB->GetNext(false, false))
{
// echo '<pre>';
// print_r($arEl);
// echo '</pre>';
$arParams = array("replace_space"=>"-","replace_other"=>"-");
$trans = $arEl[PROPERTY_CML2_ARTICLE_VALUE];
// echo '<pre>';
// print_r($trans);
// echo '</pre>';
$el = new CIBlockElement;
$arLoadProductArray = Array(
'CODE' =>$trans
);
$res = $el->Update($arEl['ID'], $arLoadProductArray);
}
$total = count($basket);
$counter = 0;
foreach ($basket as $key => $basketItem) {
$counter++;
if($counter == $total and $counter == "1"){
// делаем что-либо с последним элементом...
}
else{
$basketItem->delete(); // делаем что-либо с каждым элементом
}
}
<?$fuserId = CSaleBasket::GetBasketUserID();
$dbBasketItems = CSaleBasket::GetList(
array("ID" => "ASC"),
array(
"FUSER_ID" => $fuserId,
"LID" => SITE_ID,
"ORDER_ID" => "NULL",
"DELAY"=>"N"
),
false,
false,
array(
"ID", "NAME", "CALLBACK_FUNC", "MODULE", "PRODUCT_ID", "PRODUCT_PRICE_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 ($arBasketItems = $dbBasketItems->Fetch())
{
$allSum = ($arBasketItems["PRICE"] * $arBasketItems["QUANTITY"]);
$allWeight = ($arBasketItems["WEIGHT"] * $arBasketItems["QUANTITY"]);
$arResult[] = $arBasketItems;
}
$arOrder = array(
'SITE_ID' => SITE_ID,
'USER_ID' => $GLOBALS["USER"]->GetID(),
'ORDER_PRICE' => $allSum, // сумма всей корзины
'ORDER_WEIGHT' => $allWeight, // вес всей корзины
'BASKET_ITEMS' => $arResult // товары сами
);
$arOptions = array(
'COUNT_DISCOUNT_4_ALL_QUANTITY' => "Y",
);
$arErrors = array();
CSaleDiscount::DoProcessOrder($arOrder, $arOptions, $arErrors);
echo $arOrder["ORDER_PRICE"];?>
<?$basket = \Bitrix\Sale\Basket::loadItemsForFUser(
\Bitrix\Sale\Fuser::getId(),
\Bitrix\Main\Context::getCurrent()->getSite()
); // текущая корзина
$fuser = new \Bitrix\Sale\Discount\Context\Fuser($basket->getFUserId(true));
$discounts = \Bitrix\Sale\Discount::buildFromBasket($basket, $fuser);
$discounts->calculate();
$result = $discounts->getApplyResult(true);
$prices = $result['PRICES']['BASKET']; // цены товаров с учетом скидки
print_r($prices);
foreach ($prices as $price):
//echo $price[PRICE];?><br>
<?
$summs[]=$price[PRICE];
?>
<?endforeach;?>
<?
$a = array($summs);
$summsss = array_sum($summs);
echo $summsss;?>
$sorts[] = $enum_fields[VALUE];
$ids[] = $enum_fields[ID];
}
natsort($sorts);
foreach (array_combine($sorts, $ids) as $code => $name) {
echo $code?>-<?=$name;?><br>
<?}
?>
natsort($sorts);
на sort($sorts);
setTimeout(function() { $("#bookbutcart").load("/include/bookbutoon_cart.php"); // замена области в этом файле
}, 3000);
<?
// Выведем актуальную корзину для текущего пользователя
$dbBasketItems = CSaleBasket::GetList(
array(
"NAME" => "ASC",
"ID" => "ASC"
),
array(
"FUSER_ID" => CSaleBasket::GetBasketUserID(),
"LID" => SITE_ID,
// "PRODUCT_ID" => $arResult["ITEMS"], //ID текущего товара
"ORDER_ID" => "NULL",
"DELAY" => "N" //Исключая отложенные
),
false,
false,
array("PRODUCT_ID")
);
while ($arItemsBasket = $dbBasketItems->Fetch()) {
$itInBasket = $arItemsBasket['PRODUCT_ID'];
//echo $itInBasket ;?><br>
<? if (isset($itInBasket)) {?>
<script>
if (localStorage.getItem('addClass') == 'true') {
$('.buy-btn[data-id="<?=$itInBasket?>"]').addClass('green-btn').text("В корзине");
}
</script>
<?} else { //Если товара нет (переменная пустая) ?>
<?}
}
?>
<img id="img<?=$arItem['ID'];?>" src="<?=$img['src']?>" alt="">
<a class="bt_yellow to_carts list" data-rel="<?=$arItem['ID']?>">Купить</a>
id = $(this).attr("data-rel");
tmp="#img"+id;
$(tmp)
.clone()
.css({'position' : 'absolute', 'z-index' : '11100', top: $(this).offset().top-300, left:$(this).offset().left-100})
.appendTo("body")
.animate({opacity: 0.2,
left: $(".bt_basket").offset()['left'],
top: $(".bt_basket").offset()['top'],
width: 0}, 1000, function() {
$(this).remove();
});
$(document).on('click','#delete-us<?=$arItem['ID']?>',function(){
$.ajax({
type: "POST",
url: "/include/delete-user.php",
data: ({id:<?=$arItem['ID']?>}),
cache: false,
success: function(data) {
$("#dialerDiv1").load("/include/after-delete.php");
},
});
});
success: function(data) {
$("#dialerDiv1").load("/include/after-delete.php");
},
<? if (strstr($_SERVER['REQUEST_URI'], "?sort=price&order=asc")) {?>
<a class="catalog-sort__link active" href="?sort=price&order=desc">
<span>По цене</span>
</a>
<script>
var link = $(".catalog-sort__link");
$(".catalog-sort__link").on("click", "span", function() {
link.attr("href", "?sort=price&order=desc");
});
</script>
<?}
elseif (strstr($_SERVER['REQUEST_URI'], "?sort=price&order=desc")) {?>
<a class="catalog-sort__link active" href="?sort=price&order=asc">
<span>По цене</span>
</a>
<script>
var link = $(".catalog-sort__link");
$(".catalog-sort__link").on("click", "span", function() {
link.attr("href", "?sort=price&order=asc");
});
</script>
<?}
else {?>
<a class="catalog-sort__link" href="?sort=price&order=asc" >
<span>По цене</span>
</a>
<?}?>