File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Sales/Controller/Adminhtml/Order Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -270,16 +270,33 @@ protected function _processActionData($action = null)
270
270
if (isset ($ data ) && isset ($ data ['coupon ' ]['code ' ])) {
271
271
$ couponCode = trim ($ data ['coupon ' ]['code ' ]);
272
272
}
273
+
273
274
if (!empty ($ couponCode )) {
274
- if ($ this ->_getQuote ()->getCouponCode () !== $ couponCode ) {
275
+ $ isApplyDiscount = false ;
276
+ foreach ($ this ->_getQuote ()->getAllItems () as $ item ) {
277
+ if ($ item ->getIsApplyDiscount () === true ) {
278
+ $ isApplyDiscount = true ;
279
+ break ;
280
+ }
281
+ }
282
+ if (!$ isApplyDiscount ) {
275
283
$ this ->messageManager ->addError (
276
284
__ (
277
- '"%1" coupon code is not valid. ' ,
285
+ '"%1" coupon code for item(s) selected do not apply discount ' ,
278
286
$ this ->_objectManager ->get ('Magento\Framework\Escaper ' )->escapeHtml ($ couponCode )
279
287
)
280
288
);
281
289
} else {
282
- $ this ->messageManager ->addSuccess (__ ('The coupon code has been accepted. ' ));
290
+ if ($ this ->_getQuote ()->getCouponCode () !== $ couponCode ) {
291
+ $ this ->messageManager ->addError (
292
+ __ (
293
+ '"%1" coupon code is not valid. ' ,
294
+ $ this ->_objectManager ->get ('Magento\Framework\Escaper ' )->escapeHtml ($ couponCode )
295
+ )
296
+ );
297
+ } else {
298
+ $ this ->messageManager ->addSuccess (__ ('The coupon code has been accepted. ' ));
299
+ }
283
300
}
284
301
}
285
302
Original file line number Diff line number Diff line change @@ -87,6 +87,7 @@ public function collect(Address $address)
87
87
foreach ($ items as $ item ) {
88
88
if ($ item ->getNoDiscount () || !$ this ->_calculator ->canApplyDiscount ($ item )) {
89
89
$ item ->setDiscountAmount (0 );
90
+ $ item ->setIsApplyDiscount (false );
90
91
$ item ->setBaseDiscountAmount (0 );
91
92
92
93
// ensure my children are zeroed out
@@ -119,6 +120,7 @@ public function collect(Address $address)
119
120
$ this ->_calculator ->process ($ item );
120
121
$ this ->_aggregateItemDiscount ($ item );
121
122
}
123
+ $ item ->setIsApplyDiscount (true );
122
124
}
123
125
124
126
/**
You can’t perform that action at this time.
0 commit comments