From 9df3ecc26b7856054df7cd8768a91da32dc167bd Mon Sep 17 00:00:00 2001
From: Sergey Semenov <ssemenov@ebay.com>
Date: Wed, 24 Jun 2015 22:53:25 +0300
Subject: [PATCH] MAGETWO-39086: Product Options' details are missed while
adding to Wish List
---
.../view/frontend/web/js/add-to-wishlist.js | 38 +++++++++++++++----
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
index baba22455a4..709b552bf57 100644
--- a/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
+++ b/app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
@@ -32,7 +32,8 @@ define([
this._on(events);
},
_updateWishlistData: function(event) {
- var dataToAdd = {};
+ var dataToAdd = {},
+ isFileUploaded = false;
if (event.handleObj.selector == this.options.qtyInfo) {
this._updateAddToWishlistButton({});
event.stopPropagation();
@@ -41,20 +42,24 @@ define([
var self = this;
$(event.handleObj.selector).each(function(index, element){
if ($(element).is('input[type=text]')
- || $(element).is('textarea')) {
+ || $(element).is('input[type=checkbox]:checked')
+ || $(element).is('input[type=radio]:checked')
+ || $('#' + element.id + ' option:selected').length
+ || $(element).is('textarea')
+ ) {
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
return;
}
- if ($(element).is('input[type=file]')) {
+ if ($(element).is('input[type=file]') && $(element).val()) {
var hidden = $('input[name=' + $(element).attr('name') + '_action]');
dataToAdd = $.extend({}, dataToAdd, self._getElementData(hidden));
- return;
- }
- if ($(element).is(':checked')
- || $(element).find(':checked').length) {
- dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
+ isFileUploaded = true;
}
});
+ console.log(dataToAdd);
+ if (isFileUploaded) {
+ this.bindFormSubmit();
+ }
this._updateAddToWishlistButton(dataToAdd);
event.stopPropagation();
},
@@ -107,6 +112,23 @@ define([
$.each(dataToRemove, function(key, value) {
delete params.data[key];
});
+ },
+ bindFormSubmit: function() {
+ var self = this;
+ $('[data-action="add-to-wishlist"]').on('click', function(event) {
+ event.stopPropagation();
+ event.preventDefault();
+
+ var element = $('input[type=file]' + self.options.customOptionsInfo),
+ params = $(event.currentTarget).data('post'),
+ form = $(element).closest('form'),
+ action = params.action;
+ if (params.data.uenc) {
+ action += 'uenc/' + params.data.uenc;
+ }
+
+ $(form).attr('action', action).submit();
+ });
}
});
--
GitLab