I am building an app for a local restaurant. I need the ability for the customer to select either “delivery” or “collection” - I have done this using radio buttons.
When the customer selects “delivery” the delivery location field is shown. Which will show the current users location. And can be edited by customer if it needs to be amended.
this also then shows the element "Delivery Fee : £4.00 as shown here :
You could use two separate ‘Charge the current user’ blocks, and use conditionals to check whether the delivery radio button is active. One block will have the extra 4£, while the other wont.
I think this is a terrible way of doing things because it makes it much harder to maintain and you will quickly get swarmed with blocks if you have a lot of different combinations of possibilities.
This is a great place to use the :format as text operator. Radio button is checked: format as text (If Yes: Base charge + delivery, If No: Base charge):converted to number
This allows you to use a single dynamic expression to correctly format the ‘Amount’ field.
It is really cool because you can also chain :format as text operators to check multiple conditions.
Just to confirm, would this be run on the same workflow as the purchase button as per the screenshot above?
My main question is, where does the delivery charge come from? How do i add this in? So when i add If yes: Order total + Delivery. but where does this value come from?
There are a few options. The most basic one would be to hardcode a ‘4’ into the dynamic expression. As a hard coded value, you would not be able to change it.
This generally does not cut it.
What are your requirements for the delivery fee? Does it depend on distance from origin to destination? Does it depend on vendor? Can you change it?
In most cases, your delivery fee will somehow have to be saved to the database, either on a field, or as a whole new datatype. It might even be calculated on-the-fly on the page.
It’s wonderful, you error you get is because of maybe not understanding us. or maybe our English is poor to guide you on what to do exactly
you don’t need to include if YES: or IF NO: … inside each each box for :format as text case. don’t also use the format as text inside the NO. we need it to be a number only. and as the value return in each case would be considered to be a text we need to make it a number.
after the main :format as text add a :convert to number