Forums Forums Search Search Results for 'archive-product'

Viewing 10 results - 1 through 10 (of 63 total)
  • Author
    Search Results
  • #268370

    In reply to: Enable has_archive


    Anonymous
    Inactive

    Hello,

    Thank you for your response,
    Something missed,

    I use CPT UI and your plugin, I’ve added ‘product’ as CPT, I’ve added a filter ‘taxonomy 1: brand, and taxonomyy2: Categorie. I followed the instruction it worked, the filter works fine.

    * I checked ‘product'(without woo-commerce, is it correct?) in the general tab.
    * And ‘custom post type’ in the display result.

    Taxonomy worked but But the search field didn’t work, It shows a 404 page

    I use templatetoaster theme (parent)

    I tried to create archive-product.php and single-product.php but the website use single.php and archive.php.

    I’ve added any code in the theme and function.php .. 🙂

    Thank you or your help,

    Best regards.
    Sam


    Anonymous
    Inactive

    split by @trevorsf from https://support.searchandfilter.com/forums/topic/different-filters-for-different-product-categories/

    Any news when is new version is coming.

    I tried setting up multiple filters for different categories, by using the “As an Archive” option, and using a copy of woocommerce’s “archive-product.php” (in my child theme folder) as the template.

    While the page loads fine, when I click on any of the filters, I get redirected to an archive page with no results.

    If you know how to set it up properly using this method that would be really helpful for the time being

    #263195

    Anonymous
    Inactive

    Hi Ross,

    Not sure why the dev has added two forms tbh, but when I check in archive-product.php, it’s using the ID 37.

    <?php echo do_shortcode('[searchandfilter id="37"]') ?>

    I have also put the ID 15240 and it seems to be the same as 37.

    #262084

    Anonymous
    Inactive

    the pH field is a range, which is not included in the Auto Count function, so it will potentially show ranges that are empty.

    We don’t mind having the empty ranges there on the field, the problem is that when choosing an empty range, no results should be shown, and all are shown.

    In turn, if the template does not have the No Results Found code inside the Ajax Container, then, when submitting a search for a range that has no results could give what you see.

    Our PHP template just includes the regular WooCommerce archive-product.php which does have a regular loop and a “no results” section, but it didn’t had the same CSS class name. That solved, thanks!

    Does the site have a lot of products/posts already, or is it in development? I ask because this might determine which is the best way forwards.

    It’s a live site with 2000+ products.

    If Ajax is OFF in the form, what then happens?

    That’s how I found out the problem 🙂

    #258597

    Trevor
    Participant

    The guide here shows how to set the forms for use in Post Archive (and thus associated Post Type Taxonomy Archive) pages (you need to be using the Archive Posts widget in the template for these pages, and our form needs to be set to the Post Type Archive method, which restricts you to searching in a single Post type):

    https://searchandfilter.com/documentation/3rd-party/elementor/#archive-posts-archive-products-widgets

    This method does not require a results URL.

    #257636

    Trevor
    Participant

    Here is the modified template code (copy it from the forum post, not the email, as email software will change some characters).

    What did I change?

    On line 78 is where I moved the form output to. I commented out the line where it had been – line 104. If this new code works, you can remove line 104.

    Line 80 is commented out (in HTML – again if this works, remove this line):

    <li class="product">

    and added back in at line 109 as an echo, and the ending </li> added in at line 123 also as an echo, and the original end </li> now on line 128 is commented out (can also remove).

    Try this code then:

    <?php
    /**
     * The Template for displaying product archives, including the main shop page which is a post type archive
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce/Templates
     * @version 3.4.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    get_header( 'shop' ); ?>
    
    <?php
    
    /**
     * Hook: woocommerce_before_main_content.
     *
     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
     * @hooked woocommerce_breadcrumb - 20
     * @hooked WC_Structured_Data::generate_website_data() - 30
     */
    do_action( 'woocommerce_before_main_content' );
    
    ?>
    <header class="woocommerce-products-header">
            <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
                    <h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
            <?php endif; ?>
    
            <?php
            /**
             * Hook: woocommerce_archive_description.
             *
             * @hooked woocommerce_taxonomy_archive_description - 10
             * @hooked woocommerce_product_archive_description - 10
             */
            do_action( 'woocommerce_archive_description' );
            ?>
    </header>
    
    <?php
    
    if ( woocommerce_product_loop() ) {
    
            /**
             * Hook: woocommerce_before_shop_loop.
             *
             * @hooked woocommerce_output_all_notices - 10
             * @hooked woocommerce_result_count - 20
             * @hooked woocommerce_catalog_ordering - 30
             */
            do_action( 'woocommerce_before_shop_loop' ); ?>
    
    echo do_shortcode('[searchandfilter id="3791"]');
            <ul class="wpf-search-container products">
    <!--        <li class="product"> -->
            <?php
    
    // Get The queried object ( a WP_Term or a WP_Post Object)
    $term = get_queried_object();
    
    // To be sure that is a WP_Term Object to avoid errors
    if( is_a($term, 'WP_Term') ) :
    
    // Setup your custom query
    $loop = new WP_Query( array(
        'post_type'      => 'product',
        'posts_per_page' => -1,
        'post_status'    => 'publish',
        'tax_query'      => array( array(
            'taxonomy' => 'product_cat', // The taxonomy name
            'field'    => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
            'terms'    => $term->term_id, // can be an integer, a string or an array
        ) ),
    ) );
            
    //echo do_shortcode('[searchandfilter id="3791"]');
    
    if ( $loop->have_posts() ) :
    while ( $loop->have_posts() ) : $loop->the_post();
    echo '<li class="product">';
    the_post_thumbnail( 'thumbnail');
    echo '<div style="margin:8px;">';
    echo 'movie preview - ';
    the_title();
    echo "<br>";
    $price = get_regular_or_sale_price();
            echo $price;
            echo '&nbsp';
    $regularpriceifsale = get_regular_price_if_sale();
            echo $regularpriceifsale;
    echo '<br>';
    echo '<br>';
    echo '</div>';
    echo '</li>';
    endwhile;
    wp_reset_postdata(); // Remember to reset
    endif; endif;
    ?>
    <!--                </li> -->
    </ul>
    <?php
    
            /**
             * Hook: woocommerce_after_shop_loop.
             *
             * @hooked woocommerce_pagination - 10
             */
            do_action( 'woocommerce_after_shop_loop' );
    } else {
            /**
             * Hook: woocommerce_no_products_found.
             *
             * @hooked wc_no_products_found - 10
             */
            do_action( 'woocommerce_no_products_found' );
    }
    
    /**
     * Hook: woocommerce_after_main_content.
     *
     * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
     */
    do_action( 'woocommerce_after_main_content' );
    
    /**
     * Hook: woocommerce_sidebar.
     *
     * @hooked woocommerce_get_sidebar - 10
     */
    do_action( 'woocommerce_sidebar' );
    ?>
    
    <?php get_footer(); ?>
    #257130

    Anonymous
    Inactive

    Hi Trevor sorry about the confusion hopefully I can clarify for you.

    I’m looking to be able to filter products in my archive-product.php, search.php, and profile-defaultcopy.php. These templates use a custom product loop.

    Example A-1] If customer clicks "Groceries" category link, I need them to be able to filter through the "Groceries" products by tag. Example A-2] If customer searches “coffee” in the homepage search box, it brings them to search.php results. I need the “coffee” search result products to be filterable by tag and category. Example A-3] If customer is on profile-defaultcopy.php I need them to be able to filter the products there by tag and category.

    B-1] So, I need help setting up the Search and Filter forms properly and B-2] I need help getting the filter to work with my custom product loop.

    C-1] Are you able to set up the filters for me? I’m just really confused how to get them to show up on archive-product.php, search.php, and profile-defaultcopy.php. C-2] Can you ensure that once the filter is showing up, it is filtering products in my custom product loop?

    Does this all make more sense? Again, sorry for the confusion! Please let me know if I can clarify anything for you via Skype.

    #256497

    Anonymous
    Inactive

    Thank you Trevor in advance for your help ~

    I’m having some trouble setting this up. My goal is to have a filterable archive and filterable search. For example, 1] if user is on category=groceries (archive-product.php), they can filter groceries results and 2] if user searches “coffee” in search box on the homepage they can filter search.php results.

    I use custom loops on my archive-product.php and search.php, both using WP_Query.

    Based on your documentation – custom search results I should:

    1] Attach Search & Filter to a query
    But how to add this to my loops?

    $args = array('post_type' => 'post');
    $args['search_filter_id'] = 123;
    $query = new WP_Query($args);

    2] Enter the results URL where the query/results will be found
    I’m confused about what to enter here in order for archive and search filters to work.

    Here is my relevant search.php code:

    <?php
    $s=get_search_query();
    $args = array(
                    's' =>$s
                );
        // The Query
    $the_query = new WP_Query( $args );
    if ( $the_query->have_posts() ) {
            echo "The search results:";
            while ( $the_query->have_posts() ) {
               $the_query->the_post();
                     ?>
                        <ul>
                            <?php
    the_post_thumbnail( 'thumbnail');
    the_title();
    wp_reset_postdata(); // Remember to reset
    ?>				
    </ul>

    Here is my archive-product.php:

    <?php
    /**
     * The Template for displaying product archives, including the main shop page which is a post type archive
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see https://docs.woocommerce.com/document/template-structure/
     * @package WooCommerce/Templates
     * @version 3.4.0
     */
    
    defined( 'ABSPATH' ) || exit;
    
    get_header( 'shop' );
    get_sidebar();
    
    /**
     * Hook: woocommerce_before_main_content.
     *
     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
     * @hooked woocommerce_breadcrumb - 20
     * @hooked WC_Structured_Data::generate_website_data() - 30
     */
    do_action( 'woocommerce_before_main_content' );
    
    ?>
    <header class="woocommerce-products-header">
    	<?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?>
    		<h1 class="woocommerce-products-header__title page-title"><?php woocommerce_page_title(); ?></h1>
    	<?php endif; ?>
    
    	<?php
    	/**
    	 * Hook: woocommerce_archive_description.
    	 *
    	 * @hooked woocommerce_taxonomy_archive_description - 10
    	 * @hooked woocommerce_product_archive_description - 10
    	 */
    	do_action( 'woocommerce_archive_description' );
    	?>
    </header>
    <?php
    
    if ( woocommerce_product_loop() ) {
    
    	/**
    	 * Hook: woocommerce_before_shop_loop.
    	 *
    	 * @hooked woocommerce_output_all_notices - 10
    	 * @hooked woocommerce_result_count - 20
    	 * @hooked woocommerce_catalog_ordering - 30
    	 */
    	do_action( 'woocommerce_before_shop_loop' ); ?>
    
    	<ul class="wpf-search-container products">
    	<li class="product">
    	<?php
    
    // Get The queried object ( a WP_Term or a WP_Post Object)
    $term = get_queried_object();
    
    // To be sure that is a WP_Term Object to avoid errors
    if( is_a($term, 'WP_Term') ) :
    
    // Setup your custom query
    
    $loop = new WP_Query( array(
        'post_type'      => 'product',
    	['search_filter_id'] => 123;
        'posts_per_page' => -1,
        'post_status'    => 'publish',
        'tax_query'      => array( array(
            'taxonomy' => 'product_cat', // The taxonomy name
            'field'    => 'term_id', // Type of field ('term_id', 'slug', 'name' or 'term_taxonomy_id')
            'terms'    => $term->term_id, // can be an integer, a string or an array
        ) ),
    ) );
    
    if ( $loop->have_posts() ) :
    while ( $loop->have_posts() ) : $loop->the_post();
    the_post_thumbnail( 'thumbnail');
    the_title();
    endwhile;
    wp_reset_postdata(); // Remember to reset
    endif; endif;
    ?>
    		</li>
    </ul>
    <?php
    
    	/**
    	 * Hook: woocommerce_after_shop_loop.
    	 *
    	 * @hooked woocommerce_pagination - 10
    	 */
    	do_action( 'woocommerce_after_shop_loop' );
    } else {
    	/**
    	 * Hook: woocommerce_no_products_found.
    	 *
    	 * @hooked wc_no_products_found - 10
    	 */
    	do_action( 'woocommerce_no_products_found' );
    }
    
    /**
     * Hook: woocommerce_after_main_content.
     *
     * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content)
     */
    do_action( 'woocommerce_after_main_content' );
    
    /**
     * Hook: woocommerce_sidebar.
     *
     * @hooked woocommerce_get_sidebar - 10
     */
    do_action( 'woocommerce_sidebar' );
    ?>
    
    <?php get_footer(); ?>
    #254674

    Anonymous
    Inactive

    Edit number 2:

    after further investigation it is like the children/subcategories don’t actually get :checked like the parents do hence not seeing the :checked css.

    Also it appears that everything works well on:
    archive post-type-archive post-type-archive-products

    but on:
    archive tax-product_category term-beverage-packing-equipment
    This is where nothing is reading through…

    Any help would be awesome please

    #248139

    Anonymous
    Inactive

    My form has:

    Search
    Taxonomy: product_cat
    Sort Order
    Post Per Page
    Post Meta: _price
    Reset Button
    Submit Button

    The search seems broken, but that is mostly due to one single reason.

    For this explanation I disabled AJAX and use only Submit manual, my settings are as recommended, Woocommerce Shop display results, correct post metas etc. The search I think works good. Let me start saying that the price widget, doesn’t work, at all. It firstly worked when I had 20 products, but then it stopped (not 20 products as in time frame when testing this website, not in correlation), I haven’t changed anything, I only added 30-40 products by duplication, I added more since than with import, but it does not work. I change/slide it, the link changes, I submit it, nothing.

    Categories work half the time, and this is mostly because the filter form switches from the default shop archive-page.php to taxonomy-product_cat.php. So when I visit the store the first time, it is on archive-page.php, I use the filter, select category – switches to taxonomy-product_cat.php with the correct results, but when I search again, for example I change my category from the drop-down, it first goes to archive-product.php, resetting my search results, like clicking reset and ignoring what I selected, and if I then just click again on the submit button, it works correctly. Of course this is not an intuitive/nor I think intended way of working.

    Last thing is the results per page, when the price filter worked, the result page did not count properly – not that the price slider does not work, I cannot tell.

    It would be great to get these stuff resolved, thank you!

Viewing 10 results - 1 through 10 (of 63 total)