Skip Navigation

[Résolu] How to get a field from a specific scratchpad record

This support ticket is created Il y a 8 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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/Hong_Kong (GMT+08:00)

Marqué : 

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par tony Il y a 8 années.

Assisté par: Luo Yang.

Auteur
Publications
#399758

I am trying to:

I want to create a record somewhere in the WordPress database that contains data for use globally throughout a website and also by php programs that will create and modify data in a post type called "products".

The data could be anything but includes some parameters that will be used to calculate a sale price from a trade price.

The parameters could include:
- mark-up percentage
- fixed cost
- minimum value

So in the php programs there will be a calculation similar to:
= max of (minimum value, ((trade cost * mark-up percentage) + fixed cost))

I know that I can embed this data in the php programs and also include it in templates but I would like a simple single place where it is stored and can be easily changed by a non technical user.

So, if the business decides to change mark-up percentage from 35% to 30% and then rerun the appropriate php program it is easy to do via a CRED form.

When displaying in a template, I am looking for something that effectively does the following:
display "mark-up percentage" from post type "scratchpad" record id "3456"

In the php program fields needs to be accessed via the appropriate php code, which I expect the programmer to be able to work out.

I have tried to describe this in a generic way in case it is of use to others.

Any help/guidance would be appreciated.

Many thanks
Tony
(non-programmer)

#399812

Dear Tony,

Since those parameters is for "globally throughout a website", I suggest you store them into your database table "wp_options", then you will be able to get the parameters value anywhere in your website, with wordpress function get_option()
A safe way of getting values for a named option from the options database table.
http://codex.wordpress.org/Function_Reference/get_option

but there isn't such a feature within CRED form or Types plugin, it needs custom PHP codes,according to our new support police, we do not provide custom codes support:
https://toolset.com/toolset-support-policy/
so I suggest you check out our certified partners for it:
https://toolset.com/consultant/

#399944

Thank you Luo

Tony

Ce ticket est maintenant fermé. Si vous êtes un client de Toolset et que vous avez besoin d'aide, veuillez ouvrir un nouveau ticket d'assistance