Copy link to clipboard
Copied
Hello my friends,
I've a problem which I am hoping will be solved with your help:)
I made a pdf form with calculating net and gross price where customer can type how many of products wants to buy and it works all fine (attachment).
The problem is when I want to make a discount (for example 10%) of total price if customer order 2 or more products and I'm stuck. Do you have any ideas how I can make it happen? I can write JavaScript code but I dont know how to implement it into pdf.
Is it possible to use the total net price as a variable?
Any ideas will be very valuable, cheers!
Copy link to clipboard
Copied
Hello my friends,
I've a problem which I am hoping will be solved with your help:)
I made a pdf form with calculating net and gross price where customer can type how many of products wants to buy and it works all fine (attachment).
The problem is when I want to make a discount (for example 10%) of total price if customer order 2 or more products and I'm stuck. Do you have any ideas how I can make it happen? I can write JavaScript code but I dont know how to implement it into pdf.
Is it possible to use the total net price as a variable?
Any ideas will be very valuable, cheers!
Copy link to clipboard
Copied
Calculate the net price with Javascript code and substract the discount when 2 or more products are ordered.
Copy link to clipboard
Copied
Why do you need JavaScript code when this can be done very easily with Simplified Field Notation, and the same question has been answer before in the forums up to 4 times in the past two weeks.
Copy link to clipboard
Copied
Price value is at 100%, but at 90% if 2 or more quantity. I don’t think this can be done with Simplified Field Notation.
Copy link to clipboard
Copied
How does you count the ordered products with Simplified Field Notation?
Copy link to clipboard
Copied
@Anna5D2F for all indivual total price add this line in a custom calculation script. Make sure you change the field name for each.
var qp_price = getField("kwota_val").value;
var qp_prod = getField("ilosc_val").value; if (qp_prod > "1") qp_price = qp_price * 0.9;
event.value = qp_price * qp_prod
Copy link to clipboard
Copied
This will not when 2 different products are odered.
Copy link to clipboard
Copied
Indeed, only when the same products is ordered 2 or more time.
So we need to calculate the sum of all quantity, than act on the results.
Copy link to clipboard
Copied
She can add a hidden field, than SUM the quantities, than eveluate that resuts for the price.
Copy link to clipboard
Copied
If you need this for 2 or more differents products, create an hidden field [I call mine "ilosc_total" ] that will sum all of the quantities fields. Than for all sub-total line use this in a custom calculation script:
var q_total = getField("ilosc_total").value;;
var q_price1 = getField("kwota_val").value;
var q_1 = getField("ilosc_val").value;
if (q_total > "1") q_price1 = q_price1 * 0.9;
event.value = q_1 * q_price1;
Copy link to clipboard
Copied
You have to drop the quotes around "1" for it to work...
Copy link to clipboard
Copied
Whatever you do, you will need to fix the Calculation order...
Copy link to clipboard
Copied
Use this code as "Custom Calculation Script" of "suma_brutto" field:
var sumanetto = Number(this.getField("suma_netto").value);
var iloscval = Number(this.getField("ilosc_val").value);
var ilosclol = Number(this.getField("ilosc_lol").value);
var ilosccsgo = Number(this.getField("ilosc_csgo").value);
var iloscfifa = Number(this.getField("ilosc_fifa").value);
var iloscf1 = Number(this.getField("ilosc_f1").value);
var iloscclash = Number(this.getField("ilosc_clash").value);
var x = iloscval+ilosclol+ilosccsgo+iloscfifa+iloscf1+iloscclash;
var y = sumanetto*1.23;
if(x > 1){
event.value = y*.9;
}
else event.value = y;