Hello all,
I’m new here and working on a woocommerce project that needs custom fields for each order. After searching for solution, found that ACF repeater field is the one I needed. However, I’m having trouble to get information from the ACF form to Meta table.
Can someone please help me with this? Here is the script that I added to functions.php.
function acf_product_content(){
echo ‘<h3 id=”order_review_heading”>Please enter the custom info</h3>
<div id=”order_review” class=”woocommerce-checkout-review-order”>’;
acf_form_head();
acf_form();
}
add_action( ‘woocommerce_checkout_after_customer_details’, “acf_product_content” );
function acf_update_data( $order_id ) {
$field_key = “field_5662……..”;
$value = $_POST[‘fields’][‘field_56662…….’];
update_field( $field_key, $value, $order_id);
}
add_action(‘woocommerce_checkout_update_order_meta’, ‘acf_update_data’, 10, 3);
Thank you in advance.
Hi @kiran,
Thanks for the post.
The acf_form() and the acf_form_head() functions should be called in the region of your template where you want to display the form. The acf_form_head() function is used to process the form data.
Since the repeater makes use of repeating sets of row data, you might also need to a loop to get all the data that you want to set in your meta table. The have_rows() and the_row() functions are used to step through the row data.