Skip to content

Commit 85760a3

Browse files
committed
MAGETWO-44228: Unable to set gift options in the shopping cart
1 parent 24abff1 commit 85760a3

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

app/code/Magento/GiftMessage/view/frontend/web/js/model/gift-options.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,30 @@
33
* See COPYING.txt for license details.
44
*/
55
/*global define*/
6-
define(['underscore'],
7-
function (_) {
8-
"use strict";
6+
define(['underscore', 'ko'],
7+
function (_, ko) {
8+
9+
'use strict';
10+
911
return {
10-
options: [],
11-
addOption: function(option) {
12-
if(!this.options.hasOwnProperty(option.itemId)) {
13-
this.options[option.itemId] = option;
12+
options: ko.observableArray([]),
13+
addOption: function (option) {
14+
if (!this.options().hasOwnProperty(option.itemId)) {
15+
this.options.push({
16+
id: option.itemId, value: option
17+
}
18+
);
1419
}
1520
},
16-
getOptionByItemId: function(itemId) {
17-
return this.options.hasOwnProperty(itemId) ? this.options[itemId] : null;
21+
getOptionByItemId: function (itemId) {
22+
var option = null;
23+
_.each(this.options(), function (data) {
24+
if (data.id === itemId) {
25+
option = data.value;
26+
}
27+
});
28+
29+
return option;
1830
}
1931
}
2032
}

app/code/Magento/GiftMessage/view/frontend/web/js/view/gift-message.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
* See COPYING.txt for license details.
44
*/
55
/*global define*/
6-
define(['uiComponent', '../model/gift-message', '../model/gift-options', '../action/gift-options'],
6+
define([
7+
'uiComponent',
8+
'Magento_GiftMessage/js/model/gift-message',
9+
'Magento_GiftMessage/js/model/gift-options',
10+
'Magento_GiftMessage/js/action/gift-options'
11+
],
712
function (Component, giftMessage, giftOptions, giftOptionsService) {
813
"use strict";
914
return Component.extend({

0 commit comments

Comments
 (0)