Skip to content

Commit

Permalink
fix: hotfix bought item error
Browse files Browse the repository at this point in the history
  • Loading branch information
agladyshev committed Dec 9, 2019
1 parent dd3b18f commit ed3dcc8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ export const populateCollections = function(collections, products) {
return [];
}
return collections.map(c => {
c.products = c.products.map(p => {
return Object.assign(
p,
products.find(prod => prod.id == p.product_id)
);
});
c.products = c.products.reduce((acc, p) => {
let product = products.find(prod => prod.id == p.product_id);
if (product) {
acc.push(Object.assign(p, product));
}
return acc;
}, []);
if (c.products.length) {
return c;
}
Expand Down

0 comments on commit ed3dcc8

Please sign in to comment.