Calculated fields for ACF

Calculated fields for ACF

Wordpress plugin

Install on Wordpress

App Details

Adds a formula fields ot Advanced Custom Fields that allows you to perform simple math based on field values. Calculations are updated dynamically via ajax while editing a post on the backend post editor as well as on front end forms.

Requirements

Calculated fields requires Advanced Custom Fields 5.0 or later and works with Pro as well as the standard version.

Frontend forms

Beginning in version 1.2.3, Calculated fields for ACF supports frontend forms created using the acf_form() function (built in to Advanced Custom Fields).

Formulas

Calculated fields adds a new setting “Formula” to the the ACF field editor. Formulas supports referring to other fields in the same Field group using the field name. If a formula is added to a sub field inside a repeater field, the name refers to another sub field in the same repeater.

A sub field inside a repeater field can also refer to a parent field using the “parent.”” prefix.

A formula can contain the basic mathematical operations: plus (+), minus (-), multiply (*), division (/) and power of (^). Formulas can also contains functions like sin, cos, arcsin, log, ln, sqrt, abs. Parentheses are supported.

If an expression can’t be evaluated due to invalid syntax or referring to undefined field names, it will silently return zero.

Examples of valid expressions (note, no equal sign at the beginning):

  • fieldA * 2
  • fieldA * fieldB
  • abs(fieldA) * (2 + sqrt(fieldB))
  • amount * parent.price

Conditional operators

An expression can also contain a conditional expression that will return either 0 or 1. The supported operators are:

  • Equals (==) – Returns 1 when two values are equal, 0 otherwise
  • Not equals (!=) – Returns 1 when two values are not equal, 0 otherwise
  • Greater than (>) – Returns 1 when the first operand is greater than the second, 0 otherwise
  • Greater than or equal (>=) – Returns 1 when the first operand is greater than or equal to the second, 0 otherwise
  • Less than (<) – Returns 1 when the first operand is less than the second, 0 otherwise
  • Less than or equal (<=) – Returns 1 when the first operand is less than or equal to the second, 0 otherwise

Examples of valid expressions using conditional operators:

  • 10 == 10 (returns 1)
  • 10 == 2 (returns 0)
  • 10 > 2 (returns 1)
  • 10 < 2 (returns 0)
  • 10 <= 10 (returns 1)

Rounding functions

Round a decimal value to the nearest integer. Supported functions are:

  • round() – Uses standard mathematical rounding rules to round to nearest integer
  • ceil() – Rounds the value to the next higher integer
  • floor() – Rounds the value to the next lower integer

Examples of valid expressions using rounding functions:

  • round(10.2) (returns 10)
  • round(10.9) (returns 11)
  • round(10.888888 * 10) / 10 (returns 10.9)
  • ceil(10.2) (returns 11)
  • floor(10.2) (returns 10)

Note that the round() function only takes one parameter and always round to an integer. If you need to round to a higher precision, multiply and divide as shown in third example above.

Group fields (new from 1.2.4)

Fields defined as part of a group, subfields, can be addressed using the group name as a prefix. Inside the group, a field defined on the parent level can be addressed using the “parent” prefix. See examples below:

Valid formula to use the value of field “foobar” defined inside the group “group2”:
* group2.foobar + 10

Valid formula in a field inside a group (assuming the parent has a field named count):
* parent.count * 22

Array functions for repeater fields

If repeater fields are used, a calculated field in the parent field group can summarize a specific repeater sub fields using the aggregation functions sum, count, average, min or max. For example, the expression: “Sum(orderlines.amount)”” will return the sum of all the “amount” fields in the repeater field “orderlines”.

The available array functions are:

  • sum()
  • average()
  • count()
  • min()
  • max()

Note that anything after the dot (.) in the aggregate expression is an expression in itself. It’s perfectly OK to write a formula like: “Sum(orderlines.price * amount)”. This expression will walk over all lines in the “orderlines” repeater field, perform the calculation “price * amount” and return the sum of all lines.

Note that when working with aggregate functions, parentheses can not be used. If you need to aggregate a more complex calculation, you should add an extra field in the repeater group and let the aggregate function work on this extra field.

Data type and calculation order

Calculated fields works with the assumption that all fields are defined as numeric in the ACF editor. Using a text field in a formula WILL PRODUCE UNPREDICTABLE RESULTS.

Calculations are made as the custom field is stored to the database. To minimize the impact of performance, Calculated fields rely on field order. A formula field can only refer to fields ordered BEFORE itself. A formula field that refers to a field ordered after it WILL PRODUCE UNPREDICTABLE RESULTS.

Pricing

Starting from $0 per month.

Check Out the Pinterest Feed Widget

By Common Ninja

Pinterest FeedTry For Free!

App Info

Rating

Reviewers

