3namespace Sale\Handlers\DiscountPreset;
5use Bitrix\Main\Localization\Loc;
6use Bitrix\Sale\Discount\Preset\ArrayHelper;
7use Bitrix\Sale\Discount\Preset\Manager;
8use Bitrix\Sale\Discount\Preset\SelectProductPreset;
9use Bitrix\Sale\Discount\Preset\State;
10use Bitrix\Sale\Internals;
16 return Loc::getMessage(
'SALE_HANDLERS_DISCOUNTPRESET_SIMPLEPRODUCT_NAME');
29 return Manager::CATEGORY_PRODUCTS;
37 public function processShowInputName(State $state)
42 public function processSaveInputName(State $state)
47 public function processShowInputAmount(State $state)
49 $lid = (string)$state->get(
'discount_lid');
50 $currency = Internals\SiteCurrencyTable::getSiteCurrency($lid);
52 $sectionCount =
count($state->get(
'discount_section', []));
55 <table width="100%" border="0" cellspacing="7" cellpadding="0">
61 <script type="application/javascript">
63 new BX.Sale.Admin.DiscountPreset.SelectProduct({
64 presetId: "' . \CUtil::JSEscape($this->
className()) .
'",
65 siteId: "' . \CUtil::JSEscape($lid) .
'",
66 sectionCount: ' . $sectionCount .
',
67 products: ' . \CUtil::PhpToJSObject($this->
generateProductsData($state->get(
'discount_product'), $lid)) .
'
77 public function processSaveInputAmount(State $state)
79 if (!trim((
string)$state->get(
'discount_value')))
86 if (!$this->errorCollection->isEmpty())
88 return [$state,
'InputAmount'];
91 return [$state,
'CommonSettings'];
94 public function processShowCommonSettings(State $state)
99 public function processSaveCommonSettings(State $state)
104 public function generateState(
array $discountFields)
109 'discount_value' => ArrayHelper::getByPath($discountFields,
'ACTIONS.CHILDREN.0.DATA.Value'),
110 'discount_type' => ArrayHelper::getByPath($discountFields,
'ACTIONS.CHILDREN.0.DATA.Unit'),
111 'discount_section' => $this->
getSectionsFromConditions(ArrayHelper::getByPath($discountFields,
'CONDITIONS.CHILDREN.0.CHILDREN')),
112 'discount_product' => $this->
getProductsFromConditions(ArrayHelper::getByPath($discountFields,
'CONDITIONS.CHILDREN.0.CHILDREN')),
115 return parent::generateState($discountFields)->append($stateFields);
118 public function generateDiscount(State $state)
121 parent::generateDiscount($state),
124 'CLASS_ID' =>
'CondGroup',
131 'CLASS_ID' =>
'CondBsktProductGroup',
136 'CHILDREN' => array_merge(
138 $this->generateProductConditions($state->get(
'discount_product'))
144 'CLASS_ID' =>
'CondGroup',
150 'CLASS_ID' =>
'ActSaleBsktGrp',
152 'Type' => $this->getTypeOfDiscount(),
153 'Value' => $state->get(
'discount_value'),
154 'Unit' => $state->get(
'discount_type',
'CurAll'),
160 $this->generateSectionActions($state->get(
'discount_section')),
161 $this->generateProductActions($state->get(
'discount_product')),
normalizeDiscountFields(array $discountFields)
processSaveCommonSettingsInternal(State $state, $nextStep=self::FINAL_STEP)
processSaveInputNameInternal(State $state, $nextStep)
processShowInputNameInternal(State $state)
renderDiscountValue(State $state, $currency)
processShowCommonSettingsInternal(State $state)
addErrorEmptyActionValue()
getSectionsFromConditions(array $conditions=null)
validateSectionsAndProductsState(State $state, ErrorCollection $errorCollection)
generateSectionConditions($sectionIds, $logic='Equal')
generateProductsData($productIds, $siteId)
renderSectionBlock(State $state, $inputName='discount_section', $multi=true)
renderElementBlock(State $state, $inputName='discount_product', $multi=true)
getProductsFromConditions(array $conditions=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"