Пример #1
0
            $basket->priceVatShowValue = isset($_POST["price_vat_show_value"]) && $_POST["price_vat_show_value"] == "Y" ? "Y" : "N";
            $basket->hideCoupon = isset($_POST["hide_coupon"]) && $_POST["hide_coupon"] == "Y" ? "Y" : "N";
            $basket->usePrepayment = isset($_POST["use_prepayment"]) && $_POST["use_prepayment"] == "Y" ? "Y" : "N";
            $res = $basket->recalculateBasket($_POST);
            foreach ($res as $key => $value) {
                $arRes[$key] = $value;
            }
            $arRes["BASKET_DATA"] = $basket->getBasketItems();
            $arRes["BASKET_DATA"]["GRID"]["HEADERS"] = $basket->getCustomColumns();
            $arRes["COLUMNS"] = $strColumns;
            $arRes["CODE"] = "SUCCESS";
            if (!empty($_POST["coupon"]) && $arRes['VALID_COUPON'] === true) {
                if (!empty($arRes['BASKET_DATA']['FULL_DISCOUNT_LIST'])) {
                    global $USER;
                    $userId = $USER instanceof CAllUser ? $USER->getId() : null;
                    $giftManager = \Bitrix\Sale\Discount\Gift\Manager::getInstance()->setUserId($userId);
                    \Bitrix\Sale\Compatible\DiscountCompatibility::stopUsageCompatible();
                    $collections = $giftManager->getCollectionsByBasket(\Bitrix\Sale\Basket::loadItemsForFUser(\Bitrix\Sale\Fuser::getId(), SITE_ID), $arRes['BASKET_DATA']['FULL_DISCOUNT_LIST'], $arRes['BASKET_DATA']['APPLIED_DISCOUNT_LIST']);
                    \Bitrix\Sale\Compatible\DiscountCompatibility::revertUsageCompatible();
                    if (count($collections)) {
                        $arRes['BASKET_DATA']['NEED_TO_RELOAD_FOR_GETTING_GIFTS'] = true;
                    }
                }
            }
        }
    }
}
unset($arRes['BASKET_DATA']['APPLIED_DISCOUNT_LIST'], $arRes['BASKET_DATA']['FULL_DISCOUNT_LIST']);
$arRes["PARAMS"]["QUANTITY_FLOAT"] = isset($_POST["quantity_float"]) && $_POST["quantity_float"] == "Y" ? "Y" : "N";
$APPLICATION->RestartBuffer();
header('Content-Type: application/json; charset=' . LANG_CHARSET);
Пример #2
-1
 public function Update($ID, $arFields)
 {
     global $DB;
     $ID = (int) $ID;
     if ($ID <= 0) {
         return false;
     }
     $boolNewVersion = true;
     $arFields['ID'] = $ID;
     if (!array_key_exists('CONDITIONS', $arFields) && !array_key_exists('ACTIONS', $arFields)) {
         $boolConvert = CSaleDiscount::__ConvertOldFormat('UPDATE', $arFields);
         if (!$boolConvert) {
             return false;
         }
         $boolNewVersion = false;
     }
     if (!CSaleDiscount::CheckFields("UPDATE", $arFields)) {
         return false;
     }
     if ($boolNewVersion) {
         $boolConvert = CSaleDiscount::__SetOldFields('UPDATE', $arFields);
         if (!$boolConvert) {
             return false;
         }
     }
     $strUpdate = $DB->PrepareUpdate("b_sale_discount", $arFields);
     if (!empty($strUpdate)) {
         $strSql = "update b_sale_discount set " . $strUpdate . " where ID = " . $ID;
         $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     }
     if (isset($arFields['USER_GROUPS'])) {
         Internals\DiscountGroupTable::updateByDiscount($ID, $arFields['USER_GROUPS'], isset($arFields['ACTIVE']) ? $arFields['ACTIVE'] : '', true);
     } elseif (isset($arFields['ACTIVE'])) {
         Internals\DiscountGroupTable::changeActiveByDiscount($ID, $arFields['ACTIVE']);
     }
     if (isset($arFields['HANDLERS'])) {
         self::updateDiscountHandlers($ID, $arFields['HANDLERS'], true);
     }
     if (isset($arFields['ENTITIES'])) {
         Internals\DiscountEntitiesTable::updateByDiscount($ID, $arFields['ENTITIES'], true);
     }
     if (isset($arFields['ACTIONS']) && is_string($arFields['ACTIONS'])) {
         \Bitrix\Sale\Discount\Gift\RelatedDataTable::deleteByDiscount($ID);
         $giftManager = \Bitrix\Sale\Discount\Gift\Manager::getInstance();
         if ($giftManager->isContainGiftAction($arFields)) {
             if (!$giftManager->existsDiscountsWithGift()) {
                 $giftManager->enableExistenceDiscountsWithGift();
             }
             \Bitrix\Sale\Discount\Gift\RelatedDataTable::fillByDiscount($arFields + array('ID' => $ID));
         }
     }
     return $ID;
 }
Пример #3
-1
 /**
  * Default onAfterUpdate handler. Absolutely necessary.
  *
  * @param Main\Entity\Event $event		Event object.
  * @return void
  */
 public static function onAfterUpdate(Main\Entity\Event $event)
 {
     $id = $event->getParameter('id');
     $id = end($id);
     $data = $event->getParameter('fields');
     if (isset($data['ACTIVE'])) {
         DiscountGroupTable::changeActiveByDiscount($id, $data['ACTIVE']);
     }
     if (isset($fields['ACTIONS_LIST'])) {
         $giftManager = Gift\Manager::getInstance();
         if (!$giftManager->existsDiscountsWithGift() && $giftManager->isContainGiftAction($data)) {
             $giftManager->enableExistenceDiscountsWithGift();
         }
     }
     unset($data, $id);
 }