Skip to content

Instantly share code, notes, and snippets.

@EscApp2
Created November 11, 2024 13:48
Show Gist options
  • Select an option

  • Save EscApp2/d5ca30846cea8b05e91abbb10fd26c7b to your computer and use it in GitHub Desktop.

Select an option

Save EscApp2/d5ca30846cea8b05e91abbb10fd26c7b to your computer and use it in GitHub Desktop.
Очищать старые корзины
<?
/*
* task- Нужно очищать все корзины - поставить агента 28800
* */
function clearAllBasketsAgent(){
$day = 7;
\Bitrix\Main\Loader::includeModule('sale');
$date = date('d.m.Y', time() - 86400 * $day);
$obBasket = \Bitrix\Sale\Basket::getList(
array(
'select' => array(
'FUSER_ID'
),
'filter' => array(
'ORDER_ID' => false,
'<=DATE_INSERT' => $date, //DATE_UPDATE
),
)
);
while($bItem = $obBasket->Fetch()){
CSaleBasket::DeleteAll(
$bItem['FUSER_ID'],
False
);
}
return "clearAllBasketsAgent();";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment