Support Forums

Looking for support? You can access the support system via your account.

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

Viewing 10 posts - 11 through 20 (of 33 total)
  • Trevor Moderator
    #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.

    setgp
    #208750
    This reply has been marked as private.
    Trevor Moderator
    #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.

    setgp
    #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 Moderator
    #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.

    setgp
    #208778
    This reply has been marked as private.
    Trevor Moderator
    #208782
    This reply has been marked as private.
    setgp
    #208784
    This reply has been marked as private.
    Trevor Moderator
    #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.

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

You must be logged in to reply to this topic.