Woocommerce search some html

I try to found this code in plugin woocommerce, but i did’nt found

<mark class="count">(1)</mark>

it’s a number count for category product

Read More

check http://inst1226908-45105.crystone.net/boutique/

version woocommerce 2.5.1

Related posts

4 comments

  1. The html that you are looking for should be in your theme’s custom WooCommerce template files /wp-content/theme//woocommerce

  2. What you are looking for has been moved to /woocommerce/includes/wc-template-functions.php

    function woocommerce_template_loop_category_title( $category ) {
        ?>
        <h3>
            <?php
                echo $category->name;
    
                if ( $category->count > 0 )
                    echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class="count">(' . $category->count . ')</mark>', $category );
            ?>
        </h3>
        <?php
    }
    

    You can simply run a filter on woocommerce_subcategory_count_html

  3. In WooCommerce 2.5.1 this line of code

    echo apply_filters( 'woocommerce_subcategory_count_html', ' <mark class="count">(' . $category->count . ')</mark>', $category ); 
    

    has been moved to woocommerce/includes/wc-template-functions.php on line 539

  4. That code used to be in a template file:

    woocommerce/templates/content-product_cat.php.

    But, as @silver points out in his answer, in recent changes, it’s been moved to a functions file. Note: Please see my recommendation at the bottom – this is exactly why you want to do filters, not template modifications.

    If you view the code, you will see that it allows you to apply_filters to it, in case you want to modify it.

    You would likely want to do that (apply filters) instead of modifying the template, however WooCommerce does offer a template override system which means that you could create custom versions of templates and locate them in your theme (within a folder title woocommerce inside your theme).

    If you wanted to modify this output, you’d do it like this. Add the following to your theme functions.php file:

    add_filter('woocommerce_subcategory_count_html', 'my_subcategory_filter', 10, 2);
    
    function my_subcategory_filter($markup, $category) {
        return '<div class="my_new_class">' . $category->count . ' subcategories</div>';
    }
    

    it is my strong recommendation that you avoid modifying template files if you can. In this case, you can, so rather than modifying the template, use the filters.

    Why? Because there are OFTEN breaking changes in WooCommerce updates that will cause you to have to update / modify your “custom” templates. This turns into a lot of work, because Woo updates WooCommerce often, and there are often template updates.

Comments are closed.