Hi,
I am trying to create several fields that are calculated automatically using values from ACF fields. I am using ACF Pro and Elementor Pro. I also use Code Snippets plugin in order to create snippets.
Found similar question on this forum
https://support.advancedcustomfields.com/forums/topic/how-to-create-a-calculated-acf-field-saved-in-the-db/
So I have this values, that I input manually:
_price – just a woocommerce price
area – total area of the apartment in sqm
guarantee_return – number that shows the % of yearly income
return_term – for how many years buyer gets the income
Values that must be calculated automatically:
total_percent = “guarantee_return” * “return_term”
total_return = “guarantee_return” * “return_term” * “_price” / 100
Price_per_sqm = “_price” / “area”
I already created hidden ACF fields (as in link above) to save this data in DB.
My first snippet works perfectly (screenshot 1). The value shows up on the page after updating the product. But when I create second snippet (Screenshot 2), value doesn’t appear.
I am not good at coding, but I am sure that there is no problem in calculations because when I use formula from the second snippet in the first snippet it works fine. I think that is coding issue.
So now I need 3 fields to calculate, later I will need more. May be there is the way to place them all in one snippet?
Looking forward to your help.
Kind regards,
Paul