Home › Forums › WoodMart support forum › woodmart_ajax_suggestions is poorly coded
woodmart_ajax_suggestions is poorly coded
- This topic has 19 replies, 2 voices, and was last updated 4 months ago by
Artem Temos.
-
AuthorPosts
-
April 13, 2025 at 5:43 am #653679
dimmiselParticipantHi. I have specific problems in regard to the function mentioned in the ticket’s title. Please take a look at the attached images where I include comments on specific parts of your code.
Attachments:
You must be logged in to view attached files.April 13, 2025 at 5:59 am #653685
dimmiselParticipantAt least, please consider changing
$post_type
at line 574 to$query_args['post_type']
so that we could use the filterwoodmart_ajax_search_args
to change it to something else that would be respected and working…Attachments:
You must be logged in to view attached files.April 14, 2025 at 10:46 am #653821
Artem TemosKeymasterHello,
To make this search form work with your custom post type, you need to edit this element in the header builder and select “All post types” as shown on the screenshot https://gyazo.com/67dd84ecc5335dfc67a8f7a2f3da8424
Then you are able to filter arguments and extra calculations will not be performed.Kind Regards
April 15, 2025 at 4:13 am #654018
dimmiselParticipantHello.
Unfortunately your proposed solution didn’t make any change. I still get the fatal error when searching for a keyword. Please not that despite the setting, I still have the hook on
woodmart_ajax_search_args
but the fatal happens at line 587, on the$product->get_price_html()
part of the code. I also tried with my hook turned off but it didn’t make any difference.Please take a look at the attached image URLs in the private content.
April 15, 2025 at 9:12 am #654077
Artem TemosKeymasterHello,
You need to filter the post type only in the
woodmart_ajax_search_args
hook. Remove the second one and it will work as expected.Kind Regards
April 15, 2025 at 2:15 pm #654248
dimmiselParticipantHello. I did so, and nothing changed. I’m sending you login credentials and details in the private area.
April 15, 2025 at 2:50 pm #654271
Artem TemosKeymasterWe need your server authentication username and password as well. We can’t view your website at the moment.
April 15, 2025 at 6:31 pm #654390
dimmiselParticipantAh sorry, you’re very right! The site is under development and behind a password!
April 17, 2025 at 9:11 am #654827
Artem TemosKeymasterAs we can see, you didn’t set All post types as we proposed in our reply here https://xtemos.com/forums/topic/woodmart_ajax_suggestions-is-poorly-coded/#post-653821
April 17, 2025 at 11:35 am #654890
dimmiselParticipantWhy do you say that? Please check the screenshots in the private area.
April 17, 2025 at 11:56 am #654898
Artem TemosKeymasterIt looks like it works as expected now https://monosnap.com/file/9BoUp5O6o0MmA9rbwgrwAxz9sYh7e4
April 17, 2025 at 12:28 pm #654904
dimmiselParticipantBasically I just looked again and understand what you meant in your previous reply. You’re referring to the Transparent header, but this is not the search form I’m interested in.
The search form I’m interested in is mentioned in the private area, and it’s the AJAX Search Woodmart Widget element for Elementor.
April 17, 2025 at 1:17 pm #654916
dimmiselParticipantWe’re talking about the form available in the Home page (see screenshot in private area).
April 17, 2025 at 2:18 pm #654931
Artem TemosKeymasterIn this case, you need to select “All post types” for this search form. But note that when you use
woodmart_ajax_search_args
filter, you modify these args for all search forms on your website. So you will need to add some conditions inside your code to filter results only if “All post types” is selected.April 17, 2025 at 2:35 pm #654941
dimmiselParticipantSo, in general does your function
woodmart_ajax_suggestions
look OK to you? I mean, do you find that it respects the post_type that I set via thewoodmart_ajax_search_args
hook (https://prnt.sc/83JA8e8PEcSo )?April 17, 2025 at 2:40 pm #654942
Artem TemosKeymasterYes, we tested this code and you can change the post type using this filter and it works. The only problem with PHP errors but you can easily workaround this by selecting “All post types”.
April 18, 2025 at 3:52 am #655069
dimmiselParticipantHi. This is starting to get a bit annoying. You can’t be not understanding what I’m saying… Please pay some attention to what I’m writing in the private area.
April 18, 2025 at 10:39 am #655149
Artem TemosKeymasterHello,
You are right. Sorry for the inconvenience. Please add the following code snippet to the
functions.php
in the child theme to switch to “All post types” for search forms added to pages.add_action( 'elementor/frontend/before_render', function ( $element ) { if ( $element->get_name() === 'wd_search' ) { $settings = $element->get_settings(); $settings['search_post_type'] = 'any'; $element->set_settings($settings); } } );
Kind Regards
April 21, 2025 at 6:48 am #655506
dimmiselParticipantIndeed that worked like a charm. Thanks a lot.
April 22, 2025 at 9:33 am #655698
Artem TemosKeymasterGreat, you are welcome! Feel free to contact us if you have any further questions.
-
AuthorPosts
The topic ‘woodmart_ajax_suggestions is poorly coded’ is closed to new replies.
- You must be logged in to create new topics. Login / Register