Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/code/Magento/Tax/view/frontend/templates/order/tax.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
<td <?= /* @noEscape */ $block->getLabelProperties() ?>>
<?= $block->escapeHtml($title) ?>
<?php if ($percent !== null) : ?>
(<?= (float) $percent ?>%)
(<?= number_format((float)$percent, 1, ',', '') ?>%)
<?php endif; ?>

<br />
</td>
<td <?= /* @noEscape */ $block->getValueProperties() ?> rowspan="1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ define([
*/
isCalculated: function () {
return this.totals() && totals.getSegment('tax') !== null;
}
},

formatPercent: function (percent) {
try {
var locale = (window.checkoutConfig && window.checkoutConfig.locale)
? window.checkoutConfig.locale.replace('_', '-')
: 'de-DE'; // fallback

if (typeof percent === 'number' || (typeof percent === 'string' && percent.match(/^[\d.]+$/))) {
return parseFloat(percent).toLocaleString(locale, {
minimumFractionDigits: 1,
maximumFractionDigits: 2
});
}
} catch (e) {
console.warn('Percent formatting failed:', e);
}
return percent;
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
<!-- ko foreach: rates -->
<tr class="totals-tax-details">
<!-- ko if: percent -->
<th class="mark" scope="row" colspan="1" data-bind="text: title + ' (' + percent + '%)'"></th>
<th class="mark" scope="row" colspan="1"
data-bind="text: title + ' (' + $parents[1].formatPercent(percent) + '%)'"></th>
<!-- /ko -->
<!-- ko if: !percent -->
<th class="mark" scope="row" colspan="1" data-bind="text: title"></th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@
<!-- ko foreach: rates -->
<tr class="totals-tax-details">
<!-- ko if: percent -->
<th class="mark" scope="row" data-bind="text: title + ' (' + percent + '%)'"></th>
<th class="mark" scope="row" data-bind="text: title + ' (' + numberFormat(percent, 1) + '%)'"></th>
<!-- /ko -->

<!-- ko if: !percent -->
<th class="mark" scope="row" data-bind="text: title"></th>
<!-- /ko -->
<!-- ko if: $index() == 0 -->
<td class="amount">
<!-- ko if: $parents[1].isCalculated() -->
<span class="price"
Expand Down