Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Compact Box Layout not loading correct sometimes
- This topic has 12 replies, 2 voices, and was last updated 2 years, 6 months ago by
Ernest Marcinko.
-
AuthorPosts
-
November 15, 2023 at 1:24 pm #46038
l.mavromatis
ParticipantHi,
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,
LeonidasNovember 15, 2023 at 1:51 pm #46040Ernest Marcinko
KeymasterHi,
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.
November 15, 2023 at 1:56 pm #46041l.mavromatis
ParticipantI 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?
November 15, 2023 at 11:44 pm #46049l.mavromatis
ParticipantI 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.
November 16, 2023 at 11:14 am #46054Ernest Marcinko
KeymasterAll 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.
November 16, 2023 at 11:28 am #46058l.mavromatis
ParticipantWorking perfectly the function, thanks a lot.
All the best!November 16, 2023 at 12:56 pm #46065Ernest Marcinko
KeymasterYou cannot access this content.
November 20, 2023 at 8:18 am #46096l.mavromatis
ParticipantHi again,
Is there a similar way to display only parent product on search field results even when i search a variation product?
Thanks,
LeonidasNovember 20, 2023 at 9:57 am #46102Ernest Marcinko
KeymasterHi 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.
November 20, 2023 at 10:33 am #46103l.mavromatis
ParticipantI 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.
November 21, 2023 at 10:36 am #46108Ernest Marcinko
KeymasterOkay, 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.
November 21, 2023 at 11:38 am #46112l.mavromatis
ParticipantYou cannot access this content.
November 22, 2023 at 1:48 pm #46124Ernest Marcinko
KeymasterI 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.
-
AuthorPosts
- You must be logged in to reply to this topic.