• Resolved subrisi

    (@subrisi)


    Hi.

    we are running gravity forms.

    Firstly excellent plugin, been very useful so far.

    I am having an issue in filtering the table to show only rows/entries that have been generated by the page that the form is located. We have the same form on 700 posts and the same table. Each post has a SKU (we are running woocomerce) and would only like to show data that is for that SKU/post

    We have tried several variations on the filtering with GET, post, but are unsure how to check that both are =

    None seem to work for me, sure i am doing something daft.

    Thanks for your help and this plugin

    Thanks

    Mark

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Michael Simpson

    (@msimpson)

    I don’t 100% understand what you are saying. Post the short code that you made and let’s take it from there.

    Thread Starter subrisi

    (@subrisi)

    Hi

    Thanks for the quick reply

    here is a link that the gravity form and data table is placed

    https://saic-uk.co.uk/product/dynafile-abrasive-belt-tool-test/

    There is a gravity form on 700 products, when the form is submitted on a product I wish the table on that product post to only show entries for that product. We are trying to get the sku from the product/post and filter the table.

    We have looked through the instructions on Using HTTP GET, POST and COOKIE variables, but cant getting it working.

    here is the shortcode that we are using.

    [cfdb-datatable form=”vibration reading” hide=”Total exposure points,hours / 8,post id,Submitted Login,Submitted From,submit_time,Hidden Field” role=”Anyone” filter=”Tool SKU=$_POST(_sku)”]

    many thanks

    Mark

    Plugin Author Michael Simpson

    (@msimpson)

    I created a test form in a .html file that POSTs a _sku value to the page. It seems to work.

    <html><body>
    <form method="post" action="https://saic-uk.co.uk/product/dynafile-abrasive-belt-tool-test/">
    <input type="text" name="_sku" value="stuart13"/>
    <input type="submit"/>
    </form>
    </body></html>

    But just navigating to the page will not filter it unless you set filter="Tool SKU=stuart13"

    I’m not clear on how to intend the page to work.

    Thread Starter subrisi

    (@subrisi)

    Hi

    Thanks again.
    we are looking for

    filter=”Tool SKU=stuart13″

    to

    filter=”Tool SKU=the tool sku from the product that the table is posted on ”

    Mark

    Plugin Author Michael Simpson

    (@msimpson)

    I think you are saying that you want (1) a user to simply navigate to that page and see the filtered table instead of (2) a user getting to the page via an HTML form that POSTs the SKU value to that page. We are talking about HTML FORM POSTs not WordPress posts.

    for (1) use filter="Tool SKU=stuart13"
    for (2) use filter="Tool SKU=$_POST(_sku)"

    Thread Starter subrisi

    (@subrisi)

    Hi

    1 is what we want i think, to show only entries in the table that have been created by a form that is on the same page/post/product as the form

    I can do it as

    use filter=”Tool SKU=stuart13″

    and that works. but the stuart13 changes for every page

    Mark

    Hi, I am Mark’s colleague. I have tried:

    filter=”Tool SKU=$_POST(_sku)”

    It is the sort of thing we are looking for but does not seem to work.

    Example of what we are looking for:

    Go to product page for product with sku stuart13 and see only form entries for that product, and then go to product page for product with sku mark14 and only see form entries input on mark14’s page.

    Stuart

    Plugin Author Michael Simpson

    (@msimpson)

    You seem to misunderstand how $_POST and $_GET work. It is not going to pull text out of your WordPress post text. It references variables submitted to the page via an HTTP form POST or GET. In your case, navigating to the page provides no such variable. If the URL to your page ended in “?_sku=stuart13” then you could use $_GET(_sku) in your filter, for example.

    So other than adding the sku to the URL and using a GET/POST function, is there no other way of dynamically displaying form entries unique for each individual sku? Other than exporting a product into Excel, copying the table shortcode to every product and filtering by each individual sku.

    Stuart

    Plugin Author Michael Simpson

    (@msimpson)

    What I don’t understand is how the page knows what the sku is in the first place. You seem to have a page for a product and that product has a sku displayed on the page. How did the page get that value? If you simply wrote the sku in the page then just write the sku in the “filter” of the short code. But if you are dynamically getting that sku somehow, I can’t tell you how to pass that into the short code without knowing where it comes from.

    The sku is a entered via the ‘SKU’ box on the product page, which not having set up the site myself I presume is a feature of the WooCommerce plugin that we use.

    Plugin Author Michael Simpson

    (@msimpson)

    I don’t know anything about the plugin. Sorry, can’t help. But if the plugin has hooks, and if you can get the sku in them, then you could write PHP to get the sku value and use it to get form values or just call WordPress “do_shortcode” passing the sku.

    Well we are able to automatically post the sku to every form entry by creating a custom field for each product which contains their respective skus and using a field within the form to fetch this via {custom_field:_sku}. Does this not lend itself to a function which will filter dynamically through the same field, as it is being fetched and is not just text that is posted to the product?

    Thanks

    Stuart

    Plugin Author Michael Simpson

    (@msimpson)

    OK, now we are getting somewhere. I suggest you create your own filter function to filter against the custom field on the page.

    Using my Add Actions a Filters plugin.

    function is_sku($value) {
       $field = '_sku';
       $custom_fields = get_post_custom();
       if (is_array($custom_fields) && isset($custom_fields[$field])) {
       	$ret_val = $value == $custom_fields[$field][0];
       	return ($ret_val ? 1 : 0);
       }
       return 0;
    }
    require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBPermittedFunctions.php');
    CFDBPermittedFunctions::getInstance()->addPermittedFunction('is_sku');

    Then reference the filter function in your short code (assumes your form has field “sku”)
    [cfdb-table form="your-form" filter="is_sku(sku)"]

    Great, it works. Thanks! Is there a paid version of your plugin which we could buy?

    Stuart

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘showing table for form entries made on that post’ is closed to new replies.