Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
tier.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 /* @var $block \Magento\Catalog\Block\Adminhtml\Product\Edit\Tab\Price\Tier */
10 $element = $block->getElement();
11 ?>
12 <?php $_htmlId = $block->getElement()->getHtmlId() ?>
13 <?php $_htmlClass = $block->getElement()->getClass() ?>
14 <?php $_htmlName = $block->getElement()->getName() ?>
15 <?php $_readonly = $block->getElement()->getReadonly() ?>
16 <?php $_showWebsite = $block->isShowWebsiteColumn(); ?>
17 <?php $_editWebsite = $block->isAllowChangeWebsite(); ?>
18 <?php $_priceValueValidation = $block->getPriceValidation('validate-greater-than-zero'); ?>
19 
20 
21 <?php $_showWebsite = $block->isShowWebsiteColumn(); ?>
22 <?php $_showWebsite = $block->isMultiWebsites(); ?>
23 <div class="field" id="attribute-<?= /* @escapeNotVerified */ $_htmlId ?>-container" data-attribute-code="<?= /* @escapeNotVerified */ $_htmlId ?>"
24  data-apply-to="<?= $block->escapeHtml(
25  $this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode(
26  $element->hasEntityAttribute() ? $element->getEntityAttribute()->getApplyTo() : []
27  )
28  )?>">
29  <label class="label"><span><?= /* @escapeNotVerified */ $block->getElement()->getLabel() ?></span></label>
30  <div class="control">
31  <table class="admin__control-table tiers_table" id="tiers_table">
32  <thead>
33  <tr>
34  <th class="col-websites" <?php if (!$_showWebsite): ?>style="display:none"<?php endif; ?>><?= /* @escapeNotVerified */ __('Web Site') ?></th>
35  <th class="col-customer-group"><?= /* @escapeNotVerified */ __('Customer Group') ?></th>
36  <th class="col-qty required"><?= /* @escapeNotVerified */ __('Quantity') ?></th>
37  <th class="col-price required"><?= /* @escapeNotVerified */ $block->getPriceColumnHeader(__('Item Price')) ?></th>
38  <th class="col-delete"><?= /* @escapeNotVerified */ __('Action') ?></th>
39  </tr>
40  </thead>
41  <tbody id="<?= /* @escapeNotVerified */ $_htmlId ?>_container"></tbody>
42  <tfoot>
43  <tr>
44  <td colspan="<?php if (!$_showWebsite): ?>4<?php else: ?>5<?php endif; ?>" class="col-actions-add"><?= $block->getAddButtonHtml() ?></td>
45  </tr>
46  </tfoot>
47  </table>
48 
49 <script>
50 require([
51  'mage/template',
52  "prototype",
53  "mage/adminhtml/form"
54 ], function (mageTemplate) {
55 
56 //<![CDATA[
57 var tierPriceRowTemplate = '<tr>'
58  + '<td class="col-websites"<?php if (!$_showWebsite): ?> style="display:none"<?php endif; ?>>'
59  + '<select class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry" name="<?= /* @escapeNotVerified */ $_htmlName ?>[<%- data.index %>][website_id]" id="tier_price_row_<%- data.index %>_website">'
60  <?php foreach ($block->getWebsites() as $_websiteId => $_info): ?>
61  + '<option value="<?= /* @escapeNotVerified */ $_websiteId ?>"><?= $block->escapeJs($_info['name']) ?><?php if (!empty($_info['currency'])): ?> [<?= $block->escapeHtml($_info['currency']) ?>]<?php endif; ?></option>'
62  <?php endforeach ?>
63  + '</select></td>'
64  + '<td class="col-customer-group"><select class="<?= /* @escapeNotVerified */ $_htmlClass ?> custgroup required-entry" name="<?= /* @escapeNotVerified */ $_htmlName ?>[<%- data.index %>][cust_group]" id="tier_price_row_<%- data.index %>_cust_group">'
65  <?php foreach ($block->getCustomerGroups() as $_groupId => $_groupName): ?>
66  + '<option value="<?= /* @escapeNotVerified */ $_groupId ?>"><?= $block->escapeJs($_groupName) ?></option>'
67  <?php endforeach ?>
68  + '</select></td>'
69  + '<td class="col-qty">'
70  + '<input class="<?= /* @escapeNotVerified */ $_htmlClass ?> qty required-entry validate-greater-than-zero" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[<%- data.index %>][price_qty]" value="<%- data.qty %>" id="tier_price_row_<%- data.index %>_qty" />'
71  + '<span><?= /* @escapeNotVerified */ __("and above") ?></span>'
72  + '</td>'
73  + '<td class="col-price"><input class="<?= /* @escapeNotVerified */ $_htmlClass ?> required-entry <?= /* @escapeNotVerified */ $_priceValueValidation ?>" type="text" name="<?= /* @escapeNotVerified */ $_htmlName ?>[<%- data.index %>][price]" value="<%- data.price %>" id="tier_price_row_<%- data.index %>_price" /></td>'
74  + '<td class="col-delete"><input type="hidden" name="<?= /* @escapeNotVerified */ $_htmlName ?>[<%- data.index %>][delete]" class="delete" value="" id="tier_price_row_<%- data.index %>_delete" />'
75  + '<button title="<?= /* @escapeNotVerified */ $block->escapeHtml(__('Delete Tier')) ?>" type="button" class="action- scalable delete icon-btn delete-product-option" id="tier_price_row_<%- data.index %>_delete_button" onclick="return tierPriceControl.deleteItem(event);">'
76  + '<span><?= /* @escapeNotVerified */ __("Delete") ?></span></button></td>'
77  + '</tr>';
78 
80  template: mageTemplate(tierPriceRowTemplate),
81  itemsCount: 0,
82  addItem : function () {
83  <?php if ($_readonly): ?>
84  if (arguments.length < 4) {
85  return;
86  }
87  <?php endif; ?>
88  var data = {
89  website_id: '<?= /* @escapeNotVerified */ $block->getDefaultWebsite() ?>',
90  group: '<?= /* @escapeNotVerified */ $block->getDefaultCustomerGroup() ?>',
91  qty: '',
92  price: '',
93  readOnly: false,
94  index: this.itemsCount++
95  };
96 
97  if(arguments.length >= 4) {
98  data.website_id = arguments[0];
99  data.group = arguments[1];
100  data.qty = arguments[2];
101  data.price = arguments[3];
102  }
103  if (arguments.length == 5) {
104  data.readOnly = arguments[4];
105  }
106 
107  Element.insert($('<?= /* @escapeNotVerified */ $_htmlId ?>_container'), {
108  bottom : this.template({
109  data: data
110  })
111  });
112 
113  $('tier_price_row_' + data.index + '_cust_group').value = data.group;
114  $('tier_price_row_' + data.index + '_website').value = data.website_id;
115 
116  <?php if ($block->isShowWebsiteColumn() && !$block->isAllowChangeWebsite()):?>
117  var wss = $('tier_price_row_' + data.index + '_website');
118  var txt = wss.options[wss.selectedIndex].text;
119 
120  wss.insert({after:'<span class="website-name">' + txt + '</span>'});
121  wss.hide();
122  <?php endif;?>
123 
124  if (data.readOnly == '1') {
125  ['website', 'cust_group', 'qty', 'price', 'delete'].each(function(idx){
126  $('tier_price_row_'+data.index+'_'+idx).disabled = true;
127  });
128  $('tier_price_row_'+data.index+'_delete_button').hide();
129  }
130 
131  <?php if ($_readonly): ?>
132  $('<?= /* @escapeNotVerified */ $_htmlId ?>_container').select('input', 'select').each(this.disableElement);
133  $('<?= /* @escapeNotVerified */ $_htmlId ?>_container').up('table').select('button').each(this.disableElement);
134  <?php else: ?>
135  $('<?= /* @escapeNotVerified */ $_htmlId ?>_container').select('input', 'select').each(function(el){ Event.observe(el, 'change', el.setHasChanges.bind(el)); });
136  <?php endif; ?>
137  },
138  disableElement: function(el) {
139  el.disabled = true;
140  el.addClassName('disabled');
141  },
142  deleteItem: function(event) {
143  var tr = Event.findElement(event, 'tr');
144  if (tr) {
145  Element.select(tr, '.delete').each(function(elem){elem.value='1'});
146  Element.select(tr, ['input', 'select']).each(function(elem){elem.hide()});
147  Element.hide(tr);
148  Element.addClassName(tr, 'no-display template');
149  }
150  return false;
151  }
152 };
153 <?php foreach ($block->getValues() as $_item): ?>
154 tierPriceControl.addItem('<?= /* @escapeNotVerified */ $_item['website_id'] ?>', '<?= /* @escapeNotVerified */ $_item['cust_group'] ?>', '<?= /* @escapeNotVerified */ $_item['price_qty']*1 ?>', '<?= /* @escapeNotVerified */ $_item['price'] ?>', <?= (int)!empty($_item['readonly']) ?>);
155 <?php endforeach; ?>
156 <?php if ($_readonly): ?>
157 $('<?= /* @escapeNotVerified */ $_htmlId ?>_container').up('table').select('button')
158  .each(tierPriceControl.disableElement);
159 <?php endif; ?>
160 
161 window.tierPriceControl = tierPriceControl;
162 //]]>
163 
164 });
165 </script>
166  </div>
167 </div>
if(! $_showWebsite) if(! $_showWebsite) if(! $_showWebsite) foreach( $block->getWebsites() as $_websiteId=> $_info)($block->getCustomerGroups() as $_groupId=> $_groupName) var tierPriceControl
Definition: tier.phtml:79
$_priceValueValidation
Definition: tier.phtml:18
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
$_htmlId $_htmlClass $_htmlName $_readonly $_showWebsite
Definition: tier.phtml:16
$_editWebsite
Definition: tier.phtml:17
endif
Definition: tier.phtml:159
__()
Definition: __.php:13
$block
Definition: block.php:8
endforeach
Definition: tier.phtml:155
$element
Definition: tier.phtml:10
$_item
Definition: default.phtml:11
$_htmlId
Definition: array.phtml:12