Support » Plugin: The SEO Framework » TSF prevents redirect to search result page on woocommerce

  • Resolved Nikodemsky

    (@nikodemsky)


    I have checked all other plugins and it’s TSF for sure:
    http://www.mediafire.com/file/gwf52dcpbwjij6b/TSF+error.mp4

    For some reason TSF prevents redirects to single result page on Woocommerce.

    I have tried removing all of my custom code from functions etc. It’s like that since Woocommerce 3.6.x

    Anything else i can provide to help with the issue?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi Nikodemsky,

    Unfortunately, I couldn’t replicate this issue on my testing server.

    What I find peculiar is that the query leads to that specific page:
    katalog-produktow/
    Effectively, this query is outputted on the homepage, and it leads to that page:
    ?post_type=product&s=x

    Could you inspect the posts, pages, products, etc. that are redirected via The SEO Framework, and find one that’s redirecting to that page? If you’re able to find it, could you try if removing the redirect resolves this issue?

    Cheers!

    I’m not really sure what exactly i should look for to be honest, this is standard woocommerce product search widget overwritten by code:

    /** Custom product search form widget **/
    function woo_custom_product_searchform( $form ) {
     
        $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/'  ) ) . '">
    		<div>
    			<label class="screen-reader-text" for="s">' . __( 'Search for:', 'woocommerce' ) . '</label>
    			<input type="hidden" class="" value="product" name="post_type" />
    			<input class="search-widget" type="text" value="' . get_search_query() . '" name="s" id="s" placeholder="' . __( 'Type name or product code...','solidbase' ) . '" />
    		</div>
    	</form>';
        return $form;
     
    }
    add_filter( 'get_product_search_form' , 'woo_custom_product_searchform' );

    – but like i said, even if i remove it issue still occurs.

    It would be like the whole query is messed up?

    If i remove theme support code for woo:

    // Declares woocommerce custom template usage
    function solidbase_woocommerce_support() {
    	add_theme_support( 'woocommerce' );
    }
    add_action( 'after_setup_theme', 'solidbase_woocommerce_support' );

    Then i’m getting “raw” search results:
    https://i.postimg.cc/L6kgSThk/screencapture-solidbase-e-partnerzymarketingowi-pl-2019-06-18-22.png
    – is it maybe related somehow?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Nikodemsky,

    The form prepares a search that leads to the link below; which is the correct endpoint:

    example.com/?s=03&post_type=product
    

    When you remove the theme support, it no longer outputs that altered form, and uses the default WordPress search endpoint (without the post type) instead:

    example.com/?s=03
    

    Could you try implementing this piece of code on your site? You may put it in a theme’s functions.php file or a custom plugin. It will disable redirects initiated by The SEO Framework, which may save the day:

    add_action( 'the_seo_framework_after_front_init', function() {
    	remove_action( 'template_redirect', [ the_seo_framework(), '_init_custom_field_redirect' ] );
    } );
    

    It works! :>

    Now, that code won’t brake anything else?

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Nikodemsky,

    That code disables the whole redirection functionality in The SEO Framework. So, if you use that functionality, you may wish to remove it.

    I’m glad it worked because that confirms that one page redirects the search query incorrectly.

    Could you go over your posts, pages, and products and see if there’s a redirect set?
    The SEO Bar should be a big full blue R (for “Redirect”, may be translated), which helps you find them easier.

    See if any of the redirected pages point their redirection URL to /katalog-produktow/. If you’ve found it, you may wish to remove that redirect; it may be a placeholder “search” page that’s modified by another plugin.

    If that page is modified by a plugin, could you share some details on it? Cheers 🙂

    Jeez, i found it!

    http://solidbase.e-partnerzymarketingowi.pl/produkty/
    – it is set as shop main page and for some reason it redirects to said /katalog-produktow/

    Any idea why it behaves like that?(i mean why woo search widget redirects to this page)

    • This reply was modified 1 year, 4 months ago by Nikodemsky.
    Plugin Author Sybre Waaijer

    (@cybr)

    Hi Nikodemsky,

    I’m glad you’ve been able to find it!

    It’s not the search widget that’s the issue, as it merely outputs a form; the input of that form is parsed elsewhere.

    I think it has something to do with the theme or another plugin that overrides the search results page… but I can’t put my finger on it.

    The search results page seems to take the canonical URL of /katalog-produktow/, but that might also be a custom canonical URL input at /produkty/.

    I have reproduced the same bug here:
    http://smietnik.w3wg.com/produkt/test/

    The steps are:
    1. Set some page as main shop page
    2. Use redirect on it to something else

    That’s it. Only two plugins are active, no overrides, default theme. It must be something with TSF.

    Plugin Author Sybre Waaijer

    (@cybr)

    Thanks for that Nikodemsky!

    It’s best for me to lock out that functionality on those pages; these are two conflicting template overrides.

    WooCommerce relies on the shop base for many of its endpoints; when you redirect it, many of the callbacks falter.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘TSF prevents redirect to search result page on woocommerce’ is closed to new replies.