Okay
  Public Ticket #2169898
product count on top of shop/archieve page not correct with infinite is wrong
Closed

Comments

  •  15
    hahni started the conversation

    Hello together again,

    I have another problem with the infinite option with woocommerce:

    Normally on top of every shop / archive page there is the actual count like:

    1-12 from 298

    Where 12 are the actual shown products - with normal pagination the "1" and "12" is changing each time the user clicks to the next page BUT with infinite scroll the numbers are NOT changing!!!!

    How could I change this? normally the "12" should change every time the user scrolls to the next "infinite loading".


    Regards André


  • [deleted] replied

    Hi André,

    This option is implemented in the theme but you can add this custom JavaScript to update the number of results:

    <script>
    jQuery( document ).ready( function( $ ) {
        $( document ).on( 'kalium-infinite-scroll-request-done', function( ev, infinite_scroll_instance, data ) {
            var $resultCounter = $( '.woocommerce-result-count' ),
                text = $resultCounter.html(),
                itemsFetched = data.fetchedItems.length,
                currentFetched = text.match( /–([0-9]+)/g );
            
            if ( currentFetched && currentFetched.length ) {
                var currentFetchedNum = +currentFetched[0].replace( '–', '' );
                $resultCounter.html( text.replace( currentFetched, '–' + ( currentFetchedNum + itemsFetched ) ) );
            }
        } );
    } );
    </script>
    
    I have tested and it works, see here:

    https://d.pr/v/YVZ9wa

    To add this Custom JS go to Theme Options > Footer > JavaScript > Footer JavaScript

  •  15
    hahni replied

    Thank You Arlind,

    i will try in the next hours and try if it will work good with activated "filter plugin".

    Regards André


  •  15
    hahni replied

    I have seen that in the source:

    <?php
    // Disable infinite scroll pagination when WC_Prdctfltr pagination is used
    if ( class_exists( 'WC_Prdctfltr' ) && 'yes' == get_option( 'wc_settings_prdctfltr_use_ajax', 'no' ) && 'default' != get_option( 'wc_settings_prdctfltr_pagination_type', 'default' ) ) {
    return;
    }
    

    i have to make some test and think about a solution:

    i want to have infinite scrolling and the product-filter together....


  • [deleted] replied

    Hi hahni,

    The product filter we use here it updates the number of current shown results:

    https://demo.kaliumtheme.com/automotive/cars/

    So if you are using a plugin to filter items it should automatically update filter counter, the container class is not changed from original WooCommerce template: "woocommerce-result-count"