0

I am currently working on a project in EE that involves food delivery services and have run into a block. The project is about users subscribing to a plan and receiving a different dish every day of the week. During signup, users select their meat preferences and any items they're allergic to.

On the food side, when dishes are added, the type of meat in them is one field and ingredients (ones that users could be allergic to) is another. There will be about a couple of hundred dishes added in total.

What I would like to do is select 2-3 types of dishes daily and have them distributed to users based on their meat preference. With EE, I can't figure out of I can create a relationship based on multiple queries (such as select users that have chosen Vegetarian AND chicken or Select Users that have chosen Chicken but NOT vegetarian.) Would this be something Craft is capable of? And What would be the best way of picking a dish and then figuring out which users it can be assigned to and then picking the second dish and assigning to the remaining users and if need be, pick a third dish to assign any users that are left over?

2

This is a very difficult problem. And to be honest, I'm not sure if 3 dishes will actually cover the possible combinations in the way that you're asking. Just the common dietPreferences alone could result in 63 combinations (6+15+20+15+6+1). If you add allergens into the mix the numbers get very large very quickly.

dietPreferences = ['beef', 'pork', 'chicken', 'fish', 'vegetarian', 'vegan'];
allergens = ['dairy', 'peanuts', 'gluten', 'shellfish', 'etc', 'etc'];

I think that you will need to reduce the combinations to something like ['redmeat(including chicken)', 'redmeat+fish', 'fish+vegetarian', 'vegetarian', 'all']; And then always have a meat, fish and vegetarian dish that do not include any allergens. Vegans would not be supported; nor would those allergic to dairy, gluten, and other ingredients that are difficult to avoid.

As far as a CMS goes however, craft is as capable as any CMS to tackle the problem, but you would need to establish the parameters carefully first.

For more information on relationships check out the documentation for relatedTo. You might also do a search on this site for 'relatedTo', 'advanced search' and 'elementCriteriaModel'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.