Skip Navigation

[Resolved] Calculating amount in ingredient list

This support ticket is created 4 years, 3 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 4 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#1468659

Before I go too far with this recipe blog I want to ask about a feature I've seen on blogs like this.

I'm not using a ready-made cooking blog theme, because they need something more simple and at the same time more and other options than these themes offer.

I'm now creating the ingredient list with custom fields in a repeating group. See the image, I have one field for ingredient name, one field for amount, and a dropdown to select measurement.
I can write "4 servings", but can I create the calculation option, to change the number of servings along with the amount fields?

This is about finding out if it's an option, if it requires all sorts of other tools, it's not relevant, it has to be done with toolset and maybe some script.

Best regards
Lykke

#1469277

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Lykke

I think you forgot the screenshot.

Do I understand this correctly?

You have a quantity together with units (measurement), e.g. for Flour : 200g and you have a servings field (e.g. makes 4 servings), which presumably would belong to the main recipe post, not to the repeatable field group, there is only a single value for servings.

I assume what you are talking about would be reflected on the front-end?

That if someone was reading the recipe, they might change the servings field to 8 and then the flour quantity (and all the other ingredient quantities) would update to say 400g?

Although you would presumably only want this to apply to certain ingredients, because you "a pinch of salt" would likely still be "a pinch of salt" regardless of the serving value.

Is this the kind of thing you have in mind?

It would mean writing a custom JS script on the front-end so that changes to a serving field (which would need to be output as an input tag) would trigger recalculations for the quantities fields.

It's not trivial, and an entirely bespoke solution is required, so I'm afraid you would need a developer to produce it if you were not able to yourself, but from another thread about this project I think you said there was no budget for that.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.