Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Show price before discount

Is the folllowing possible?

I want to add an attribute: "10% Discount" in a ACBC design with levels :
 
1=No
2=Yes
 
Instead of just labeling as above I  would like to explain what it means:
Assume the shown product has a shown summed price of 1000.-
 
the levels then should be
 
1= -
2= Normal price: 1111.-
     Discount         :   111.-
 
It is just the other way round...instead of deducting something of summed price  (which would make my revenue simulations very hard)....I just want to show what the reduction means and sum it  "up"
 
For this I would have to be able to get the value of the summed price per product and show it in the label – plus 10% of it….

any ideas?
asked Feb 17 by steve

1 Answer

0 votes
Like before, add this HTML to the label of your summed price attribute:

<input type="hidden" id="summed"/>


And set the "Yes" label of your discount level to this:

<span class="discount"></span>


Then add this script to your Screener, Choice, and/or Calibration tasks:

<script>
$(document).ready(function(){
    // Settings
    var originalDecimalSeparator = '.';

    // Run
    var summedPriceTr = $('#summed').closest('tr');
    $('.discount').each(function(){
        var summedPriceTd = $(summedPriceTr).children().eq($(this).closest('td').index());
        var summedPrice = Number($(summedPriceTd).text().split(originalDecimalSeparator).map(function(x) { return x.replace(/[^0-9]/g, ''); }).join('.'));
        var discount = summedPrice / 9;
        var newSummedPrice = summedPrice + discount;
        $(this).html('Normal price: ' + newSummedPrice.toFixed(2) + '<br/>' + 'Discount: ' + discount.toFixed(2));
    });
})
</script>


Line 4 must be updated if the summed price has decimals and its decimal separator is not the period character.

Line 13 could be altered to handle thousand separators, currency symbols, etc. if needed.
answered Feb 17 by Zachary Platinum Sawtooth Software, Inc. (147,000 points)
Great ! Thank you
...