Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
bundle.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 
11 <?php /* @var $block \Magento\Bundle\Block\Adminhtml\Catalog\Product\Composite\Fieldset\Bundle */ ?>
12 <?php $options = $block->decorateArray($block->getOptions(true)); ?>
13 <?php if (count($options)): ?>
14 <fieldset id="catalog_product_composite_configure_fields_bundle"
15  class="fieldset admin__fieldset composite-bundle<?= $block->getIsLastFieldset() ? ' last-fieldset' : '' ?>">
16  <legend class="legend admin__legend"><span><?= /* @escapeNotVerified */ __('Bundle Items') ?></span></legend><br />
17  <?php foreach ($options as $option) : ?>
18  <?php if ($option->getSelections()) : ?>
19  <?= $block->getOptionHtml($option) ?>
20  <?php endif; ?>
21  <?php endforeach; ?>
22 </fieldset>
23 
24 <script>
25 require([
26  "Magento_Catalog/catalog/product/composite/configure"
27 ], function(){
28  BundleControl = Class.create();
29 
30  BundleControl.prototype = {
31  initialize: function (config) {
32  this.config = config;
33  },
34 
35  changeSelection: function (selection) {
36  if (selection.multiple) {
37  return;
38  }
39  var parts = selection.id.split('-'), optionId = parts[2],
40  showQtyInput = selection.value && selection.value != 'none',
41  options = this.config.options[optionId],
42  selectionOptions = options && options.selections && options.selections[selection.value] || {};
43 
44  selectionOptions.can_change_qty = Number(selectionOptions.can_change_qty) && showQtyInput;
45  this.updateQtyInput(optionId, selectionOptions);
46  },
47 
48  updateQtyInput: function(optionId, selectionOptions) {
49  var elem = $('bundle-option-' + optionId + '-qty-input'),
50  default_qty = Number(selectionOptions.default_qty);
51  if (!elem) {
52  return;
53  }
54  if (selectionOptions.can_change_qty) {
55  elem.removeClassName('qty-disabled');
56  elem.disabled = false;
57  elem.value = default_qty || 1;
58  } else {
59  elem.addClassName('qty-disabled');
60  elem.disabled = true;
61  elem.value = default_qty || 0;
62  }
63  },
64 
65  updateForDefaults: function () {
66  for (var optionId in this.config.options) {
67  var selection = $('bundle-option-' + optionId);
68  if (selection) {
69  this.changeSelection(selection);
70  }
71  }
72  }
73  };
74  ProductConfigure.bundleControl = new BundleControl(<?= /* @escapeNotVerified */ $block->getJsonConfig() ?>);
75 });
76 </script>
77 
78 <?php endif; ?>
endif
Definition: bundle.phtml:74
__()
Definition: __.php:13
$options
Definition: bundle.phtml:12
$block
Definition: block.php:8
endforeach
Definition: bundle.phtml:21