Skip to content

Commit 1e74edb

Browse files
committed
MAGETWO-51096: Wrong discount for order with Cart Price Rule and settings Apply to Shipping Amount = YES
1 parent 254d14e commit 1e74edb

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@
437437
<field name="apply_to_shipping">
438438
<argument name="data" xsi:type="array">
439439
<item name="config" xsi:type="array">
440+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/single-checkbox-toggle-notice</item>
440441
<item name="dataType" xsi:type="string">boolean</item>
441442
<item name="formElement" xsi:type="string">checkbox</item>
442443
<item name="source" xsi:type="string">sales_rule</item>
@@ -445,8 +446,9 @@
445446
<item name="true" xsi:type="number">1</item>
446447
<item name="false" xsi:type="number">0</item>
447448
</item>
448-
<item name="notice" xsi:type="string" translate="true">
449-
If is checked discount amount will be applied to subtotal and shipping amount separately
449+
<item name="notices" xsi:type="array">
450+
<item name="0" xsi:type="string" translate="true">Discount amount is applied to subtotal only</item>
451+
<item name="1" xsi:type="string" translate="true">Discount amount is applied to subtotal and shipping amount separately</item>
450452
</item>
451453
<item name="default" xsi:type="number">0</item>
452454
<item name="label" xsi:type="string" translate="true">Apply to Shipping Amount</item>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Copyright © 2016 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Ui/js/form/element/single-checkbox'
8+
], function (SingleCheckbox) {
9+
'use strict';
10+
11+
return SingleCheckbox.extend({
12+
defaults: {
13+
notices: [],
14+
tracks: {
15+
notice: true
16+
}
17+
},
18+
19+
/**
20+
* Choose notice on initialization
21+
*
22+
* @returns {*|void|Element}
23+
*/
24+
initialize: function () {
25+
this._super()
26+
.chooseNotice();
27+
28+
return this;
29+
},
30+
31+
/**
32+
* Choose notice function
33+
*
34+
* @returns {void}
35+
*/
36+
chooseNotice: function () {
37+
var checkedNoticeNumber = Number(this.checked());
38+
this.notice = this.notices[checkedNoticeNumber];
39+
},
40+
41+
/**
42+
* Choose notice on update
43+
*
44+
* @returns {void}
45+
*/
46+
onUpdate: function () {
47+
this._super();
48+
this.chooseNotice();
49+
}
50+
});
51+
});

0 commit comments

Comments
 (0)