Skip to content

Commit 8f94408

Browse files
author
Anna Bukatar
committed
MC-42813: Cart qty update should be reverted back if the requested qty is not available
1 parent c9db59c commit 8f94408

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

app/code/Magento/Checkout/view/frontend/web/js/action/update-shopping-cart.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,18 @@ define([
107107
* Form validation failed.
108108
*/
109109
onError: function (response) {
110-
var that = this;
110+
var that = this,
111+
responseData = JSON.parse(response['error_message']);
112+
111113
if (response['error_message']) {
112114
try {
113-
var responseData = JSON.parse(response['error_message']);
114115
$.each(responseData, function (index, data) {
115-
if (data['itemId'] !== undefined) {
116-
let elm = $('#cart-' + data['itemId'] + '-qty');
116+
117+
if (data.itemId !== undefined) {
118+
let elm = $('#cart-' + data.itemId + '-qty');
117119
elm.val(elm.attr('data-item-qty'));
118120
}
119-
response['error_message'] = data['error'];
121+
response['error_message'] = data.error;
120122
});
121123
} catch (e) {}
122124
alert({

0 commit comments

Comments
 (0)