Forums Forums Search Search Results for 'archive-product'

Viewing 3 results - 61 through 63 (of 63 total)
  • Author
    Search Results
  • #2178

    Anonymous
    Inactive

    Thanks for the help!

    My fix for the time being is to simply create a new archive-product.php in the theme root with this:

    <?php 
    
    add_filter('body_class','my_class_names');
    function my_class_names($classes) {
    	// add 'class-name' to the $classes array
    	$classes[] = 'woocommerce';
    	// return the $classes array
    	return $classes;
    }
    
    include 'woocommerce/archive-product.php';
    
    ?>

    i should note that my_class_names() is an unrelated fix 😉

    #2173

    Anonymous
    Inactive

    I’m trying to use the template override when searching my woocommerce products.

    The woocommerce templates are usually stored in ‘theme/woocommerce/archive-product.php’, but when entering ‘woocommerce/archive-product.php’ as custom template in the search form config, the slash is stripped so it becomes ‘woocommercearchive-product.php’.

    Moving archive-product.php to the themes root folder seems to work, but then I have 2 template files serving the same prupose… Any other options?

    #1807

    Ross
    Keymaster

    Hey Petr

    Yes, basically you need to create your own template, and create a widget area specifically for this page…

    1) Make sure custom template is ticked in admin
    2) Make sure you enter a slug (ie product-search)
    3) Create your custom template

    Now that you are using a slug you can access your search results like:
    yoursite.com/product-search and if you are using a custom template then you can restrict S&F to only appear on this template.

    Now the tricky part…. I had to do quite a lot of modification to get it working with the mystile theme exactly how I wanted.

    First I duplicated the archive-product.php from the woocommerce templates folder and called this products-search.php and put this in my theme folder.

    Then I create and register a sidebar, so…. Add this code to functions.php of your theme:

    register_sidebar(array(
    	'name'=> 'Search & Filter Form Widgets',
    	'id' => 'search_filter_form_widget',
    	'before_widget' => '',
    	'after_widget'  => '',
    	'before_title'  => '<h2 class="widgettitle">',
    	'after_title'   => '</h2>'
    ));

    Now you will find a new widget area to add S&F widget.

    We need to include this in our products-search.php though so we must create a sidebar first…

    Create a new file in your theme folder called sidebar-search-form.php and add the code:

    <?php 
    /**
     * Sidebar Template
     *
     * If a <code>primary</code> widget area is active and has widgets, display the sidebar.
     *
     * @package WooFramework
     * @subpackage Template
     */
    	global $woo_options;
    	
    	if ( isset( $woo_options['woo_layout'] ) && ( $woo_options['woo_layout'] != 'layout-full' ) ) {
    ?>	
    <aside id="sidebar" class="col-right">
    
    	<?php dynamic_sidebar( 'search_filter_form_widget' ); ?>
    	
    </aside><!-- /#sidebar -->
    <?php } // End IF Statement ?>

    Now we have a sidebar that loads our custom widget area…. but this is still not in our template… so in the template product-search.php add:

    <?php 
    	get_sidebar('search-form');
    ?>

    And there you have it! A new widget area just for your custom template 🙂

Viewing 3 results - 61 through 63 (of 63 total)