Skip to content

Commit 9d80960

Browse files
authored
ENGCOM-5552: No alert when user "Apply empty Coupon Code" in create new order form (issue 24015) #24016
2 parents 36186da + ea86f19 commit 9d80960

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

app/code/Magento/Sales/i18n/en_US.csv

+2
Original file line numberDiff line numberDiff line change
@@ -797,3 +797,5 @@ Created,Created
797797
Refunds,Refunds
798798
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
799799
"Allow Zero GrandTotal","Allow Zero GrandTotal"
800+
"Please enter a coupon code!","Please enter a coupon code!"
801+

app/code/Magento/Sales/view/adminhtml/templates/order/create/coupons/form.phtml

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<div class="admin__field-control">
1313
<?php if (!$block->getCouponCode()) : ?>
1414
<input type="text" class="admin__control-text" id="coupons:code" value="" name="coupon_code" />
15-
<?= $block->getButtonHtml(__('Apply'), 'order.applyCoupon($F(\'coupons:code\'))') ?>
15+
<?= $block->getButtonHtml(__('Apply'), 'order.handleOnclickCoupon($F(\'coupons:code\'))') ?>
1616
<?php endif; ?>
1717
<?php if ($block->getCouponCode()) : ?>
1818
<p class="added-coupon-code">
@@ -22,9 +22,23 @@
2222
</p>
2323
<?php endif; ?>
2424
<script>
25-
require(["Magento_Sales/order/create/form"], function() {
25+
require([
26+
"jquery",
27+
'Magento_Ui/js/modal/alert',
28+
'mage/translate',
29+
"Magento_Sales/order/create/form"
30+
], function($, alert) {
2631
order.overlay('shipping-method-overlay', <?php if ($block->getQuote()->isVirtual()) : ?>false<?php else : ?>true<?php endif; ?>);
2732
order.overlay('address-shipping-overlay', <?php if ($block->getQuote()->isVirtual()) : ?>false<?php else : ?>true<?php endif; ?>);
33+
order.handleOnclickCoupon = function (code) {
34+
if (!code) {
35+
alert({
36+
content: $.mage.__('Please enter a coupon code!')
37+
});
38+
} else {
39+
order.applyCoupon(code);
40+
}
41+
};
2842
});
2943
</script>
3044
</div>

app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,8 @@ define([
445445
*/
446446
loadShippingRates: function () {
447447
var addressContainer = this.shippingAsBilling ?
448-
'billingAddressContainer' :
449-
'shippingAddressContainer',
448+
'billingAddressContainer' :
449+
'shippingAddressContainer',
450450
data = this.serializeData(this[addressContainer]).toObject();
451451

452452
data['collect_shipping_rates'] = 1;

0 commit comments

Comments
 (0)