• Resolved Jamie

    (@digitalchild)


    Hi Team,

    Jamie here from WC Vendors Marketplace. I’ve built an integration with your plugin to provide support for EAN within WC Vendors. The issue our users are facing is that due to how we’ve built our dashboard, the ‘s’ query var is used for enabling search in our front end vendor dashboard for products. This results in EAN for WooCommerce filtering our products’ table to remove any products that don’t have an EAN added. Now we can disable frontend search in your settings and this fixes the issue for our dashboard, but then removes the ability to search by EAN on the front end.

    I have attempted to modify our plugin to use ‘s’ query var conditionally, but this provides inconsistent results on our dashboard.

    Would you be able to add a filter to your search method in the Alg_WC_EAN_Search class so that we can disable the search method on our dashboard page? I tested this by creating a filter called alg_wc_ean_search in the initial check at the top of the search function.

    function search( $wp_query ) {
    		global $wpdb;
    		if ( ! isset( $wp_query->query['s'] ) || ! isset( $wp_query->query['post_type'] ) || 'product' != $wp_query->query['post_type'] || apply_filters( 'alg_wc_ean_search', false ) ) {
    			return;
    		}
    		WC_Vendors::log( $wp_query );
    		$key   = alg_wc_ean()->core->ean_key;
    		$posts = $wpdb->get_col( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key='{$key}' AND meta_value LIKE %s;",
    			esc_sql( '%' . $wp_query->query['s'] . '%' ) ) );
    		if ( ! $posts ) {
    			return;
    		}
    		unset( $wp_query->query['s'] );
    		unset( $wp_query->query_vars['s'] );
    		$wp_query->query['post__in'] = array();
    		foreach ( $posts as $id ) {
    			if ( ( $post = get_post( $id ) ) ) {
    				if ( $post->post_type == 'product_variation' ) {
    					$wp_query->query['post__in'][]      = $post->post_parent;
    					$wp_query->query_vars['post__in'][] = $post->post_parent;
    				} else {
    					$wp_query->query_vars['post__in'][] = $post->ID;
    				}
    			}
    		}
    	}

    Thanks in advance,

    Jamie

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi Jamie,

    Thanks for reaching out.

    I have escalated this with our development team. They will get back to you as soon as they can.

    Kind regards,
    Moshtafizur

    Thread Starter Jamie

    (@digitalchild)

    Hello,

    Has there been any progress on this?

    Thanks,

    Jamie.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi, @digitalchild,

    Sorry for the delay.

    We’ve just released a new plugin version (v4.4.4), where we’ve added the alg_wc_ean_search filter, as requested.

    Except that instead of:

    apply_filters( 'alg_wc_ean_search', false )

    we did:

    ! apply_filters( 'alg_wc_ean_search', true, $wp_query )

    Please take a look and let me know what you think.

    P.S. We’ve also added a similar filter for the admin search:

    alg_wc_ean_search_backend

    Thread Starter Jamie

    (@digitalchild)

    Hi @algoritmika

    Thanks, it’s working perfectly.

    Have a great rest of your week.

    Cheers,

    Jamie.

    Plugin Author Algoritmika

    (@algoritmika)

    Hi @digitalchild,

    Happy to hear it’s solved! Please let me know if you’ll need anything else. And if you like the plugin, please consider leaving me a rating.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable Search on front end for single page’ is closed to new replies.