Support

Account

Forum Replies Created

  • For anyone else with this issue, I resolved it this way:
    I used the acf/load_value as outllined here: https://gist.github.com/theJasonJones/7061b8020e43a114756214e20c4d0ed9

    Fantastic Help!
    Instead of adding each item like they do int he tutorial, I had a global variable based on how many items I needed, then I looped through the “$value[] = array(…” creating as many repeater items as I need.
    Here’s my resultant code:

    // Sets the number of Repeater Confirm Ring Size items.
    add_filter('acf/load_value/key=field_5d366cc2c5656',  'afc_load_my_repeater_value', 10, 3);
    function afc_load_my_repeater_value($value, $post_id, $field) {
        global $ring_count;
        //Optional: Check for post_status otherwise published values will be changed.
        if ( get_post_status( $post_id ) === 'wc-processing' or get_post_status( $post_id ) === 'wc-pending') {
             //Optional: Check for post_type.
            if( get_post_type( $post_id ) == 'shop_order' ){
                if ($ring_count > 0){
                    $value	= array();
                    // Add field key for the field you would to put a default value (text field in this case)
                    for ($i = 0; $i < $ring_count; $i++) {
                        $value[] = array(
                            'field_5d366d10c5657' => '5'
                        );
                    }
                }
            }
        }
        return $value;
    }
  • As a work around, I used the Pro version to get the Repeater field. I was able to make this do what I needed it to.

  • Incidentally, this is my existing code

    acf_form(array(
       'fields' => array('field_5d366cc2c5656'),
    ));
  • Thanks a lot for the quick reply, but I want to be able to do this programatically.
    In this case, if someone has, let’s say 15 items. I want to display 15 repeater fields.
    Or 5 items, 5 repeater fields. etc.

    Thanks again.

  • I think if I word this in another ay it will be a lot more relatable.
    If a customer orders 3 rings in 1 order and they want one ring in size 5, one size 7 and, one size 10(let’s imagine that those different sizes are a custom ACF field).
    They can only enter the ring sizes choices after they’ve purchased the item.
    So the user has to go to their order page and enter the ring size separately for each product within the same order.
    Is this possible with an ACF field?

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