Skip Navigation

[Resolved] Create Takeaway Menu Order Form

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#1965237

Bob

The site is for a takeaway only restaurant.
What I want to do is make it easy for a non tech user to create dishes (starters, mains etc) with descriptions and prices.
Then they select certain dishes to create the daily menu.
This menu is then presented to the customer where they add quantities for the items they want.
Email notifications are then sent to customer and restaurant.
No payment system is initially required.
I'd appreciate any direction and opinion that Toolset is the right approach.

#1965433

Bob

So far I have two custom post types menu and dishes with a one to many relationship.
Does this seem to be the right approach?
I'm not sure how to tackle the order form part of things.

#1966429

Hi,

Thank you for contacting us and I'd be happy to assist.

Based on the requirements that you've shared, this is how I would structure this:

1. Custom Post Types:

a). Dishes (individual dish information will be saved in this post type. Information like Dish description and price will be saved in this post type too through separate custom fields)
b). Orders (individual order information will be saved in this post type)

2. Custom Taxonomies:

a). Dish Type (will be attached to the Dishes post type and will hold terms like starters, mains, desserts, drinks, etc)
b). Weekday Menu (will also be attached to the Dishes post type and will be needed only if the restaurant will be serving only selective dishes on specific weekdays. Terms will be weekdays Sunday, Monday, Tuesday, etc)

3. Post-Relationships:

a). Dishes and Orders
They'll be linked with each other through a many-to-many relationship. Also in this relationship's intermediary post type, you'll also add a numeric custom field "Quantity".

This way, when a customer will create a new "Order" post, he/she will select which "Dishes" are needed and in what "Quantity".

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1966461

Bob

Many thanks.
I'm setting that up now and one problem I can see is how the non tech user assigns the taxonomy Weekday menu - is it possible to do this without them editing each dish?
Ideally they'd be presented with a list of all dishes and they select the appropriate taxonomy for each.

#1966745

Thanks for writing back.

There is no built-in feature available to edit multiple "Dish" posts at the same time, but, there is a workaround that you can use.

You can create an edit post form for the "Dish" posts and include only the fields that you'd like to edit from the same page, for example, the "Weekday Menu " taxonomy.

After that, you can add this form inside a post view loop, that shows all the "Dish" posts. As a result, you'll have the edit form for all the "Dish" posts on one page and the user can make changes to the one that he/she wants.

#1966809

Bob

That's great I have that working in a rough design so thanks so much.
I'm anticipating an issue with the order form as I haven't done entry forms involving many to many relationships so I'll leave this open for the moment as I'll be working on this today.
I really appreciate your help to date.

#1966891

Bob

Hi Waqar
So far I have the 'dishes' sorted and your method of the chef creating the different menus.
I have an 'order' post type in a many to many relationship as you instructed.
Can you direct me to documentation or give me an idea relating to creating a form where customers see the relevant menu and can enter their required quantities.
I'm assuming the calculation of pricing totals is a just a calculation field quantity*price for each item then total it up?

#1968051

The order form would be a bit tricky, because, by default, the relationship form can be used to join only 1 post with another, in one form submission.

Similar to what I suggested in my last message, you can use a post view and the relationship form combination.

1. On a new page, you can add a form to create a new order. It doesn't have to include any field and on form submission, you can redirect the user to the single order page of that newly created order.

2. On the single order page, there will be a post view, that will loop through all the dish posts, which can be ordered.

3. In the loop of this view, you'll include a relationship form to join an order post with a dish post, with the order, dish, and quantity fields.

4. The objective would be that in each instance of the form, the order field will be preselected with the current order and the dish field will be preselected by the current post in the loop and the user can enter the desired quantity.

As a result, when an individual instance of the form will be submitted, a relationship will be formed between the current order and that dish, or in other words, that dish will be included in the order.

On the next order summary page, you can show the total price of the order by using a custom shortcode, that first gets all the related dish posts of the current order.
( ref: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts )

And then adds the sum of the prices, multiplied by their selected quantities.

#1970401

Bob

Can I just clarify when you say 'the single order page of that newly created order' is that a page displaying the post or the post itself?

#1970657

Thanks for writing back and sorry about the confusion.

From the "the single order page of that newly created order", I meant the newly created order post itself.

For example, suppose that the new order form is on a page:
yourwebsite.com/add-new-order

Then when the user will be redirected to the newly created order post, its link would be something like:
yourwebsite.com/order/xyz

( where "order" is the slug of the "Orders" post type and "xyz" is the slug of the newly created order post )

#1970809

Bob

Thanks for that.
I'm closer but I can't see how to populate the fields in the relationship form with the order and dish. I can create the view and create a relationship form but tying them isn't intuitive.

#1972031

Can you please share temporary admin login details, so that I can see how everything is set up at the moment?

I'll be in a better position to suggest the next steps accordingly.

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

#1975379

Thank you for waiting.

I've performed some tests on my website and I was able to make this pre-selection work using the form shortcode like this:


[cred-relationship-form form='new-order-entry' parent_item='$current' child_item='[wpv-post-id item="$current_page"]']

The parent_item='$current' parameter tells the form to select the current Dish post in the view's loop in the parent relationship field.

And the child_item='[wpv-post-id item="$current_page"]' parameter, tells the form to select the current page (which is the current Order post in this case) in the child relationship field.
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/ )

Since the passing of these attributes is not supported through the "Forms" block, you'll remove it from the "New Order" content template and instead use this shortcode in a "Fields and Text" block.

#1978151

Bob

Apologies i haven't had the chance to try this yet. I will do so in the next few days.
Thank you for your help so far.

#1979303

You're welcome and please take your time.