Compact Box Layout not loading correct sometimes

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Compact Box Layout not loading correct sometimes

This topic contains 12 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 3 months, 1 week ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #46038
    l.mavromatis
    l.mavromatis
    Participant

    Hi,
    I have an issue with compact box layout from mobile view. Not always but often the search is loading opened and not in proper position at header. This happens only on my homepage and as i mention not allways. Is there something i can do for this? Or at least is other way to have the search button on mobile to work without conflict?
    Thanks in advanced,
    Leonidas

    Attachments:
    You must be logged in to view attached files.
    #46040
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I tried and reloaded a dozen times, but it seems to work all right on my end every single time. Can you please try to clear the phone cache as well as the site cache. The fact that it can’t be replicated points to a cache issue.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #46041
    l.mavromatis
    l.mavromatis
    Participant

    I have this issue since i register the plugin and create new search. I tryed to clean cache and different incognicto browser but often the load of search is not correct, try please incognito and different prowser in a couple of minutes again probably you will see it. Is there other way to use a search button on mobile header instead of compact box?

    #46049
    l.mavromatis
    l.mavromatis
    Participant

    I have implemented custom JavaScript code to achieve the desired functionality of the compact box, and it’s working perfectly. I have one more question, though. I’ve reviewed your documentation and plugin comments but couldn’t find a solution to this issue. I’m using your search functionality for my WooCommerce store, and variations have been incorporated into the search. When I search for a specific variation, everything functions as expected. However, when I perform a general search and press Enter, the results display all products along with their corresponding variations. This leads to the same product being displayed 30-40 times on the results page, which is undesirable as I have products with numerous variations. Is there a way to restrict the results page to display only parent products?

    Thanks in advance for your assistance.

    #46054
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    All right – I tried to replicate the issue a few times on different devices yesterday but I couldn’t, so I don’t know where it originated from unfortunately.

    Well, for the results page you could try a custom code for that:

    add_filter("asp_query_args", "asp_query_args_remove_variation", 10, 2);
    function asp_query_args_remove_variation($args, $search_id) {
    	if ( !$args['_ajax_search'] ) {
    		$args['post_type'] = array_diff($args['post_type'], array('product_variation'));
    	}
    	return $args;
    }

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #46058
    l.mavromatis
    l.mavromatis
    Participant

    Working perfectly the function, thanks a lot.
    All the best!

    #46065
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #46096
    l.mavromatis
    l.mavromatis
    Participant

    Hi again,

    Is there a similar way to display only parent product on search field results even when i search a variation product?

    Thanks,
    Leonidas

    #46102
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Leonidas,

    I think so, but it may require a bit of custom code and special configuration.

    Try adding this code via the Code Snippets plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    add_filter( 'asp_post_content_before_tokenize_clear', 'asp_tokenize_sku_variation', 10, 2 );
    function asp_tokenize_sku_variation($content, $post) {
      if ( $post->post_type == 'product' && ($variations = $_product->get_children()) ) {
    	foreach ( $variations as $variation ) {
    		$content .= ' ' . $variation->get_description();
    		$content .= ' ' .  $variation->get_sku();
    	}
      }
    
      return $content;
    }

    Then you will have to enable and use the index table engine. It will then index the variation description and SKU for each product as part of a the product content.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #46103
    l.mavromatis
    l.mavromatis
    Participant

    I am using index table and enabled variations on available post types, i added your code and tried several different settings but nothing changed. I tried to create new index when new code exist, the process does not start.

    #46108
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Okay, let’s try something different.

    On the index table settings, do NOT select the product variations, that may actually conflict with this. Try this code instead:

    add_filter( 'asp_post_content_before_tokenize_clear', 'asp_tokenize_sku_variation', 10, 2 );
    function asp_tokenize_sku_variation($content, $post) {
      if ( $post->post_type == 'product' ) {
    	$_product = wc_get_product( $r->id );  
    	$variations = $_product->get_children();
    	if ( !is_wp_error($variations) && is_array($variations) ) {
    		foreach ( $variations as $variation ) {
    			$content .= ' ' . $variation->get_description();
    			$content .= ' ' .  $variation->get_sku();
    		}
    	}
      }
    
      return $content;
    }

    If all goes well this should make some sort of a change.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #46112
    l.mavromatis
    l.mavromatis
    Participant
    You cannot access this content.
    #46124
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    I can check it out, but it is very likely that I can only apply the variation description and the SKU in this case and only for the index table engine. Regular engine will not work with this as the variation are separate post type objects, not stored as part of the product.

    Can you please also add temporary (s)FTP access? I will have to make change to the files and any mistake in the code could lead to a site error which I can’t revert from the back-end.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 13 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic.