Home Forums WoodMart support forum woodmart_ajax_suggestions is poorly coded

woodmart_ajax_suggestions is poorly coded

Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #653679

    dimmisel
    Participant

    Hi. 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.
    #653685

    dimmisel
    Participant

    At least, please consider changing $post_type at line 574 to $query_args['post_type'] so that we could use the filter woodmart_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.
    #653821

    Artem Temos
    Keymaster

    Hello,

    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

    #654018

    dimmisel
    Participant

    Hello.

    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.

    #654077

    Artem Temos
    Keymaster

    Hello,

    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

    #654248

    dimmisel
    Participant

    Hello. I did so, and nothing changed. I’m sending you login credentials and details in the private area.

    #654271

    Artem Temos
    Keymaster

    We need your server authentication username and password as well. We can’t view your website at the moment.

    #654390

    dimmisel
    Participant

    Ah sorry, you’re very right! The site is under development and behind a password!

    #654827

    Artem Temos
    Keymaster

    As 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

    #654890

    dimmisel
    Participant

    Why do you say that? Please check the screenshots in the private area.

    #654898

    Artem Temos
    Keymaster

    It looks like it works as expected now https://monosnap.com/file/9BoUp5O6o0MmA9rbwgrwAxz9sYh7e4

    #654904

    dimmisel
    Participant

    Basically 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.

    #654916

    dimmisel
    Participant

    We’re talking about the form available in the Home page (see screenshot in private area).

    #654931

    Artem Temos
    Keymaster

    In 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.

    #654941

    dimmisel
    Participant

    So, 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 the woodmart_ajax_search_args hook (https://prnt.sc/83JA8e8PEcSo )?

    #654942

    Artem Temos
    Keymaster

    Yes, 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”.

    #655069

    dimmisel
    Participant

    Hi. 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.

    #655149

    Artem Temos
    Keymaster

    Hello,

    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

    #655506

    dimmisel
    Participant

    Indeed that worked like a charm. Thanks a lot.

    #655698

    Artem Temos
    Keymaster

    Great, you are welcome! Feel free to contact us if you have any further questions.

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

The topic ‘woodmart_ajax_suggestions is poorly coded’ is closed to new replies.