[Resuelto] Get the values of new fields created in woocommerce products through PHP.
This support ticket is created hace 5 años, 4 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
If I create new fields for WooCommerce products, how can I obtain the values of those fields in the product the user is currently on through PHP?
Another thing, I suppose that to obtain the values of the current product it will be necessary to know the id of the product that is currently being viewed.
How can I get this product id?
The documentation is not clear at all. It's a mess. 🙁
For example, I create 2 new numerical fields for WooCommerce products.
Field1: slug: s_1
Field2: slug: s_2
Now I want to get the value of field1 of the product with id = 20
How would it be done?
Only the "types_render_field" function is used in the documentation.
It would be something like this?
$cc1 = types_render_field ("s_1", array ("output" => "raw");
but here, where do you put that is the value of the product with id = 20?
Another thing.
In the documentation in output it says: 'raw' | 'normal' (default), but below it also puts 'html'.
It means that there are 3 possible values for output?
Another thing.
In the documentation when "More" is displayed, more attributes are shown, for repeater, user, term, but it does not specify how they are used.
Nor does it make it possible to go through all the records (loop) of a new type created with Types.
Everything is very confusing.
It is all so brief that it does not serve much. 🙁
This URL is actually correct because it shows you how to build the custom templates as well as include custom fields into those custom templates.
In the documentation in output it says: 'raw' | 'normal' (default), but below it also puts 'html'.
It means that there are 3 possible values for output?
Lets say your custom field is a URL field. If you set the URL field to display normally it will display the URL as a clickable link. If you set the display to normal it will print out the exact url without wrapping it in the HTML for an anchor tag.
In the documentation when "More" is displayed, more attributes are shown, for repeater, user, term, but it does not specify how they are used.
These are as specified "repeater" means these attributes apply if the field is a repeatable field. "user" makes reference to if this is a custom field for users and "term" are attributes for custom fields on taxonomies.
This document is an API document its usually meant for intermediate to advanced users who are familiar with coding.
But even for developers, these are not born knowing the apis of any product, especially because they have not made that product. For example, in the ACF documentation there are many examples and it is much more extensive. The ACF documentation is made to be able to really use the ACF API, it is not just an exposition of attributes, etc. The same can be said of other products. The Formidable Forms documentation is fantastic and if something is not sufficiently explained the support team give detailed explanations.
Toolset has many limitations, so it is necessary on many occasions to do things in PHP. The minimum would be to have extensive documentation and numerous examples.
I do recognise that the documentation is quite limited on how to use the items so we here in support try to see how best we can explain to customers how to use the products or the API.
Also was my explanation in the previous thread able to help you to get through the issue you were having ?
I think so.
I appreciate your help.
Although you did not explain how to do a loop to get all the values of all the records of a new type created by Types.