Forums Forums Search & Filter Pro Search & filter pro and woocommerce product table

Viewing 10 posts - 11 through 20 (of 33 total)
  • Trevor
    #208723

    The first problem I can see looking at the forms and the page itself, are:

    You have two forms on the page, this this may well not work, you may need to try this with just one form to see if that works.

    The forms are set to ‘As an Archive’, but for the filter_next_query to work, they need to be set to ‘Custom’.

    I cannot guarantee that this will work though.

    Anonymous
    #208750
    This reply has been marked as private.
    Trevor
    #208752

    With just one form, set to custom, if that method does not work, then the table plugin must be doing its own query in a different way. You will need to check their code for calls to wp_query or pre_get_posts.

    Anonymous
    #208764

    this is the code that woocommerce product table use for the query i presume:

    $args = shortcode_parse_atts( str_replace( array( ‘[product_table’, ‘]’ ), ”, $shortcode ) );
    $args = ! empty( $args ) && is_array( $args ) ? $args : array();

    if ( is_product_category() ) {
    // Product category archive
    $args[‘category’] = get_queried_object_id();
    } elseif ( is_product_tag() ) {
    // Product tag archive
    $args[‘tag’] = get_queried_object_id();
    } elseif ( is_product_taxonomy() ) {
    // Other product taxonomy archive
    $term = get_queried_object();
    $args[‘term’] = “{$term->taxonomy}:{$term->term_id}”;
    } elseif ( is_post_type_archive( ‘product’ ) && get_query_var( ‘s’ ) ) {
    // Product search results page
    add_filter( ‘wc_product_table_run_in_search’, ‘__return_true’ );

    if ( have_posts() ) {
    global $wp_query;
    $args[‘include’] = wp_list_pluck( $wp_query->posts, ‘ID’ );
    } else {
    // Force ‘nothing found’ message if no posts in query
    $args[‘include’] = -1;
    }
    }

    Trevor
    #208770

    Could you try changing this bit (you need to use the ID of the form you retained on the page instead of ‘123456’):

    if ( have_posts() ) {
    global $wp_query;
    $args['include'] = wp_list_pluck( $wp_query->posts, 'ID' );
    } else {

    to

    if ( have_posts() ) {
    global $wp_query;
    $args['include'] = wp_list_pluck( $wp_query->posts, 'ID' );
    $args['search_filter_id'] = 123456;
    } else {

    But I am not confident this will work, but here’s hoping. You will need to remove the shortcode that has the filter_next_query in it.

    Anonymous
    #208778
    This reply has been marked as private.
    Trevor
    #208782
    This reply has been marked as private.
    Anonymous
    #208784
    This reply has been marked as private.
    Trevor
    #208790

    Those two shortcodes will output the form, but will not output any posts unless there is something on the page to do that also, and then they might need to be tied together. On that page there are no posts, so I assume that there is nothing on the page outputting them?

    The process is generally this:

    Output the form
    Send the selected form filters to the plugin, theme template or pagebuilder posts element.
    Output the posts.

    For the custom method, it is necessary to manually join those together (for example using the filter_next_query shortcode, or adding the args line).

    Most other form Display Results methods do the joining for you.

    Anonymous
    #208792
    This reply has been marked as private.
Viewing 10 posts - 11 through 20 (of 33 total)