The repo for Purrform's main BigCommerce store.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: filter out unwanted ingredients from recommended products in Diet Builder

+12
+12
assets/js/theme/custom/diet-builder.js
··· 1043 1043 const { total, kcal } = calculateRDA(catWeight, activity, coef); 1044 1044 this.state.calculatedRDA = total; 1045 1045 this.state.kcal = kcal; 1046 + 1047 + // Filter out products containing any unwanted ingredients 1048 + if (this.state.unwantedIngredients.length > 0) { 1049 + this.state.recommendedProducts = 1050 + this.state.recommendedProducts.filter((product) => { 1051 + const ingredients = product.customFields?.Ingredients ?? []; 1052 + return !ingredients.some((ing) => 1053 + this.state.unwantedIngredients.includes(ing), 1054 + ); 1055 + }); 1056 + } 1057 + 1046 1058 // need to calculate grams for each recommended product based on kcal and product calorie density - each product has a custom field called CALORIE per Product and another called Weight of product which is in grams - so we can calculate calories per kg for each product and then calculate grams needed to meet the RDA kcal 1047 1059 for (const product of this.state.recommendedProducts) { 1048 1060 const calsPerProduct = Number(