Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. 818.41
  2.  
  3. <?
  4. function OnIBlockElementUpdate(&$arFields)
  5. {
  6. if (($arFields['IBLOCK_ID'] == 2 && !CCatalogSKU::IsExistOffers($arFields['ID'], $arFields['IBLOCK_ID'])) || $arFields['IBLOCK_ID'] == 3) {
  7. $arPrice = CPrice::GetByID($arFields['PRODUCT_ID']);
  8. $ar_res = CCatalogProduct::GetByID($arFields['ID']);
  9.  
  10. if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] > 0) {
  11.  
  12. if ($arPrice['TIMESTAMP_X'] == 0) {
  13.  
  14. $delivery_expected = ($arFields['IBLOCK_ID'] == '2') ? '23' : '33';
  15. $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
  16.  
  17. $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $delivery_expected]];
  18. }
  19. }
  20.  
  21. if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] > 0) {
  22.  
  23. if ($arPrice['TIMESTAMP_X'] == false) {
  24.  
  25. $unavailable = ($arFields['IBLOCK_ID'] == '2') ? '22' : '33';
  26. $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
  27.  
  28. $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $unavailable]];
  29. }
  30. }
  31.  
  32. if ($ar_res['QUANTITY'] == 0 && $arPrice['PRICE'] == 0) {
  33.  
  34.  
  35. $discontinued = ($arFields['IBLOCK_ID'] == '2') ? '36' : '33';
  36. $porduct_state = ($arFields['IBLOCK_ID'] == '2') ? '60' : '92';
  37.  
  38.  
  39. $arFields['PROPERTY_VALUES'][$porduct_state] = [0 => ["VALUE" => $discontinued]];
  40.  
  41. }
  42.  
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement