Support

Account

Home Forums Add-ons Repeater Field Add field values based on true/false selector

Solving

Add field values based on true/false selector

  • I am using ACF repeater fields to detail square footage of a number of stores in a number of different outlet properties.

    Here’s my field setup:
    Space (text, space)
    Square Footage (number, square_footage)
    Key Tenant (text, key_tenant)
    Available (true/false, available)

    And again as an example:
    Space – Square Footage – Key Tenant – Available
    0001 – 2,309 – Kroger – False
    0002 – 2,009 – Belk – False
    0003 – 2,000 – AVAILABLE – True
    0004 – 1,500 – AVAILABLE – True
    0005 – 2,000 – Ross – False

    What I need to figure out is how to sum the square footage of available properties and display on the front end. So for the example above, Space 0003 + Space 0004 = square footage available (maybe available_square_footage).

    How do I set the AVAILABLE fields to calculate? I need something to say IF true, THEN add square_footage and output to a new field (maybe available_square_footage).

  • this is just a general idea, I can’t give a specific example because information about the fields your using is incomplete.

    
    $total_footage = 0;
    if (have_rows('repeater')) {
      while (have_rows('repeater')) {
        the_row();
        if (get_sub_field('available')) {
          $total_footage += get_sub_field('square_footage');
        }
      }
    }
    echo $total_footage;
    
  • Thank you John. When using ACF with Elementor, where do I enter the above code?

  • I don’t know anything about elementor, can’t answer that question for you.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.