• 5 Subscribers
  • 114 Views
0

On one page I have an products collection Field Group which has a repeat which has the following subfields:

 Product (returns a custom post object ID)
 sku_selection (Select field that I'd like to populate with fields from a repeater on the post specified in the Product field.

On the Product post type, I have a skus repeater field which has the following subfields

SKU_ID
shadename

I would like to populate the SKUS select field with the shadename/SKU_ID fields from the post specified in the Product Post Object field.

So far I have:

function load_product_skus($field) {
    $postID = get_field('product');

    $field['choices'] = array();

    if (have_rows('skus', $postID)) {
        while ( have_rows('skus', $postID )) {
            the_row();

            $value = get_sub_field('SKU_ID');
            $label = get_sub_field('shadename');

            $field['choices'][$value] = $label;
        }
    }

    return $field;
}

add_filter('acf/load_field/name=sku_selection', 'load_product_skus');

But the skus_selection field is coming back empty, and I'm guessing because I'm having trouble specifying the post ID I'd like to retrieve the fields from. Suggestions?


0 answers in total

Answer this questsion