• Resolved paul91

    (@paul91)


    I have button which works almost great with this plugin but that button won’t hide after click on last page when it’s not necessary.
    Test products are on 3 pages and the source code of my pagination button is:

    <?php
    $current_page = get_query_var('page');
    if ( ! $current_page ) {
    $current_page = 1;
    }
    if($current_page < $wc_query->max_num_pages+1):?>
    <div class="btn-next-wrap col-xs-10 col-xs-offset-1 text-center"><a class="btn-next btn btn-transparent" href="<?php echo site_url()?>/shop/?page=<?php echo $current_page+1;?>">Load more products</a></div>
    <?php
    endif; 
    ?> 

    When I use it as standard pagination it works properly with condition
    if($current_page < $wc_query->max_num_pages) except if($current_page < $wc_query->max_num_pages+1). But in that case the button remains with link to the 3rd page and after click it shows products from that page several times infinitely.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Dmytro Holovnia

    (@dholovnia)

    if($current_page < $wc_query->max_num_pages+1):
    to
    if($current_page < $wc_query->max_num_pages):

    Thread Starter paul91

    (@paul91)

    Thank you for reply. I changed it but still doesn’t work althought this is proper solution for standard pagination. I described the problem in the last paragraph under source code. Now it’s visible on web.

    Plugin Author Dmytro Holovnia

    (@dholovnia)

    Load More Products plugin replace default pagination with the button. No need to edit pagination in any case. More than that it is using links from default pagination so editing it can break Load More plugin functionality.

    Right now it is broken. 3d page is loading forever. Just set there default pagination and it will be working

    Thread Starter paul91

    (@paul91)

    I am not sure what is default pagination in this case because it’s not product archive page. But I am pretty surre, that link to 3rd page is not broken. You can check my page, because now I canceled load more button plugin functionality.

    I also tried code from woocommerce/template/loop/pagination.php:

    <nav class="woocommerce-pagination">
    	<?php
    		echo paginate_links( apply_filters( 'woocommerce_pagination_args', array(
    			'base'         => esc_url_raw( str_replace( 999999999, '%#%', remove_query_arg( 'add-to-cart', get_pagenum_link( 999999999, false ) ) ) ),
    			'format'       => '',
    			'add_args'     => false,
    			'current'      => max( 1, get_query_var( 'paged' ) ),
    			'total'        => $wp_query->max_num_pages,
    			'prev_text'    => '&larr;',
    			'next_text'    => '&rarr;',
    			'type'         => 'list',
    			'end_size'     => 3,
    			'mid_size'     => 3,
    		) ) );
    	?>
    </nav>

    Which shows links to 3 pages and also next and previous. When I link it to the Load More Products accoring to propper classed then pagination is completely hidden with display:none.

    Plugin Author Dmytro Holovnia

    (@dholovnia)

    “Which shows links to 3 pages and also next and previous. When I link it to the Load More Products accoring to propper classed then pagination is completely hidden with display:none.” and the button is shown instead and loading next page with ajax. Yes, this is how it is working. Hiding woocommerce pagination with display:none and using its links to load next pages

    Thread Starter paul91

    (@paul91)

    This is ok. But load more button generated by plugin is also hidden. And it doesn’t work on click (if I set force display or by developpers tools in browser).

    Thread Starter paul91

    (@paul91)

    I finally solved it. The expected functionality for this plugin is that the pagination element is always exists and only next page link is missing on the last page but I completely ommited pagination on the last page.

    • This reply was modified 7 years, 5 months ago by paul91.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Hide button after load last page’ is closed to new replies.