Support » Plugin: YITH WooCommerce Ajax Product Filter » Shop Base URL

  • Hello, I added the filter to my shop but the problem is that when I go to a product page, the filter tries to load the parameters on that same page, how can I make the filter go back to shop page and show the parameters there?
    I tried this code from another ticket but it doesn’t work. Thank you for your help.

    function yith_wcan_change_base_url( $params ){
            if( is_product() ) {
                $base_url= "https://example.com/shop";
            }
            return $base_url;
        }
        add_filter( 'yith_wcan_base_url', 'yith_wcan_change_base_url' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Carlos Rodríguez

    (@crodriguez1991)

    Hello there,

    Thanks for contacting us and I hope you’re doing well 😀

    Could you please give me a url where I can reproduce the problem?

    Anyway try to change the code and try with the following code in the functions.php of your active theme

    if( ! function_exists( 'yith_wcan_change_base_url' ) ){ 
     function yith_wcan_change_base_url( $params ){ 
      if( isset($_GET['s'] ) && (isset($_GET['post_type']) && $_GET['post_type'] === 'product') ){ 
       $base_url= wc_get_page_permalink('shop'); 
      } 
      return $base_url; 
     } 
     add_filter( 'yith_wcan_base_url', 'yith_wcan_change_base_url' ); 
    }

    Please, try it and let me know.

    Have a good day.

    Thread Starter Dafne Delgado

    (@ddm333)

    Hello,
    thank you so much for replying and so quickly. This is the URL https://biyuu.mx/producto/camino-de-mesa/ and if you click on any element of the filter, it loads in that same URL even though I already inserted the code you sent to me in my functions.php
    do you have any feedback?

    Plugin Support Carlos Rodríguez

    (@crodriguez1991)

    Hello there,

    Thanks for contacting us and I hope you’re doing well 😀

    Sorry I made a mistake with my code. The code you need is the following code

    if( ! function_exists( 'yith_wcan_change_base_url' ) ){
    	function yith_wcan_change_base_url( $params ){
    		if( is_product() ) {
    			$base_url = wc_get_page_permalink('shop');
    		}
    		return $base_url;
    	}
    	add_filter( 'yith_wcan_base_url', 'yith_wcan_change_base_url' );
    }

    I checked it on my local installation and works fine. See the following link

    Please, try it and let me know.

    Have a good day.

    Thread Starter Dafne Delgado

    (@ddm333)

    it works great, thank you so so much for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.