• Resolved Goran

    (@hrvan)


    Hi.
    My page is still on my local computer.
    I’m having some trouble with 2 fields. For my products I’m using ACF fields for prices (meta_keys are price1, price2, price3, etc.) and colors (meta_keys are color1, color2, color3, etc.). Colors I have in the first dropdown, and managed to get the respected values. In the second dropdown I want to get the prices but dependent on color, e.g.
    if fieldset1 meta key=color1 then fieldset2 meta_key=price1, and so on.
    I’m trying to find some tutorial on how to do it but nothing like this I found. I’m really surprised that noone had that type of problem before.
    Please help.

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author codepeople

    (@codepeople)

    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.

    Plugin Author codepeople

    (@codepeople)

    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…

    Plugin Author codepeople

    (@codepeople)

    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.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘CFF & ACF’ is closed to new replies.