Hello,
I’m sorry, but I need to know the version of the plugin you are using, the fields inserted in the form, and how are you populating the fields now.
Best regards.
Thread Starter
Goran
(@hrvan)
Hello.
The version is 10.0.297. The fields are both dropdown. I’ve used url to get the post id and the date I’m getting over that id. If I want input I could pass the price as well, but I want for the customer to be able to switch the color in the form, so I need to switch the price accordingly.
Thank you.
Best regards.
Hello,
The solution will depend of the database structure and the way you are reading the values from the database.
For example, assuming you have inserted in the webpage the shortcode to generate a variable with the post’s id received as parameter. I will call it post_id
If you have inserted a “DropDown DS” field for reading all colors (I will call it fieldname1) a possible query using the previous variable, would be:
SELECT meta_key as value, meta_value as text FROM {wpdb.postmeta} WHERE post_id=<%post_id%> AND meta_key LIKE "%color%"
For the “DS” field used for reading the price, for example a “Currency DS” field, should use a query similar to the following one:
SELECT meta_value as text FROM {wpdb.postmeta} WHERE post_id=<%post_id%> AND meta_key=REPLACE("color","price","<%fieldname1%>");
and that’s all.
If you need additional help implementing your form, I can offer you a custom coding service from my private website:
https://cff.dwbooster.com/customization
Best regards.
Thread Starter
Goran
(@hrvan)
This for some reason doesn’t work.
I’ve made another dropdown DS to get the post id.
I’ve set column for value to id, for text to post_title, table to {wp_posts} and condition to post_status=’publish’ AND post_type=’packages’. This dropdown works perfectly. Second dropdown column for value to meta_key, for text to meta_value, table to {wp_postmeta} and condition to post_id=<%fieldname1%> AND meta_key LIKE “%color%”;
This one also work perfectly.
Third one (Currency DS), I’ve set like you said: column for value to meta_value, table to {wp_postmeta} and condition to SELECT meta_value as text FROM {wpdb.postmeta} WHERE post_id=<%post_id%> AND meta_key=REPLACE(“color”,”price”,”<%fieldname2%>”);
I even tried to change <%post_id%> to <%fieldname1%> cause I already have it there, but nothing I’ve tried works.
Any clues for the third one?
I know it’s a hasle for you but please help if you can…
Hello @hrvan,
The tables’ names need the symbols {} only if you are using any of the plugin’s constants, like {wpdb.posts}, but if you are using the tables’ names directly you don’t need them, for example: wp_posts
Concerning to your project, I recommend you request a custom coding service, because the implementation of the queries are specific to your project. I’ve described the process in my tickets, but I cannot be sure if the values of meta_key column are exactly the includes in yours, if the structure of queries in your form are fine, etc.
https://cff.dwbooster.com/customization
Best regards.