-
-
Save iksecreeet/0eafef5f82b8e8f4a22eca18ee138194 to your computer and use it in GitHub Desktop.
товары в корзину одним набюором
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', 'button[name="ms2_action_set"][value="cart/addset"]', function(e) { | |
var parentSelector = '.mssetincart-row'; | |
var formSelector = '.ms2_form'; | |
var sets = { | |
action: 'cart/add', | |
ctx: miniShop2Config.ctx, | |
id: 0, | |
count: 1, | |
options: [] | |
}; | |
$.each($(parentSelector).find(formSelector), function(i, el) { | |
var $el = $(el); | |
sets = $.extend({}, sets, { | |
id: $el.find('input[name="id"]').val() || 0, | |
count: $el.find('input[name="count"]').val() || 1 | |
}); | |
$.ajax({ | |
url: miniShop2Config.actionUrl, | |
type: 'POST', | |
dataType: 'json', | |
async: false, | |
data: sets, | |
success: function(response) { | |
if (response.success) { | |
miniShop2.Cart.status(response.data); | |
miniShop2.Message.success(response.message); | |
} else { | |
miniShop2.Message.error(response.message); | |
} | |
} | |
}); | |
}); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment