In woocommerce, I am trying to get the data from a multidimensional array from an Advanced custom field (ACF) to populate woocommerce_form_field() select field options.
If I print_r the data from:
$pickup = get_field_object('pick_up', 'pick_up_list')['value'];
I have this:
Array
(
[0] => Array
(
[name] => Hotel Cla
[price] => 0
)
[1] => Array
(
[name] => Ritz Carlon
[price] => 7
)
)
Then I'm getting the error Array to string conversion in when using this array in:
woocommerce_form_field( 'pick_up_list', array(
'type' => 'select',
'class' => array('form-row-wide'),
'label' => __('Pick Up'),
'options' => $pickup
));
What I want is to be able to add the $pickup array as select field. Any help?
get_field()which returnsarrayinstead ofget_field_object()and retyping that. advancedcustomfields.com/resources/get_field. Is it what you're looking for?