function dgx_donate_create_donation_from_donation($old_donation_id)
{
    // Create a new donation record by cloning an old one (useful for repeating donations)
    dgx_donate_debug_log("about to create donation from old donation {$old_donation_id}");
    $new_donation_id = dgx_donate_create_empty_donation_record();
    dgx_donate_debug_log("new donation id = {$new_donation_id}");
    $meta_map = dgx_donate_get_meta_map();
    foreach ((array) $meta_map as $transient_data_key => $postmeta_key) {
        $old_donation_meta_value = get_post_meta($old_donation_id, $postmeta_key, true);
        update_post_meta($new_donation_id, $postmeta_key, $old_donation_meta_value);
    }
    dgx_donate_debug_log("done with dgx_donate_create_donation_from_donation, returning new id {$new_donation}");
    return $new_donation_id;
}
function seamless_donations_create_donation_from_donation($old_donation_id)
{
    // Create a new donation record by cloning an old one (useful for repeating donations)
    dgx_donate_debug_log("About to create donation from old donation {$old_donation_id}");
    $new_donation_id = dgx_donate_create_empty_donation_record();
    dgx_donate_debug_log("New donation id = {$new_donation_id}");
    $meta_map = dgx_donate_get_meta_map();
    foreach ((array) $meta_map as $transient_data_key => $postmeta_key) {
        $old_donation_meta_value = get_post_meta($old_donation_id, $postmeta_key, true);
        update_post_meta($new_donation_id, $postmeta_key, $old_donation_meta_value);
    }
    // Now build in the donor data
    $first = get_post_meta($old_donation_id, '_dgx_donate_donor_first_name', true);
    $last = get_post_meta($old_donation_id, '_dgx_donate_donor_last_name', true);
    // now move that data into a donor post type
    $donor_name = sanitize_text_field($first . ' ' . $last);
    $donor_slug = sanitize_title($donor_name);
    $post = get_page_by_path($donor_slug, OBJECT, 'donor');
    if ($post == NULL) {
        // create the new custom donor post
        $post_array = array('post_title' => $donor_name, 'post_content' => '', 'post_status' => 'publish', 'post_type' => 'donor');
        $post_id = wp_insert_post($post_array, true);
    } else {
        $post_id = $post->ID;
    }
    // record the donor id in the donation record
    update_post_meta($new_donation_id, '_dgx_donate_donor_id', $post_id);
    // update the donations to point to this donor id
    $donations_list = get_post_meta($post_id, '_dgx_donate_donor_donations', true);
    if ($donations_list !== false) {
        $donations_list .= ',' . $old_donation_id;
    } else {
        // this is the first donation for this donor
        $donations_list = $old_donation_id;
    }
    update_post_meta($post_id, '_dgx_donate_donor_donations', $donations_list);
    dgx_donate_debug_log("done with dgx_donate_create_donation_from_donation, returning new id {$new_donation}");
    return $new_donation_id;
}