• Resolved deterius

    (@deterius)


    Hello Calculated fields for ACF people!

    I’m having a few issues, but it might stem from me not knowing how to use this plugin properly. It might be just me, but a quick tutorial example on how to properly setup the fields and few example from start to finish might be useful. (Looking a the official screen shots I notice some calculation field types are text, can I use number, should I use text? etc..)

    Anyway, I’m getting an error, my steps:
    1. I set up a new field group type Group
    2. It contains three fields
    3. (name: field1 type:number)(name: field2 type:number)(name:sumField type:number formula: field1 * field2, Read Only)
    4. Create new post, I add a number in field1 and field2, sumField remains unchange.
    5. I click Publish and get error:
    Warning: Invalid argument supplied for foreach() in /homepages/1/d224002048/htdocs/clickandbuilds/Lead/wp-content/plugins/calculated-fields-for-acf/src/Evaluator.php on line 98

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author wundermatics

    (@wundermatics)

    Hi,

    Thanks for trying out our plugin.

    This looks like the code is identifying your fields to be part of a repeater field. But from your description, that doesn’t appear to be the case. Correct?

    The first thing I’d like to know to be able to help you is to know what versions that are in use. Could you please let me know the version of:

    – PHP on the server
    – WordPress core
    – Advanced custom fields (also if it’s the free of pro version)

    I’d also like to have a look at the field configuration of this field group. Could you do an export of all field groups on your site (I’d like to look for potential naming collisions). Use the export tool provided by ACF and either paste the content here or email it to us at [email protected]

    Thread Starter deterius

    (@deterius)

    Thanks for the quick reply!

    Yes, since I am using the free version, I do not have access to the repeater field, but using group instead.

    Okay, the versions:
    – PHP 7.3
    – Worpdress 5.3.2
    – ACF (free version)

    ACF field groups

    [
        {
            "key": "group_5e15a2d3ca750",
            "title": "Generic Secret Shop",
            "fields": [
                {
                    "key": "field_5e15b0367c131",
                    "label": "Visit Date",
                    "name": "visit_date",
                    "type": "date_picker",
                    "instructions": "",
                    "required": 1,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "display_format": "d\/m\/Y",
                    "return_format": "d\/m\/Y",
                    "first_day": 1
                },
                {
                    "key": "field_5e15aca1f11cc",
                    "label": "Shopper Info",
                    "name": "shopper_info",
                    "type": "relationship",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "post_type": [
                        "shopper"
                    ],
                    "taxonomy": "",
                    "filters": [
                        "search",
                        "post_type",
                        "taxonomy"
                    ],
                    "elements": "",
                    "min": 1,
                    "max": 1,
                    "return_format": "object"
                },
                {
                    "key": "field_5e15a2e089295",
                    "label": "Generic Questions",
                    "name": "genericquestion",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "layout": "row",
                    "sub_fields": [
                        {
                            "key": "field_5e15a58089296",
                            "label": "Were you greeted in 30 seconds?",
                            "name": "Were_you_greeted_in_30_seconds?",
                            "type": "true_false",
                            "instructions": "Where you greeted in 30 seconds?",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e15a5ae89297",
                            "label": "Did the sales staff "break the ice" by first engaging you in any non-product conversation before referring to product sales or pricing?",
                            "name": "Did_the_staff_break_the_ice?",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e15a5c789298",
                            "label": "Did the staff compliment you?",
                            "name": "Did_the_staff_compliment_you?",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e17d6de84a9d",
                            "label": "Shopping Reason",
                            "name": "Did_the_staff_ask_you_who_and_why_you_are_shopping?",
                            "type": "true_false",
                            "instructions": "Did the staff ask you who and why you are shopping?",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6b7382d88",
                            "label": "Was staff able to answer basic questions about the product such as price material etc.",
                            "name": "was_staff_able_to_answer_basic_questions_about_the_product_such_as_price_material_etc",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6b8082d89",
                            "label": "Did staff explain to you what the features, advantages, and benefits of the product are you are interested in",
                            "name": "did_staff_explain_to_you_what_the_features_advantages_and_benefits_of_the_product_are_you_are_interested_in",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6ba382d8a",
                            "label": "Did service staff explain why this product is suitable for you your life style or why it matches or compliments their other products or preferences",
                            "name": "did_service_staff_explain_why_this_product_is_suitable_for_you_your_life_style_or_why_it_matches_or_compliments_their_other_products_or_preferences",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6bd182d8b",
                            "label": "Did staff recommend any second or third other product to purchase or try out...",
                            "name": "did_staff_recommend_any_second_or_third_other_product_to_purchase_or_try_out",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6bee82d8c",
                            "label": "Did staff thank you for shopping with their company and welcome you to return again?",
                            "name": "did_staff_thank_you_for_shopping_with_their_company_and_welcome_you_to_return_again",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        },
                        {
                            "key": "field_5e4a6c4382d8d",
                            "label": "Did staff share any information with you about the company, brand, story or history?",
                            "name": "did_staff_share_any_information_with_you_about_the_company_brand_story_or_history",
                            "type": "true_false",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "message": "",
                            "default_value": 0,
                            "ui": 0,
                            "ui_on_text": "",
                            "ui_off_text": ""
                        }
                    ]
                },
                {
                    "key": "field_5e40f0bbee815",
                    "label": "Secret Shop Score",
                    "name": "secret_shop_score",
                    "type": "number",
                    "instructions": "Divide the number of true \/ false",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "default_value": "",
                    "placeholder": "",
                    "prepend": "",
                    "append": "",
                    "min": "",
                    "max": "",
                    "step": ""
                },
                {
                    "key": "field_5e1aac657e72a",
                    "label": "Client Details",
                    "name": "client_details",
                    "type": "relationship",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "post_type": [
                        "client_details"
                    ],
                    "taxonomy": "",
                    "filters": [
                        "search",
                        "post_type",
                        "taxonomy"
                    ],
                    "elements": "",
                    "min": "",
                    "max": "",
                    "return_format": "object"
                },
                {
                    "key": "field_5e41077535b6a",
                    "label": "Open ended questions",
                    "name": "open_ended_questions",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "show_in_graphql": 1,
                    "layout": "block",
                    "sub_fields": [
                        {
                            "key": "field_5e41078b35b6b",
                            "label": "Body language assessment",
                            "name": "body_language_assessment",
                            "type": "textarea",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "maxlength": "",
                            "rows": "",
                            "new_lines": ""
                        },
                        {
                            "key": "field_5e4a6dbf79236",
                            "label": "Tone of voice assessments",
                            "name": "tone_of_voice_assessments",
                            "type": "textarea",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "maxlength": "",
                            "rows": "",
                            "new_lines": ""
                        },
                        {
                            "key": "field_5e4a6dd879237",
                            "label": "Urgency assessment",
                            "name": "urgency_assessment",
                            "type": "textarea",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "maxlength": "",
                            "rows": "",
                            "new_lines": ""
                        },
                        {
                            "key": "field_5e4a6de979238",
                            "label": "Conversation Notes",
                            "name": "conversation_notes",
                            "type": "textarea",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "maxlength": "",
                            "rows": "",
                            "new_lines": ""
                        }
                    ]
                },
                {
                    "key": "field_5e4a8a54d9054",
                    "label": "SimpleCalc",
                    "name": "SimpleCalc",
                    "type": "group",
                    "instructions": "",
                    "required": 0,
                    "conditional_logic": 0,
                    "wrapper": {
                        "width": "",
                        "class": "",
                        "id": ""
                    },
                    "formula": "",
                    "readonly": 0,
                    "show_in_graphql": 1,
                    "layout": "row",
                    "sub_fields": [
                        {
                            "key": "field_5e4a8a64d9055",
                            "label": "field1",
                            "name": "field1",
                            "type": "number",
                            "instructions": "put a numba",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 0,
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e4a8ab2d9056",
                            "label": "field2",
                            "name": "field2",
                            "type": "number",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "",
                            "readonly": 0,
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "min": "",
                            "max": "",
                            "step": ""
                        },
                        {
                            "key": "field_5e4a8ac5d9057",
                            "label": "sumField",
                            "name": "sumField",
                            "type": "text",
                            "instructions": "",
                            "required": 0,
                            "conditional_logic": 0,
                            "wrapper": {
                                "width": "",
                                "class": "",
                                "id": ""
                            },
                            "formula": "field1 * field2",
                            "readonly": 1,
                            "show_in_graphql": 1,
                            "default_value": "",
                            "placeholder": "",
                            "prepend": "",
                            "append": "",
                            "maxlength": ""
                        }
                    ]
                }
            ],
            "location": [
                [
                    {
                        "param": "post_type",
                        "operator": "==",
                        "value": "generic_secret_shops"
                    }
                ]
            ],
            "menu_order": 0,
            "position": "acf_after_title",
            "style": "default",
            "label_placement": "top",
            "instruction_placement": "label",
            "hide_on_screen": [
                "permalink",
                "the_content",
                "excerpt",
                "discussion",
                "comments",
                "revisions",
                "format",
                "featured_image",
                "tags",
                "send-trackbacks"
            ],
            "active": true,
            "description": "",
            "show_in_graphql": 1,
            "graphql_field_name": "generic_secret_shop"
        }
    ]
    Plugin Author wundermatics

    (@wundermatics)

    Hi,

    Thank for the field group definition. We’re looking at this and will try to get back with a solution within a few days.

    Plugin Author wundermatics

    (@wundermatics)

    Hi again @deterius,

    We’ve just release version 1.2.4 of this plugin. In this version, we’ve fixed a couple of bugs that was related to dealing with fields inside a group. We think that your use case as you’ve described it should now work as expected.

    Please note that when you are writing a formula _INSIDE_ of a ACF group, you refer to other fields using their names, pretty much as you’d expect. If you want to use the value of a group field _OUTSIDE_ of the group (at the parent level) you need to prefix the field name with the name of the group. Examples:

    At the parent level, you can refer to a field inside “group2” like this:
    * group2.foobar + 10

    Inside the group, you can get values from the “parent” level like this:
    * parent.count * 22

    Please let us know if this new version doesn’t fix your problem.

    Thread Starter deterius

    (@deterius)

    Yes, That fixed the problem! Thanks.

    Thanks for the hard work!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Am I doing this right?’ is closed to new replies.