13 reviews

Tags

acf
admin

Developed By

wundermatics

Quick & Easy

Find the Best Wordpress plugins for you

Common Ninja has a large selection of powerful Wordpress plugins that are easy to use, fully customizable, mobile-friendly and rich with features — so be sure to check them out!

Testimonial

Testimonial plugins for Wordpress

Galleries

Galleries plugins for Wordpress

SEO

SEO plugins for Wordpress

Contact Form

Contact Form plugins for Wordpress

Forms

Forms plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Sliders

Sliders plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Comments

Comments plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Maps

Maps plugins for Wordpress

Security

Security plugins for Wordpress

Translation

Translation plugins for Wordpress

Ads

Ads plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Music Player

Music Player plugins for Wordpress

Backup

Backup plugins for Wordpress

Privacy

Privacy plugins for Wordpress

Optimize

Optimize plugins for Wordpress

Chat

Chat plugins for Wordpress

Countdown

Countdown plugins for Wordpress

Email Marketing

Email Marketing plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Membership

Membership plugins for Wordpress

popup

popup plugins for Wordpress

SiteMap

SiteMap plugins for Wordpress

Payment

Payment plugins for Wordpress

Coming Soon

Coming Soon plugins for Wordpress

Ecommerce

Ecommerce plugins for Wordpress

Customer Support

Customer Support plugins for Wordpress

Inventory

Inventory plugins for Wordpress

Video Player

Video Player plugins for Wordpress

Testimonials

Testimonials plugins for Wordpress

Tabs

Tabs plugins for Wordpress

Social Sharing

Social Sharing plugins for Wordpress

Social Feeds

Social Feeds plugins for Wordpress

Slider

Slider plugins for Wordpress

Reviews

Reviews plugins for Wordpress

Portfolio

Portfolio plugins for Wordpress

Membership

Membership plugins for Wordpress

Forms

Forms plugins for Wordpress

Events Calendar

Events Calendar plugins for Wordpress

Contact

Contact plugins for Wordpress

Comments

Comments plugins for Wordpress

Analytics

Analytics plugins for Wordpress

Common Ninja Apps

Some of the best Common Ninja plugins for Wordpress

Browse our extensive collection of compatible plugins, and easily embed them on any website, blog, online store, e-commerce platform, or site builder.

Pinterest Feed for Wordpress logo

Pinterest Feed

Show Pinterest content in a Pinterest feed that keeps your page visually engaging, highlights new ideas, and helps visitors explore fresh inspiration.

LinkedIn Feed Slider for Wordpress logo

LinkedIn Feed Slider

Show LinkedIn posts with a slider that auto updates, presents content in a smooth layout, and keeps visitors engaged.

Count-Up Clock for Wordpress logo

Count-Up Clock

Track time since important events with a count up clock that displays elapsed days and hours and keeps visitors engaged.

PayPal Button for Wordpress logo

PayPal Button

Offer customers a trusted way to pay using PayPal through a PayPal Button that reduces checkout friction and supports higher sales.

Highlighted Headlines for Wordpress logo

Highlighted Headlines

Enhance titles with highlighted headlines that use custom colors, animations, and styles to draw attention and help visitors notice key messages.

YouTube Feed for Wordpress logo

YouTube Feed

Show YouTube videos in a customizable YouTube feed that keeps content fresh, boosts watch time, and helps visitors explore more of your channel.

Flip Card Builder for Wordpress logo

Flip Card Builder

Add interactive two-sided cards with flip effects to present front and back content in a compact, engaging format.

PDF Viewer for Wordpress logo

PDF Viewer

Add a PDF viewer to your site to display documents, share product information, and give visitors easy access to helpful content in one place.

Accessibility for Wordpress logo

Accessibility

Make Your Website More Inclusive and Accessible

Stop Motion Player for Wordpress logo

Stop Motion Player

Create engaging stop motion displays with a stop motion player that turns image sequences into interactive animations to boost creativity and visitor engagement.

Yelp Reviews for Wordpress logo

Yelp Reviews

Show Yelp reviews to build trust, strengthen credibility, and help visitors make confident decisions that support higher sales.

Countdown for Wordpress logo

Countdown

Add a countdown timer to your site to highlight upcoming events or launches and encourage timely user action.

Discover Apps By Platform

Discover the best apps for your website

WordPress
Wix
Shopify
Weebly
Webflow
Joomla
PrestaShop
Shift4Shop
WebsiteX5
MODX
Opencart
NopCommerce

Common Ninja Search Engine

The Common Ninja Search Engine platform helps website builders find the best site widgets, apps, plugins, tools, add-ons, and extensions! Compatible with all major website building platforms - big or small - and updated regularly, our Search Engine tool provides you with the business tools your site needs!

Multiple platforms