almost finished new design on product page / reproduced bug with amount not updating
This commit is contained in:
@@ -101,6 +101,19 @@ var takeItemOut = function(itemId) {
|
||||
saveCartStateForItem(itemId);
|
||||
};
|
||||
|
||||
var setItemCount = function(itemId, count) {
|
||||
var state = states[itemId] || new ItemInCart({
|
||||
item_id: itemId,
|
||||
count: 0
|
||||
})
|
||||
console.log("Old state", state.get('count'));
|
||||
|
||||
state.set('count', state.get('count') + count);
|
||||
console.log("New state", state.get('count'));
|
||||
states[itemId] = state;
|
||||
saveCartStateForItem(itemId);
|
||||
}
|
||||
|
||||
var changeDeliveryDestinationProperty = function(property, value) {
|
||||
_deliveryDestination.set(property, value);
|
||||
|
||||
@@ -274,6 +287,9 @@ AppDispatcher.register(function(payload) {
|
||||
case CartConstants.CONFIRM_DELIVERY:
|
||||
saveDeliveryDestination();
|
||||
break;
|
||||
case CartConstants.SET_ITEM_COUNT:
|
||||
setItemCount(action.itemId, action.count);
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -76,12 +76,13 @@ var ItemWithDetailsStore = _.extend({}, EventEmitter.prototype, {
|
||||
getState: function() {
|
||||
|
||||
|
||||
|
||||
var firstImage = _images[0] || "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png";
|
||||
return {
|
||||
item: _itemWithDetails,
|
||||
images: _images,
|
||||
currentImage: _currentImage,
|
||||
count: _count
|
||||
count: _count,
|
||||
firstImage: firstImage
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
@@ -53,33 +53,34 @@ var fetchItemWithDetails = function() {
|
||||
}
|
||||
|
||||
var fetchItemsByCategory = function(categoryId, offset, limit, query) {
|
||||
//var items = _itemsByCategory;
|
||||
var items = new ItemCollection();
|
||||
items.clearFilter();
|
||||
items.setClassificationType(2);
|
||||
items.setClassificationId(categoryId);
|
||||
items.setLimit(limit);
|
||||
items.setOffset(offset);
|
||||
//var items = _itemsByCategory;
|
||||
var items = new ItemCollection();
|
||||
items.clearFilter();
|
||||
items.setClassificationType(2);
|
||||
items.setClassificationId(categoryId);
|
||||
items.setLimit(limit);
|
||||
items.setOffset(offset);
|
||||
|
||||
for(var key in query) {
|
||||
if (query.hasOwnProperty(key) && key != 'limit' && key !='offset') {
|
||||
items.addFilter(key, query[key]);
|
||||
for (var key in query) {
|
||||
if (query.hasOwnProperty(key) && key != 'limit' && key != 'offset') {
|
||||
items.addFilter(key, query[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
items.fetch({
|
||||
success: function(collection, response, options) {
|
||||
var total = options.xhr.getResponseHeader('x-total-count');
|
||||
items.setTotalCount(total);
|
||||
items.fetch({
|
||||
success: function(collection, response, options) {
|
||||
var total = options.xhr.getResponseHeader('x-total-count');
|
||||
items.setTotalCount(total);
|
||||
|
||||
ItemStore.emitChange();
|
||||
}});
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
});
|
||||
|
||||
_itemsByCategory = items;
|
||||
_itemsByCategory = items;
|
||||
};
|
||||
|
||||
var fetchBestSellingItemsForSection = function(sectionId) {
|
||||
console.log('getting section', sectionId);
|
||||
console.log('getting section', sectionId);
|
||||
var items = _bestSellingForSection;
|
||||
items.setClassificationType(1);
|
||||
items.setClassificationId(sectionId);
|
||||
@@ -87,15 +88,15 @@ var fetchBestSellingItemsForSection = function(sectionId) {
|
||||
items.setOffset(0);
|
||||
|
||||
items.fetch({
|
||||
success: function() {
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
success: function() {
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var fetchBestSellingItemsForGroup = function(groupId) {
|
||||
console.log('getting group', groupId);
|
||||
console.log('getting group', groupId);
|
||||
var items = _bestSellingForGroup;
|
||||
items.setClassificationType(4);
|
||||
items.setClassificationId(groupId);
|
||||
@@ -103,9 +104,9 @@ var fetchBestSellingItemsForGroup = function(groupId) {
|
||||
items.setOffset(0);
|
||||
|
||||
items.fetch({
|
||||
success: function() {
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
success: function() {
|
||||
ItemStore.emitChange();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -113,19 +114,19 @@ var fetchBestSellingItemsForGroup = function(groupId) {
|
||||
// Extend ItemStore with EventEmitter to add eventing capabilities
|
||||
var ItemStore = _.extend({}, EventEmitter.prototype, {
|
||||
|
||||
getItemsForCategory: function() {
|
||||
return _itemsByCategory;
|
||||
},
|
||||
getItemsForCategory: function() {
|
||||
return _itemsByCategory;
|
||||
},
|
||||
getBestSellingForSection: function() {
|
||||
|
||||
return _bestSellingForSection;
|
||||
return _bestSellingForSection;
|
||||
},
|
||||
// item with details
|
||||
getLoadedItemWithDetails: function() {
|
||||
return _itemWithDetails;
|
||||
},
|
||||
|
||||
getItemsForGroup: function () {
|
||||
getItemsForGroup: function() {
|
||||
return _bestSellingForGroup;
|
||||
},
|
||||
|
||||
@@ -190,4 +191,4 @@ AppDispatcher.register(function(payload) {
|
||||
|
||||
});
|
||||
|
||||
module.exports = ItemStore;
|
||||
module.exports = ItemStore;
|
||||
Reference in New Issue
Block a user