Skip to content

Commit 497fce2

Browse files
refactored template
1 parent 00f3514 commit 497fce2

File tree

1 file changed

+25
-13
lines changed
  • app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option

1 file changed

+25
-13
lines changed

app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/type/bundle/option/checkbox.phtml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
<?php /* @var $block \Magento\Bundle\Block\Catalog\Product\View\Type\Bundle\Option\Checkbox */ ?>
99
<?php $_option = $block->getOption() ?>
1010
<?php $_selections = $_option->getSelections() ?>
11+
<?php $inputClass = 'checkbox product bundle option bundle-option-' . $block->escapeHtmlAttr($_option->getId()) ?>
12+
<?php $inputId = 'bundle-option-' . $block->escapeHtmlAttr($_option->getId()) ?>
13+
<?php $inputName = 'bundle_option[' . $block->escapeHtmlAttr($_option->getId()) . ']' ?>
14+
<?php $dataValidation = 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' .
15+
$block->escapeHtmlAttr($_option->getId()) . ']&quot;]:checked\'}"' ?>
16+
1117
<div class="field option <?= ($_option->getRequired()) ? ' required': '' ?>">
1218
<label class="label">
1319
<span><?= $block->escapeHtml($_option->getTitle()) ?></span>
@@ -22,24 +28,30 @@
2228
name="bundle_option[<?= $block->escapeHtml($_option->getId()) ?>]"
2329
value="<?= $block->escapeHtmlAttr($_selections[0]->getSelectionId()) ?>"/>
2430
<?php else: ?>
25-
<?php foreach ($_selections as $_selection): ?>
31+
<?php foreach ($_selections as $selection): ?>
32+
<?php $sectionId = $selection->getSelectionId() ?>
2633
<div class="field choice">
27-
<?php /** phpcs:disable */ ?>
28-
<input class="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?> checkbox product bundle option change-container-classname"
29-
id="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
34+
<input class="<?=/* @noEscape */ $inputClass ?> change-container-classname"
35+
id="<?=/* @noEscape */ $inputId . '-' . $block->escapeHtmlAttr($sectionId)?>"
3036
type="checkbox"
31-
<?php if ($_option->getRequired()) { echo 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' . $block->escapeHtmlAttr($_option->getId()) . ']&quot;]:checked\'}"'; } ?>
32-
name="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][<?= $block->escapeHtmlAttr($_selection->getId()) ?>]"
33-
data-selector="bundle_option[<?= $block->escapeHtmlAttr($_option->getId()) ?>][<?= $block->escapeHtmlAttr($_selection->getId()) ?>]"
34-
<?php if ($block->isSelected($_selection)) { echo ' checked="checked"'; } ?>
35-
<?php if (!$_selection->isSaleable()) { echo ' disabled="disabled"'; } ?>
36-
value="<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>"
37+
<?php if ($_option->getRequired()): ?>
38+
<?= /* @noEscape */ $dataValidation ?>
39+
<?php endif;?>
40+
name="<?=/* @noEscape */ $inputName .'['. $block->escapeHtmlAttr($sectionId)?>]"
41+
data-selector="<?= /* @noEscape */ $inputName.'['.$block->escapeHtmlAttr($sectionId)?>]"
42+
<?php if ($block->isSelected($selection)): ?>
43+
<?= ' checked="checked"' ?>
44+
<?php endif; ?>
45+
<?php if (!$selection->isSaleable()): ?>
46+
<?= ' disabled="disabled"' ?>
47+
<?php endif; ?>
48+
value="<?= $block->escapeHtmlAttr($sectionId) ?>"
3749
data-errors-message-box="#validation-message-box"/>
3850
<label class="label"
39-
for="bundle-option-<?= $block->escapeHtmlAttr($_option->getId()) ?>-<?= $block->escapeHtmlAttr($_selection->getSelectionId()) ?>">
40-
<span><?= /* @noEscape */ $block->getSelectionQtyTitlePrice($_selection) ?></span>
51+
for="<?= /* @noEscape */ $inputId . '-' . $block->escapeHtmlAttr($sectionId) ?>">
52+
<span><?= /* @noEscape */ $block->getSelectionQtyTitlePrice($selection) ?></span>
4153
<br/>
42-
<?= /* @noEscape */ $block->getTierPriceRenderer()->renderTierPrice($_selection) ?>
54+
<?= /* @noEscape */ $block->getTierPriceRenderer()->renderTierPrice($selection) ?>
4355
</label>
4456
</div>
4557
<?php endforeach; ?>

0 commit comments

Comments
 (0)