• Resolved aspsniper

    (@aspsniper)


    Hello, the last two days I’m trying to solve a problem with a product search result. I’ve disabled all the plugins, tried different theme and clean the cache but the issue is still there. Every time I’m trying to search for any product, its shows a homepage instead of a search result page. I’m using a Kallyas theme which has a two search options: Default WordPress (blog type) search result which is working fine but the products are having an author details and no prices and WooCommerce Product Search Result which is not working at all even when a different theme is chosen.
    SEARCH.PHP

    <?php if(! defined('ABSPATH')){ return; }
    
    /**
     * This is the template layout for search results page.
     *
     * @package  Kallyas
     * @author   Team Hogash
     */
    
    wp_enqueue_style( 'search-css', THEME_BASE_URI . '/css/pages/search.css', array('kallyas-styles'), ZN_FW_VERSION );
    
    get_header();
    
    /*** USE THE NEW HEADER FUNCTION **/
    global $wp_query;
    if ( !empty( $wp_query->found_posts ) ) {
    	$title = $wp_query->found_posts . " " . __( 'search results for:', 'zn_framework' ) . " " .
    			 esc_attr( get_search_query() );
    }
    else {
    	if ( !empty( $_GET['s'] ) ) {
    		$title = __( 'Search results for:', 'zn_framework' ) . " " . esc_attr( get_search_query() );
    	}
    	else {
    		$title = __( 'To search the site please enter a valid term', 'zn_framework' );
    	}
    }
    WpkPageHelper::zn_get_subheader( array( 'title' => $title, 'title_tag' => 'h1' ) );
    
    // Check to see if the page has a sidebar or not
    $main_class = zn_get_sidebar_class( 'blog_sidebar' );
    if ( strpos( $main_class, 'right_sidebar' ) !== false || strpos( $main_class, 'left_sidebar' ) !== false ) {
    	$zn_config['sidebar'] = true;
    }
    else {
    	$zn_config['sidebar'] = false;
    }
    $sidebar_size = zget_option( 'sidebar_size', 'unlimited_sidebars', false, 3 );
    $content_size = 12 - (int)$sidebar_size;
    
    $zn_config['size'] = $zn_config['sidebar'] ? 'col-sm-8 col-md-'.$content_size : 'col-sm-12';
    $cacheZn_config = $zn_config;
    ?>
    	<section id="content" class="site-content">
    
    		<div class="container kl-searchpage">
    
    			<div class="row">
    
    				<!--// CONTENT -->
    				<div class="<?php echo esc_attr( $main_class ); ?>" <?php echo WpkPageHelper::zn_schema_markup('main'); ?>>
    
    					<div class="row">
    						<div class="col-sm-12">
    							<div class="search-form-wrapper u-mb-30">
    								<div class="search gensearch__wrapper kl-gensearch--<?php echo zget_option( 'zn_main_style', 'color_options', false, 'light' ); ?>">
    									<?php get_search_form(); ?>
    								</div>
    							</div>
    						</div>
    					</div>
    
    					<?php $postCount = 0; ?>
    					<?php if ( have_posts() ) : ?>
    
    						<?php
    							// get_template_part( 'blog', 'columns' );
    							include(locate_template( 'blog-columns.php' ));
    						?>
    
    					<?php else : ?>
    						<h2 class="center kl-searchpage-nores"><?php _e( 'Nothing Found', 'zn_framework' ); ?></h2>
    						<p class="center kl-searchpage-nores-text"><?php _e( 'Sorry, nothing matched your search criteria.', 'zn_framework' ); ?></p>
    					<?php endif; ?>
    				</div>
    				<?php
    					$zn_config = $cacheZn_config;
    					get_sidebar();
    				?>
    			</div>
    
    			<?php if ( $postCount > 8 ) { ?>
    				<div class="row">
    					<div class="col-sm-12">
    						<div class="search-form-wrapper u-mb-30">
    							<div class="search gensearch__wrapper kl-gensearch--<?php echo zget_option( 'zn_main_style', 'color_options', false, 'light' ); ?>">
    								<?php get_search_form(); ?>
    							</div>
    						</div>
    					</div>
    				</div>
    			<?php } ?>
    		</div>
    
    	</section>
    <?php get_footer();

    SEARCHFORM.PHP

    <?php if(! defined('ABSPATH')){ return; } ?>
    
    <form id="searchform" class="gensearch__form" action="<?php echo home_url( '/' ); ?>" method="get">
    	<input id="s" name="s" value="<?php echo get_search_query() ?>" class="inputbox gensearch__input" type="text" placeholder="<?php esc_attr_e('SEARCH ...','zn_framework'); ?>" />
    	<button type="submit" id="searchsubmit" value="go" class="gensearch__submit glyphicon glyphicon-search"></button>
    	<?php if( zget_option( 'woo_site_search_type', 'zn_woocommerce_options', false, 'wp' ) == 'wc' && znfw_is_woocommerce_active() ){ ?>
            <input type="hidden" name="post_type" value="product">
        <?php } ?>
    </form>

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @aspsniper,

    I understand that when you search for products, you’re redirected to the homepage instead of the search results page.

    Could you please temporarily switch to the Storefront theme and deactivate all plugins except for WooCommerce and test to see if the issue persist?

    You can find a more detailed explanation on how to do a conflict test here: https://docs.woocommerce.com/document/how-to-test-for-conflicts/

    If you can’t do this on your live site, I’d recommend creating a staging site. If your host doesn’t offer that option, we recommend WP Staging for quickly spinning up a new test site: https://www.ads-software.com/plugins/wp-staging

    Please let me know what you find so I can help further.

    Thread Starter aspsniper

    (@aspsniper)

    Hi @sukafia Thank you for your support. You got me right, I’m looking to get the search result page instead of a homepage. I’ve installed the Storefront theme which I left on for now so you can check yourself. There are two search bars on the right. The top one works fine. That’s exactly what I’ve been looking for (search results with product photo and price) but the second search bar (bottom one) shows only large pictures of the products in the results. All plugins except woocommerce are deactivated.
    Regards

    • This reply was modified 3 years, 9 months ago by aspsniper.
    Thread Starter aspsniper

    (@aspsniper)

    Is there any way I can make this product search page work with my theme? Is the product search issue I have caused by woocommerce or the theme itself?

    Hi @aspsniper,

    Thank you for your patience.

    There are two search bars on the right. The top one works fine. That’s exactly what I’ve been looking for (search results with product photo and price) but the second search bar (bottom one) shows only large pictures of the products in the results.

    Could you please provide us with a screenshot so that we can see what you are describing? Also, I’d like to know how you’re adding the second search bar.

    You can upload the screenshot to a service like https://prnt.sc/ or https://snipboard.io/ and share the URL here.

    Is there any way I can make this product search page work with my theme? Is the product search issue I have caused by woocommerce or the theme itself?

    If the issue doesn’t exist on the Storefront theme, then it’s caused by your theme – The next step would be contacting your theme developers for assistance.

    Cheers!

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Please Help. Woocommerce search result page issue.’ is closed to new replies.