Support » Plugin: Calculated Fields Form » How to Return different values based on quantity for different selections?

• Resolved Willuknight

(@willuknight)

I want to build a form that returns a price based on quantity for different products.

ie. I have cards and Stickers.

If you have 20 stickers, price is this
or if you have 50 business cards, price is this.

(fieldname1 = producttype, fieldname2 = quantity)
My understanding of the formula is that in the calculated results field I would enter something like:

(function(){
if(fieldname1 = stickers),(fieldname2 = < 75) return 35;
if(fieldname1 = stickers),(fieldname2 = < 150) return 50;
if(fieldname1 = stickers),(fieldname2 = < 200) return 70;
if(fieldname1 = cards),(fieldname2 = < 20) return 35;
if(fieldname1 = stickers),(fieldname2 = < 90) return 72;
})();

(i know the syntax is wrong) but that seems like a very very long way of doing it, especially when I have 5 different products and 6 different price brackets.

I just wanted to make sure that I was on the right track?

http://wordpress.org/plugins/calculated-fields-form/

Viewing 1 replies (of 1 total)
• Plugin Author codepeople

(@codepeople)

Hi,

Yes, you are in the right direction but the syntax of your code is wrong, the correct is:

(function(){
if(fieldname1 == ‘stickers’ && fieldname2 <= 75) return 35;
if(fieldname1 == ‘stickers’ && fieldname2 <= 150) return 50;
if(fieldname1 == ‘stickers’ && fieldname2 <= 200) return 70;
if(fieldname1 == ‘cards’ && fieldname2 <= 20) return 35;
if(fieldname1 == ‘cards’ && fieldname2 <= 90) return 72;
})();

Viewing 1 replies (of 1 total)
• The topic ‘How to Return different values based on quantity for different selections?’ is closed to new replies.