Discount Ninja
Search
K
Comment on page

Component

Methods

render: renders the banner(s) based on the messages received
  • Parameters:
    • message (object):
      • token (string) [required]: the token of the associated Discount Ninja offer
      • available:
        • indicates if the product variant is in stock (true) or out of stock (false)
        • default value: true
      • location ("product-page" | "collection" | "drawer-cart" | "cart") [required]: The location where the price is displayed
      • Attributes required for location collection:
        • productHandle (string): the message is intended for placeholders with a matching product-handle attribute
      • Attributes required for location product-page:
        • productHandle (string): the message is intended for placeholders with a matching product-handle attribute
        • variantId (number | null): if available, the message is intended for placeholders with a matching variant-id attribute; when variantId is available, the component disregards productHandle
      • Attributes required for locations cart and drawer-cart
        • level ("product" | "line" | "total"): the message is intended for placeholders with a matching line-item-key attribute
        • line-item-key (string) [required if level is "product" or "line"): the message is intended for placeholders with a matching line-item-key attribute
      • discounted:
        • indicates if the product variant is discounted (true) or not (false)
        • default value: false
      • Attributes when discounted is false:
        • price (number) [required]: the price variable
      • Attributes when discounted is true:
        • price (number) [required]: the price variable
        • compare-at-price (number): the compare-at-price variable
        • msrp (number): the msrp variable
        • unit-price (number): the unit-price variable
        • compliance-price (number): the compliance-price variable
      • Template content attributes:
        • header (string)
        • footer (string)
        • price-prefix (string)
        • price-suffix (string)
        • compare-at-price-prefix (string)
        • compare-at-price-suffix (string)
        • unit-price-prefix (string)
        • unit-price-suffix (string)
        • msrp-prefix (string)
        • msrp-suffix (string)
        • compliance-price-prefix (string)
        • compliance-price-suffix (string)

Examples

  • Product variant 123456 should be marked as out of stock on the product page
{
token: "ABCD",
location: "product-page",
variant-id: 123456,
available: false
}
  • Product variant 123456 is not discounted, its price should display as $120 on the product page
{
token: "ABCD",
location: "product-page",
variant-id: 123456,
discounted: false,
price: 12000
}
  • Product variant 123456 is discounted, its price should display as $100 on the product page, with a compare-at price of $120
{
token: "ABCD",
location: "product-page",
variant-id: 123456,
discounted: true,
price: 10000,
compare-at-price: 120000
}
  • Product variant 123456 is discounted, its price should display as $100 on the product page, with an MSRP of $180
{
token: "ABCD",
location: "product-page",
variant-id: 123456,
discounted: true,
price: 10000,
msrp: 180000
}
  • Cart line item 1 is discounted, its product price should display as $100 on the drawer cart, with a compare-at price of $120 and a suffix showing "You save $20"
{
token: "ABCD",
location: "drawer-cart",
level: "product"
line-item-key: 123456,
discounted: true,
price: 10000,
compare-at-price: 120000
compare-at-price-suffix: "You save $20"
}
  • The product with handle "my-product-handle" is discounted, its price should display as $100 in collections, with a unit price of $1.59
{
token: "ABCD",
location: "collection",
product-handle: "my-product-handle",
discounted: true,
price: 10000,
unit-price: 159
}
  • The subtotal of the cart is discounted, its price should display as $200 in the drawer cart, with a compare-at price of $250, the footer should display "You save 20%"
{
token: "ABCD",
location: "drawer-cart",
level: "total",
discounted: true,
price: 20000,
compare-at-price: 250,
footer: "You save 20%"
}

Events

la:dn:product-banner:render
  • Executes the render method.