Discount Ninja
  • Discount Ninja Developer Hub
    • Storefront API
      • Promotion Engine
        • Enable
        • JavaScript API
          • Functions
          • Events
          • Objects
      • Widgets
        • Guiding principles
          • Accessibility
          • Localization
          • Integration
          • Style
        • Announcement Bar
        • Notification
        • Offer Rules Popup
        • Product Banner
        • Promotion Summary
        • Promotion Code Field
        • Promotional Badge
    • Integration
    • Theme edits
      • App blocks
        • Product Page Banner
        • Promo Code Field
        • Promotion Summary
      • Code edits
        • Product Detail Page (PDP)
          • Price
          • Banner
          • Badge
        • Product List Page (PLP) and Collections
          • Attributes
          • Price
            • Searchanise Search & Filter
            • Globo Smart Product Filter & Search (aka SPF)
            • AI Search & Product Filter (Ultimate Search)
            • Boost AI Search & Filter (aka PFS)
          • Badge
          • Pagination
          • Quick View
        • Cart
          • Root
          • Cart item
          • Promo Code Field
          • Promotion Summary
          • Subtotal
        • Gift With Purchase
Powered by GitBook
On this page
  • Standard pagination
  • Infinite scrolling
  • Example
  • Load more pagination
  • Snippet
  • Example

Was this helpful?

  1. Discount Ninja Developer Hub
  2. Theme edits
  3. Code edits
  4. Product List Page (PLP) and Collections

Pagination

PreviousBadgeNextQuick View

Last updated 5 months ago

Was this helpful?

Standard pagination

Standard pagination is a technique used to break down a large dataset into smaller, manageable "pages" of content, each accessible by a unique URL or link. Users can navigate through these pages one at a time, typically using "Previous" and "Next" buttons or numbered page links at the bottom of the page.

Discount Ninja automatically detects pagination and applies strikethrough pricing when users navigate to the next page.

Infinite scrolling

In infinite scrolling, additional content loads dynamically as the user scrolls down the page, rather than navigating through paginated sections or pressing a button. This creates a seamless experience by continuously appending data to the page without requiring user intervention.

To ensure strikethrough pricing is applied when new products are added to the PLP in this way, JavaScript is required. The event is used to communicate to the app that strikethrough pricing needs to be applied to the added products.

Example

function myInfiniteScrolling() {
    // Original logic
    ... fetch products
    ... render products
    
    // Inform Discount Ninja that new products have been added
    // Publish this event after the products have rendered
    document.dispatchEvent(new CustomEvent('la:dn:collection:updated'));
}

Load more pagination

However, when content is loaded only after pressing a button, it's often called "load more" pagination. While similar to infinite scrolling, it requires an explicit user action to trigger the next batch of content, rather than loading it automatically.

To ensure strikethrough pricing is applied when new products are added to the PLP in this way, you must mark the button with the data-la-dn-loadmore attribute.

Snippet

Use the following attribute to mark a "load more" button:

data-la-dn-loadmore

Example

<button id="loadMoreBtn" data-la-dn-loadmore>Load More</button>
Collection products updated