Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 818.41
- <?
- function OnIBlockElementUpdate(&$arFields)
- {
- if (($arFields['IBLOCK_ID'] == 2 && !CCatalogSKU::IsExistOffers($arFields['ID'], $arFields['IBLOCK_ID'])) || $arFields['IBLOCK_ID'] == 3) {
- $arPrice = CPrice::GetByID($arFields['PRODUCT_ID']);
- $ar_res = CCatalogProduct::GetByID($arFields['ID']);
- if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] > 0) {
- if ($arPrice['TIMESTAMP_X'] == 0) {
- $delivery_expected = ($arFields['IBLOCK_ID'] == '2') ? '23' : '33';
- $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
- $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $delivery_expected]];
- }
- }
- if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] > 0) {
- if ($arPrice['TIMESTAMP_X'] == false) {
- $unavailable = ($arFields['IBLOCK_ID'] == '2') ? '22' : '33';
- $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
- $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $unavailable]];
- }
- }
- if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] == 0) {
- $discontinued = ($arFields['IBLOCK_ID'] == '2') ? '36' : '33';
- $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
- $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $discontinued]];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement