Answers.Body: <p>I haven't done this myself, but I see two ways to get the percentage:</p>
  
  <p>Take the <code>product.defaultVariant.saleAmount</code> and use maths in twig to work out the percentage - that should definitely work.  Twig math is a good general solution if you can't get the numbers you need directly from Commerce. See:</p>
  
  <p><a href="http://twig.sensiolabs.org/doc/templates.html#math" rel="nofollow">http://twig.sensiolabs.org/doc/templates.html#math</a></p>
  
  <p>However, I think you can use</p>
  
  <pre><code> {% set sales = craft.commerce.getSales() %}
  </code></pre>
  
  <p>...to get all your SalesModels.</p>
  
  <p>(see <code>/craft/plugins/commerce/models/Commerce_SaleModel.php</code>) as this model is not really documented yet it seems.</p>
  
  <p>You'd loop through those and get the particular sale you're after (e.g. by <code>id</code>).  Then, it appears there is code in there to  <code>getDiscountAmountAsPercent</code> to get what you're after....however while <code>DiscountModel</code> has an attribute of <code>percentDiscount</code> on it, SaleModel does not appear to so I don't <em>think</em> you can get at it directly in your templates currently.</p>
  
  <p>Unfortunately I am a bit pushed for time in terms of actually trying it to see.  But Twig maths will do it for sure if you get stuck with a more direct approach!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-28T00:40:42.353Z
Answers.Text: thanks a lot, i will try to figure it out tomorrow, i actually just need the value that the costumer enters to display something like a sticker on the product image to say how much % is off ..maybe there is a workaround if  the costumer just names the deal 20 for 20% and i can read out the deal name i.e.
Answers.UserDisplayName: HendrikEng
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-28T00:41:43.827Z
Answers.Text: will try to work it out and report here, thanks a lot :-)
Answers.UserDisplayName: HendrikEng
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-28T00:38:15.677Z
Answers.LastActivityDate: 2016-10-28T00:38:15.677Z
Answers.UserDisplayName: Jeremy Daalder
Answers.Body: <p>For some reason the above answers aren't working for me, so I've done it the mathematical way...</p>
  
  <p>Formula: ((newprice-oldprice)/oldprice)*100</p>
  
  <p>In craft/twig code:</p>
  
  <pre><code>{% if product.defaultVariant.onSale %}
    &lt;span class="badge"&gt;
      {% set procent = ((product.defaultVariant.salePrice-product.defaultPrice)/product.defaultPrice)*100 %}
      {{procent}}%
    &lt;/span&gt;
  {% endif %}
  </code></pre>
  
  <p>Hope it helps for those who where struggling also... :)</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-08T21:48:41.063Z
Answers.LastActivityDate: 2017-06-08T21:48:41.063Z
Answers.UserDisplayName: iDzine
Answers.Body: <p>I believe <a href="https://craftcommerce.com/docs/line-item-model#saleamount" rel="nofollow">saleAmount</a> is what you're looking for.</p>
  
  <pre><code>{% set amount = product.defaultVariant.saleAmount %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-28T00:36:23.963Z
Answers.Text: i checked the docs again, i think you are right, i figured its saleAmount or discount but i cant cant it working, i want do output the value i entered in the dashboard (i.e. 20%) i updated the code above.
Answers.UserDisplayName: HendrikEng
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-27T23:04:46.893Z
Answers.LastActivityDate: 2016-10-28T00:06:34.630Z
Answers.LastEditDate: 2016-10-28T00:06:34.630Z
Answers.UserDisplayName: Brad Bell
Body: <p>I am trying to display the Discount Value (%) of Products with the onSale Tag. What works for now is to display only the Products which are onSale. But I can't figure out which value stores the Discount Value.</p>
  
  <pre><code>{% set products = craft.commerce.products.find() %} {% for product in products %}
  &lt;li class="list-item"&gt;
      {% if product.defaultVariant.onSale == true %}
      &lt;div class="pin circle"&gt;
          &lt;h6&gt;Sale!&lt;/h6&gt;
          &lt;h6 class="percent"&gt;{{ amount.saleAmount }}/h6&gt;
          &lt;h6&gt;off&lt;/h6&gt;
      &lt;/div&gt;
      {% endif %}
  </code></pre>
  
  <p></li></p>
  
Tags: <templating><plugin-craftcommerce>
Title: How can I display the Discount Value onSale of Products
ThreadText: # How can I display the Discount Value onSale of Products
  
  (Asked by: username_0 on 2016-10-27)
  
  I am trying to display the Discount Value (%) of Products with the onSale Tag. What works for now is to display only the Products which are onSale. But I can't figure out which value stores the Discount Value.
  
  ```
  {% set products = craft.commerce.products.find() %} {% for product in products %}
  <li class="list-item">
      {% if product.defaultVariant.onSale == true %}
      <div class="pin circle">
          <h6>Sale!</h6>
          <h6 class="percent">{{ amount.saleAmount }}/h6>
          <h6>off</h6>
      </div>
      {% endif %}
  
  ```
  
  **Tags:** templating, plugin-craftcommerce
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2016-10-28. Score: 2 | Accepted answer
  
  I haven't done this myself, but I see two ways to get the percentage:
  
  Take the `product.defaultVariant.saleAmount` and use maths in twig to work out the percentage - that should definitely work. Twig math is a good general solution if you can't get the numbers you need directly from Commerce. See:
  
  <http://twig.sensiolabs.org/doc/templates.html#math>
  
  However, I think you can use
  
  ```
   {% set sales = craft.commerce.getSales() %}
  
  ```
  
  ...to get all your SalesModels.
  
  (see `/craft/plugins/commerce/models/Commerce_SaleModel.php`) as this model is not really documented yet it seems.
  
  You'd loop through those and get the particular sale you're after (e.g. by `id`). Then, it appears there is code in there to `getDiscountAmountAsPercent` to get what you're after....however while `DiscountModel` has an attribute of `percentDiscount` on it, SaleModel does not appear to so I don't *think* you can get at it directly in your templates currently.
  
  Unfortunately I am a bit pushed for time in terms of actually trying it to see. But Twig maths will do it for sure if you get stuck with a more direct approach!
  
  > **Comments:**
  > **username_0**: thanks a lot, i will try to figure it out tomorrow, i actually just need the value that the costumer enters to display something like a sticker on the product image to say how much % is off ..maybe there is a workaround if  the costumer just names the deal 20 for 20% and i can read out the deal name i.e.  
  > **username_0**: will try to work it out and report here, thanks a lot :-)  
  
  ---
  
  ### Answer by username_2 on 2017-06-08. Score: 2
  
  For some reason the above answers aren't working for me, so I've done it the mathematical way...
  
  Formula: ((newprice-oldprice)/oldprice)\*100
  
  In craft/twig code:
  
  ```
  {% if product.defaultVariant.onSale %}
    <span class="badge">
      {% set procent = ((product.defaultVariant.salePrice-product.defaultPrice)/product.defaultPrice)*100 %}
      {{procent}}%
    </span>
  {% endif %}
  
  ```
  
  Hope it helps for those who where struggling also... :)
  
  
  ---
  
  ### Answer by username_3 on 2016-10-27. Score: 1
  
  I believe [saleAmount](https://craftcommerce.com/docs/line-item-model#saleamount) is what you're looking for.
  
  ```
  {% set amount = product.defaultVariant.saleAmount %}
  
  ```
  
  > **Comments:**
  > **username_0**: i checked the docs again, i think you are right, i figured its saleAmount or discount but i cant cant it working, i want do output the value i entered in the dashboard (i.e. 20%) i updated the code above.  
  
  ---
  
  