Skip to content

Commit af4d5f3

Browse files
author
Cristian Partica
committed
MAGETWO-31324: Tax labels aren't displayed for Bundle options of "multiple select" & "drop-down" types
- javascript fix and option template restored to the data.* fromat + unit test
1 parent 50075c7 commit af4d5f3

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ define([
1717
qtyFieldSelector: 'input.qty',
1818
priceBoxSelector: '.price-box',
1919
optionHandlers: {},
20-
optionTemplate: '<%- label %>' +
21-
'<% if (finalPrice.value) { %>' +
22-
' +<%- finalPrice.formatted %>' +
20+
optionTemplate: '<%- data.label %>' +
21+
'<% if (data.finalPrice.value) { %>' +
22+
' +<%- data.finalPrice.formatted %>' +
2323
'<% } %>',
2424
controlContainer: 'dd', // should be eliminated
2525
priceFormat: {},
@@ -163,7 +163,9 @@ define([
163163
}
164164

165165
toTemplate = {
166-
label: optionConfig[optionValue] && optionConfig[optionValue].name
166+
data: {
167+
label: optionConfig[optionValue] && optionConfig[optionValue].name
168+
}
167169
};
168170
prices = optionConfig[optionValue].prices;
169171

@@ -172,7 +174,7 @@ define([
172174
value += _.reduce(price.adjustments, function (sum, x) {
173175
return sum + x;
174176
}, 0);
175-
toTemplate[type] = {
177+
toTemplate.data[type] = {
176178
value: value,
177179
formatted: utils.formatPrice(value, format)
178180
};

app/code/Magento/Tax/Model/Observer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,17 @@ public function updateProductOptions(\Magento\Framework\Event\Observer $observer
310310
// prepare correct template for options render
311311
if ($this->_taxData->displayBothPrices()) {
312312
$options['optionTemplate'] = sprintf(
313-
'<%%= label %%>'
314-
. '<%% if (finalPrice.value) { %%>'
315-
. ' <%%= finalPrice.formatted %%> (%1$s <%%= basePrice.formatted %%>)'
313+
'<%%= data.label %%>'
314+
. '<%% if (data.finalPrice.value) { %%>'
315+
. ' <%%= data.finalPrice.formatted %%> (%1$s <%%= data.basePrice.formatted %%>)'
316316
. '<%% } %%>',
317317
__('Excl. tax:')
318318
);
319319
} elseif ($this->_taxData->priceIncludesTax() && $this->_taxData->displayPriceExcludingTax()) {
320320
$options['optionTemplate'] = sprintf(
321-
'<%%= label %%>'
322-
. '<%% if (basePrice.value) { %%>'
323-
. ' <%%= basePrice.formatted %%>'
321+
'<%%= data.label %%>'
322+
. '<%% if (data.basePrice.value) { %%>'
323+
. ' <%%= data.basePrice.formatted %%>'
324324
. '<%% } %%>'
325325
);
326326
}

app/code/Magento/Tax/Test/Unit/Model/ObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ public function dataProviderUpdateProductOptions()
9090
[
9191
'expected' => [
9292
'calculationAlgorithm' => 'TOTAL_BASE_CALCULATION',
93-
'optionTemplate' => '<%= label %><% if (finalPrice.value) '.
94-
'{ %> <%= finalPrice.formatted %> (Excl. tax: <%= basePrice.formatted %>)<% } %>',
93+
'optionTemplate' => '<%= data.label %><% if (data.finalPrice.value) '.
94+
'{ %> <%= data.finalPrice.formatted %> (Excl. tax: <%= data.basePrice.formatted %>)<% } %>',
9595
],
9696
'displayBothPrices' => true,
9797
'priceIncludesTax' => false,
@@ -100,7 +100,7 @@ public function dataProviderUpdateProductOptions()
100100
[
101101
'expected' => [
102102
'calculationAlgorithm' => 'TOTAL_BASE_CALCULATION',
103-
'optionTemplate' => '<%= label %><% if (basePrice.value) { %> <%= basePrice.formatted %><% } %>',
103+
'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) { %> <%= data.basePrice.formatted %><% } %>',
104104
],
105105
'displayBothPrices' => false,
106106
'priceIncludesTax' => true,

0 commit comments

Comments
 (0)