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
  • Attributes
  • Price
  • Badge
  • Example

Was this helpful?

  1. Discount Ninja Developer Hub
  2. Theme edits
  3. Code edits
  4. Product Detail Page (PDP)

Badge

PreviousBannerNextProduct List Page (PLP) and Collections

Last updated 5 months ago

Was this helpful?

The instructions in this article constitute a workaround to show a badge on the Product Detail Page (PDP) that is originally designed to be displayed on the Product List Page (PLP) and Collections. The style and text of the badges displayed on the PDP cannot be managed separately.

Attributes

Add the data attributes, documented , around the section where you want to display the badge.

Price

In order for the badge to work, a price section must be included inside the elemented that has the attributes. This section should be hidden.

Example:

<span style="display:none" data-la-dn-price></span>

Badge

Optionally, add the badge class, documented , on the element that should act as the parent of the badge.

Example

<div id="my-product-page-image-gallery"
     data-la-dn-product-handle="{{ product.handle }}" 
     data-la-dn-product-id="{{ product.id }}" 
     data-la-dn-product-collection-handles="{{ product.collections | map: 'handle' | join: ',' | default: '[[--NONE--]]' }}" 
     data-la-dn-product-collection-ids="{{ product.collections | map: 'id' | join: ',' | default: '[[--NONE--]]' }}" 
     data-la-dn-product-available="{{ product.available}}" 
     data-la-dn-product-price="{{ product.first_available_variant.price | default: product.price }}"
     data-la-dn-product-compare-at-price="{{ product.first_available_variant.compare_at_price | default: product.first_available_variant.price | default: product.compare_at_price | default: product.price }}" 
     data-la-dn-product-compare-at-price-varies="{{ product.compare_at_price_varies }}"
     data-la-dn-product-price-varies="{{ product.price_varies }}" 
     data-la-dn-product-price-min="{{ product.price_min }}"
     data-la-dn-product-tags="{{ product.tags | join: ',' | escape | default: '[[--NONE--]]' }">
    ...
    <span style="display:none" data-la-dn-price></span>
    ...
    <div id="my-product-page-image" class="la-dn-collection-badge">
        <img>
        ...
    </div>    
</div>

here
here