Discounts

This documentation refers to the properties and methods of this interface as accessed only through the "data-bind" html attribute used for interface theming. For information on how to access this interface and its properties using standard javascript code, have a look at our developer documentation.

The discounts data-bind accessor will give you access to any discount data that is associated with the app. For example, if there are any producers that are associated with the app, then any discounts that are available through those producers will have data available through this accessor. We'll run through all of its properties to see what data is available and the ways you can use it.

Note: Flex will not process your "data-bind" attributes automatically. Refer to the security implications section of our theming guide for more information on how to enable and use the "data-bind" attribute safely on your website.

Sandbox

Open SandboxWant to get hands on with the flex framework? Use any of the html examples from this guide in our sandbox!


Discounts List: discounts.list() Array

This property is an array list of any known discounts made available by the producers that are associated with the app. It can be used to build themed content around all of the discounts in the application.


discounts.list()[index] Object

Each array item is a discount object which contains the following properties about the discount.


Name: discounts.list()[index].name String

This property contains the headline name of the discount as provided by the producer. It is provided by the framework in html format.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>Discount Name: <strong data-bind="html: name"></strong></li>
</ul>

Description: discounts.list()[index].description String

This property contains the benefit description of the discount as provided by the producer. It is provided by the framework in html format.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong>
    <p data-bind="html: description"></p>
  </li>
</ul>

How It Works: discounts.list()[index].sys_description String

This property contains the system generated description of exactly how to qualify for the discount. It is provided by the framework in html format.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong>
    <div data-bind="html: sys_description"></div>
  </li>
</ul>

Producer Name: discounts.list()[index].producer String

This property contains the name of the producer who is offering the discount. It is provided by the framework in html format.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong> by
    <span data-bind="html: producer"></span>
  </li>
</ul>

Producer Banner: discounts.list()[index].producer_banner String

This property contains the url to the producer's logo banner.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>
    <img data-bind="attr: { src: producer_banner }" />
  </li>
</ul>

Limitations: discounts.list()[index].limitations String

This property contains any special limitations to the discount (such as specific licenses that it applies to).

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>
    <p data-bind="html: description"></p>
    <div data-bind="html: sys_description"></div>
    <!-- ko if: limitations -->
    Limitations: <span data-bind="html: limitations"></span>
    <!-- /ko -->
  </li>
</ul>

Cumulative: discounts.list()[index].cumulative Boolean

This property contains a boolean value (true/false) which indicates whether the discount is cumulative. When a discount is cumulative, that means that it can be combined with other cumulative discounts at the same time. Otherwise, discounts are exclusive (which means that after it's qualified, other discounts will not apply).

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>
    <!-- ko if: cumulative -->
    <strong>This discount can be combined with other discounts!</strong>
    <!-- /ko -->
  </li>
</ul>

Type: discounts.list()[index].type String

This property contains a value which indicates what type of discount this is. The possible values are:

  • 1 = The discount is for free items
  • 2 = The discount is for a percentage off
  • 3 = The discount is for a fixed amount off
Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>

    <!-- ko if: type == 1 -->
    This discount is for free items!
    <!-- /ko -->

    <!-- ko if: type == 2 -->
    This discount is for a percentage off!
    <!-- /ko -->

    <!-- ko if: type == 3 -->
    This discount is for a fixed amount off!
    <!-- /ko -->

  </li>
</ul>

Amount: discounts.list()[index].amount String

This property contains the amount of the discount. This may be a fixed cost, percentage off, or number of free items. The value it represents depends on the discount type as expressed by the type property.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>
    This discount is for:
    <!-- ko if: type == 1 -->
      <em data-bind="text: amount"></em> free items!
    <!-- /ko -->

    <!-- ko if: type == 2 -->
      <em data-bind="text: parseInt(amount * 100)"></em> percent off!
    <!-- /ko -->

    <!-- ko if: type == 3 -->
      <em data-bind="text: '$' + amount"></em> off your purchase!
    <!-- /ko -->

   </li>
</ul>

Producer ID: discounts.list()[index].uid String

This property contains the producer id for which the discount applies.

Example:
<ul data-bind="foreach: discounts.list()">
  <li>
    Discount Name: <strong data-bind="html: name"></strong><br>
    <!-- ko with: $root.producers.byId()[uid] -->
    <em data-bind="text: total_beats"></em> total beats available by this producer!
    <!-- /ko -->
   </li>
</ul>

Discount ID: discounts.list()[index].id String

This property contains the unique id assigned to the discount.


Discount Info (by ID): discounts.byId()[id] Object

This property will give you access to a specific discount object by using the discount id as a key. It is most useful to access information about a discount while inside of a different context.