Support

Account

Home Forums Add-ons Repeater Field Adding new row of repeater in PHP Reply To: Adding new row of repeater in PHP

  • This is my test code I am using at the moment

    add_action('save_post_product', 'rl_acf_test', 999);
    function rl_acf_test($post_id) {
        // Avoid infinite loop when using update_field()
        remove_action('save_post_product', __FUNCTION__);
    
        // Check if stock is managed
        $product = wc_get_product($post_id);
        if (!$product ) {
            return;
        }
    
        // Update the repeater
                $rows = [[
                        'event_date' => "30062025",
                        'shipping_date' => "30062025",
                        'return_send_date' => "30062025",
                        'return_arrival_date' => "30062025",
                ]];
        //$status = update_field($repeater_name, $new_rows, $post_id);
        //$status = update_field($acfFieldObject['key'], $rows, $post_id);
        $status = update_field('rental_info', $rows, $post_id);
        error_log("Status is: " . var_export($status,true));
        $product->save();
    }