Hello @hippow
If you have a field that calculates the total price (for example, the fieldname1), and you want to display the user 1/4 of this price, you should insert a second calculated field with the equation:
PREC(fiedlname1/4, 2)
The PREC operation rounds the first parameter with the decimal places entered in the second parameter.
Best regards.
Thread Starter
T9S
(@hippow)
Hello @codepeople,
Thanks for your quick answer !
I don’t have a field which calculates the total price.
It is just the product price with <span class=”woocommerce-Price-amount amount”>
Is it then just possible to divide this span class with this plugin ?
Thanks a lot !
Hello @hippow
There are two alternatives:
* If you are using the “CFF – WooCommerce” add-on to integrate the form into the WooCommerce product, the add-on creates the woocommerce_cpcff_product_price variable with the current product’s price. So, the equation to enter into the calculated field would be:
PREC(woocommerce_cpcff_product_price/4, 2)
https://cff.dwbooster.com/blog/2018/11/26/woocommerce
* If you prefer to read the data from the span tag directly, the process would be more complex. You should access the information using jQuery (or javascript) and process it to get the number removing the currency symbols and replacing the comma with dot as a decimal separator:
(function(){
var price = jQuery('.woocommerce-variation-price .woocommerce-Price-amount.amount:eq(0)').text().replace(/€/g,'').replace(/\,/g, '.')*1;
return PREC(price/4, 2);
})()
Best regards.