• Resolved sjoerd89

    (@sjoerd89)


    Hi there,

    i would like to add a product count on top of my shop page (woocommerce) to show how much products are left when filtering. I added the following to my functions.php

    // [product_count] shortcode
    function product_count_shortcode( ) {
    	$count_posts = wp_count_posts( 'product' );
    	return $count_posts->publish;
    }
    add_shortcode( 'product_count', 'product_count_shortcode' );

    And dropped that shortcode [product_count] on top of the page. Now it shows the ammount of products in total but i want something like when i filter the products it says something like “12 out of 300 products”. I know it was there once but for no reason it is not there anymore. Can i fix this by adding some kind of function or do you have any other solution?
    -https://codepen.io/Sjoerd89/pen/zKOqRo

    Thanks for your time,

    Sjoerd

    PS: The normal productcount is not there and no clue why because i think i had it in the beginning.

    https://www.ads-software.com/plugins/woocommerce/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I know it was there once but for no reason it is not there anymore.

    Correct, this is shown by default: https://cld.wthms.co/rnCW/3bou943F. Something on your site must be removing it. A static shortcode like that won’t work because it won’t update with ajax.

    It would be better to find out why this count no longer shows. Try temporarily switching back to the WordPress Twenty Sixteen Theme, or Storefront, and disable all plugins except for WooCommerce. If that resolves the issue, then slowly re-enable features until you find the one that’s causing the conflict.

    Thread Starter sjoerd89

    (@sjoerd89)

    Well i removed all plugins and restored to the twentysixteen aswell as the storefront theme and in both options with just the woocommerce plugin opened the product count is not there https://clip2net.com/s/3BIhXg5

    Hmmmm i am stuck ??

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    I don’t see the sorting option either. Are you viewing the main shop page / an automatically generate archive page like a category page? Else are you on a custom page with products via shortcode or something?

    The count and sorting only work on archive pages.

    Thread Starter sjoerd89

    (@sjoerd89)

    It is a category page but it should been an archive page since the filter plugin WOOF needs me to have an archive page to find the products.
    Not 100% sure about this

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    Hmm, I’m out of ideas then. If you truly have all other plugins disabled and it still isn’t showing on archive pages when a default theme is active – then something strange is happening. Likely something was tampered with that shouldn’t have been.

    Thread Starter sjoerd89

    (@sjoerd89)

    Hmm if i make the shoppage a random test page instead of a category page i indeed have the count product there. So now i guess i have to figure out how to work around this and get it on my category pages? Or according to you this isn’t possible.

    Caleb Burks

    (@icaleb)

    Automattic Happiness Engineer

    It should show up on category pages as well: https://cld.wthms.co/1bopb/ylb93O0N

    I don’t think you are using the actual category pages. Go to Products > Categories in the settings, and click “View” under one of your categories with products. Then you will be on the actual category page.

    Thread Starter sjoerd89

    (@sjoerd89)

    Okay that’s it indeed it works on that page! Thanks alot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding the productcount on top of shoppage’ is closed to new replies.