Have an idea?

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

How to conditionally display acbc summed price and overt discount

Hi Guys,

I am hoping to use an overt discount mechanism (post BYO) in an ACBC study - as an example I want a final price attribute to show

£<discounted summed price> per month for 12 months then £<summed price>

So I hope to be able to have a discount variable (-£5/-£10/-£20) that can reference the summed price as part of that.

Is this possible?

Cheers,

Dean
asked Oct 16, 2019 by djtindall Bronze (600 points)
So respondents ultimately see two price-related attributes in the ACBC?  The first row being the discount, and the second row showing the summed price as well as the summed price minus the discount?
I'd be happier to hide the discount and just show the two-pronged discounted/summed price attribute instead.

As a bit of background, this is how media companies legally have to advertise new customer offers
Another option here is (which might be the easiest) is if I have some set discounts (negative summed price attributes) which all combine into a single discount feature - and then I get to show the summed price both with and without the discounted total?

1 Answer

0 votes
I would start by creating a list of discounts.  Each item's display text should look something like this:

<input type="hidden" class="discount" value="5"/>


With "5" being replaced with "10," "20," or any other discount price.  (You can optionally add internal labels to each item so you don't end up with all this HTML in analysis.)

In your list of attributes, add this HTML to the attribute that represents summed price:

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


(Again, I would recommend adding an internal label.)

Now you can create your ACBC exercise using these lists.  You'll want to keep the discount attribute from showing up in BYOs, Must Haves, or Unacceptables as respondents won't actually be seeing this attribute.

Finally, add this script to your screener and choice questions:

<script>
$(document).ready(function(){
    // Hide discounts
    $('.discount').closest('tr').hide();
    
    // Update summed price
    $('#summed').closest('tr').find('.level_text').each(function(){
        var summedPrice = Number($(this).text().replace(/[^0-9.]/g, ''));
        var discount = Number($('td:nth-child(' + ($(this).closest('td').index() + 1) + ') .discount').val());
        $(this).text('£' + (summedPrice - discount) + ' per month for 12 months then £' + summedPrice);
    });
})
</script>
answered Oct 16, 2019 by Zachary Platinum Sawtooth Software, Inc. (147,000 points)
So multiple attributes have levels with the "discount" class?
or any class really, but yes.

I have sort of flipped it so I have the base price hard coded and will then compare it to the varied summedprice

I would like to show the sum of a class rather than (summedprice - discount)
Replace line 9 of my JavaScript with this:

var discount = 0;
$('td:nth-child(' + ($(this).closest('td').index() + 1) + ') .discount').each(function(){
    discount += Number($(this).val());
});


Now you can use "summedPrice + discount" to write the total.
Excellent, works exactly as I needed!
Show price before discount
...