Next Previous Button On Product Page

PHOTO EMBED

Wed Jun 15 2022 13:38:58 GMT+0000 (UTC)

Saved by @websensepro #shopify #shapedivider #divider

{%- liquid
    assign previous_product = collection.previous_product
    assign next_product = collection.next_product
    if previous_product or next_product
    else
    	assign collectionList = product.collections[0].handle
        assign previous_product = nil
        assign next_product = nil
        assign last = collections[collectionList].products_count
        for p in collections[collectionList].products
        	if p.handle == product.handle
            	assign prev = forloop.index | minus: 2
                assign next = forloop.index
                if prev >= 0
                  assign previous_product = collections[collectionList].products[prev].handle
                endif
                if last >= next
                  assign next_product = collections[collectionList].products[next].handle
                endif
                break
            endif
        endfor
    endif
-%}       
            
<div id="nextpre">
    		{%- if previous_product -%}
            <a class="next-prev-icon prev-icon" href="{{ previous_product }}">
               <---------
            </a>
        {%- endif -%}
        {%- if next_product -%}
            <a class="next-prev-icon next-icon" href="{{ next_product }}">
               --------->
            </a>
        {%- endif -%}
    </div>
content_copyCOPY