Support » Plugin: Calculated Fields Form » simple discount formula and exemption

• Resolved dirtmcgirt

(@dirtmcgirt)

Hello,
I have been at this for days:(
I have 3 fields:
fieldname10 = 35
fieldname9 = 65

fieldname8 has 7 checkboxes,
check any 1 box and value = 65,
2 checkboxes = 125
3 checkboxes = 180 etc.
So there is a discount for the more boxes checked in this field only.
The following formula works to accomplish this, but checking fieldname9 and 10 will only show up in the total IF i have already checked at lest one box in fieldname8. In other words, if someone wants to only check fieldname9 and nothing else, there is no returned value in the totals box. i need fieldname9 and 10 to be independent of the formula but added to the total when checked.

my formula:

(function(){
var v;
switch(fieldname8){
case 65:
v = 65;
break;
case 130:
v = 125;
break;
case 195:
v = 180;
break;
case 260:
v = 230;
break;
case 325:
v = 265;
break;
case 390:
v = 310;
break;
case 455:
v = 340;
break;
}
return v + fieldname9 + fieldname10;
})();

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

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

(@codepeople)

Hi,

In this case you only should define an initial value for the varaible “v”, like follow:

(function(){
var v = 0;
switch(fieldname8){
case 65:
v = 65;
break;
case 130:
v = 125;
break;
case 195:
v = 180;
break;
case 260:
v = 230;
break;
case 325:
v = 265;
break;
case 390:
v = 310;
break;
case 455:
v = 340;
break;
}
return v + fieldname9 + fieldname10;
})();

Best regards.

Viewing 1 replies (of 1 total)
• The topic ‘simple discount formula and exemption’ is closed to new replies.