Created
October 4, 2021 16:36
-
-
Save JamesBondsky/bc1238ccef8415c859a2864adf1cb111 to your computer and use it in GitHub Desktop.
Ограничение службы доставки по свойству товаров в корзине
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RestrictByOutlet extends Bitrix\Sale\Delivery\Restrictions\Base | |
{ | |
public static function getClassTitle() | |
{ | |
return 'Ограничение по свойству outlet'; | |
} | |
public static function getClassDescription() | |
{ | |
return 'Ограничение на службы доставки. Если у всех товаров в корзине свойство равно 128, то не показываем эту службу доставки'; | |
} | |
protected static function extractParams(Bitrix\Sale\Shipment $shipment) | |
{ | |
$items = []; | |
foreach ($shipment->getShipmentItemCollection() as $shipmentItem) { | |
$basketItem = $shipmentItem->getBasketItem(); | |
$items[] = $basketItem->getProductId(); | |
} | |
return self::getItemsProperty($items); | |
} | |
protected static function getItemsProperty($items) { | |
if (!empty($items)) { | |
$dbProps = \CIBlockElement::GetList( | |
[], | |
[ | |
"ACTIVE" => "Y", | |
"IBLOCK_ID" => OFFERS_IBLOCK_ID, | |
"ID" => array_values($items), | |
"!PROPERTY_OF_SEASON" => 128, | |
], | |
false, | |
false, | |
[ | |
'IBLOCK_ID', | |
'ID', | |
'NAME', | |
'PROPERTY_OUTLET', | |
] | |
); | |
$itemsFilter = []; | |
while($ob = $dbProps->Fetch()) | |
{ | |
$itemsFilter[] = $ob; | |
} | |
return $itemsFilter; | |
} | |
return array(); | |
} | |
public static function getParamsStructure($deliveryId = 0) | |
{ | |
return array(); | |
} | |
public static function check($shipmentParams, array $restrictionParams, $deliveryId = 0) | |
{ | |
if (!empty($shipmentParams)) return true; | |
else return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment