Skip to content
  1. Extras
  2. msDiscount
  3. Snippets
  4. msdGetDiscount

msdGetDiscount

Snippet for outputting a product's discount and/or promotion end time.

Can be used as prepareSnippet in msProducts or standalone on a page. In the first case it adds two placeholders to the product: [[+sale_discount]] (discount amount) and [[+remains]] (seconds until promotion end). In the second it outputs a chunk with those placeholders.

Parameters

NameDefaultDescription
&idProduct ID for discount and promotion time.
&saleComma-separated promotion IDs. If empty, no promotion filter.
&tpltpl.msProduct.discountChunk for output.
&frontend_css[[+assetsUrl]]css/web/main.cssFrontend CSS.
&frontend_js[[+assetsUrl]]js/web/default.jsFrontend JS.

Examples

The snippet chooses its mode from the call parameters.

On product page:

modx
[[!msdGetDiscount]]

Elsewhere with parameters:

modx
[[!msdGetDiscount?
  &id=`15`
  &sale=`1,2,3,4,5`
]]

As prepare snippet in msProducts:

modx
<link rel="stylesheet" href="[[++assets_url]]components/msdiscount/css/web/main.css" type="text/css" />
[[!msProducts?
  &parents=`0`
  &prepareSnippet=`msdGetDiscount`
  &tpl=`@INLINE
    <div class="row ms2_product">
      <a href="{{+link}}">{{+pagetitle}}</a>
      <span class="price">{{+price}} {{%ms2_frontend_currency}}{{+remains}}</span>
    </div>
    <!--minishop2_remains -{{+sale_discount}} — <span class="msd_remains">{{+remains}}</span>-->
    <!--minishop2_!remains -{{+sale_discount}}-->
  `
]]
<script type="text/javascript" src="[[++assets_url]]components/msdiscount/js/web/default.js"></script>

This outputs all products with discount and time left (if any). For promotion-only listing use msdBuyNow.