Skip to content

No alert when user "Apply empty Coupon Code" in create new order form (issue 24015) #24016

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
2 changes: 2 additions & 0 deletions app/code/Magento/Sales/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -797,3 +797,5 @@ Created,Created
Refunds,Refunds
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
"Allow Zero GrandTotal","Allow Zero GrandTotal"
"Please enter a coupon code!","Please enter a coupon code!"

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="admin__field-control">
<?php if (!$block->getCouponCode()) : ?>
<input type="text" class="admin__control-text" id="coupons:code" value="" name="coupon_code" />
<?= $block->getButtonHtml(__('Apply'), 'order.applyCoupon($F(\'coupons:code\'))') ?>
<?= $block->getButtonHtml(__('Apply'), 'order.handleOnclickCoupon($F(\'coupons:code\'))') ?>
<?php endif; ?>
<?php if ($block->getCouponCode()) : ?>
<p class="added-coupon-code">
Expand All @@ -22,9 +22,23 @@
</p>
<?php endif; ?>
<script>
require(["Magento_Sales/order/create/form"], function() {
require([
"jquery",
'Magento_Ui/js/modal/alert',
'mage/translate',
"Magento_Sales/order/create/form"
], function($, alert) {
order.overlay('shipping-method-overlay', <?php if ($block->getQuote()->isVirtual()) : ?>false<?php else : ?>true<?php endif; ?>);
order.overlay('address-shipping-overlay', <?php if ($block->getQuote()->isVirtual()) : ?>false<?php else : ?>true<?php endif; ?>);
order.handleOnclickCoupon = function (code) {
if (!code) {
alert({
content: $.mage.__('Please enter a coupon code!')
});
} else {
order.applyCoupon(code);
}
};
});
</script>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ define([
*/
loadShippingRates: function () {
var addressContainer = this.shippingAsBilling ?
'billingAddressContainer' :
'shippingAddressContainer',
'billingAddressContainer' :
'shippingAddressContainer',
data = this.serializeData(this[addressContainer]).toObject();

data['collect_shipping_rates'] = 1;
Expand Down