• Resolved ananddevops

    (@ananddevops)


    Hello,

    I am currently on a Product Category Page of a particular product. It shows all the products under that category. Since I am testing I added a single product and went to the page.

    I noticed that there are two Show By Popularity dropdowns showing there. See Screenshot . Ideally this will be useful when there are two many products, to sort at top as well at the bottom of page. But if the number of products are not many, is there a way the dropdown below?

    Is there a way that products can be shown vendor specific? Or only specific to a logged in vendor?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    Hey @ananddevops – I’m not sure I entirely follow what you’re trying to do.

    First of all, if you use Product Vendors, please contact us at WooCommerce.com > My Account > Tickets. We will be able to help you further there.

    Second, if you’re trying to hide the dropdown based on the quantity in a category, then you’d need some custom PHP or CSS.

    With PHP, you need to customize the snippet that Business Bloomer has created here:

    /**
    * @snippet Remove "Default Sorting" Dropdown @ StoreFront Shop & Archive Pages
    * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
    * @source https://businessbloomer.com/?p=401
    * @author Rodolfo Melogli
    * @compatible Woo 3.4.3
    */
     
    add_action( 'init', 'bbloomer_delay_remove' );
     
    function bbloomer_delay_remove() {
        remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
        remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 10 );
    }

    This can be also fixed with some custom CSS. Under Customize > Additional CSS, you can add the following code. Note that the term-clothing aspect will need to be replaced by the specific category. See the screenshot below.
     

    /* Hide sorting option on a category */
    
    .term-clothing .woocommerce-ordering {
        display: none;
    }

    Screenshot of where to find the category filter:


    Link to image: http://cld.wthms.co/c6xmQ3
     
    If you’d like to learn more about CSS, I highly recommend using the free tutorials at w3schools. Here, you can find the basics of selectors (how to target the right element on the page), and properties (how to change the element on the page).

    Thread Starter ananddevops

    (@ananddevops)

    @jobthomas

    Thanks again.

    For the first part, I am actually looking to display content, under a category, only as per a vendor and not as per quantity. I understand that I will need to pass the vendor details, as per the logged in specific vendor. Since I am using another plugin for vendors, hence I will request support from them.

    The CSS worked great with my respective change.

    I really appreciate your advice and resources on taking up CSS tutorial. I am already refering the same. But it is a learning curve and will need time and practice to scale up 🙂

    Thanks

    Hey,

    To expand upon @jobthomas’ answer above, I decided to write a small snippet to hide the duplicated sorting information / links for all categories based on how many products are in the category:

    
     add_action( 'wp', 'jk_remove_bottom_duplicate_sorting' );
    
     function jk_remove_bottom_duplicate_sorting() {
    	 global $wp_query;
    	 $count = absint( $wp_query->get_queried_object()->count );
    
    	 if ( '4' > $count ) {
    		 remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper', 9 );
    		 remove_action( 'woocommerce_after_shop_loop', 'woocommerce_catalog_ordering', 10 );
    		 remove_action( 'woocommerce_after_shop_loop', 'woocommerce_result_count', 20 );
    		 remove_action( 'woocommerce_after_shop_loop', 'woocommerce_pagination', 30 );
    		 remove_action( 'woocommerce_after_shop_loop', 'storefront_sorting_wrapper_close', 31 );
    	 }
     }
    

    In this example, if there are fewer than 4 products in a category only one group of sorting & ordering info / links will be displayed. Just change that 4 to another value if you prefer.

    James
    Designer @ Automattic

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide Show By Popularity on Product Category Page?’ is closed to new replies.