Skip to content

Commit

Permalink
fix(admin-tool):update code to make it compatible for dry run impress…
Browse files Browse the repository at this point in the history
  • Loading branch information
raftaar1191 committed Apr 4, 2018
1 parent 3b54c17 commit 86605bd
Show file tree
Hide file tree
Showing 2 changed files with 167 additions and 152 deletions.
47 changes: 22 additions & 25 deletions includes/admin/admin-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,36 +568,33 @@ function give_donation_import_callback() {
}

// Processing done here.
$raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter );
$raw_key = maybe_unserialize( $mapto );
$raw_data = give_get_donation_data_from_csv( $csv, $start, $end, $delimiter );
$raw_key = maybe_unserialize( $mapto );
$current_key = $start;

if ( empty( $import_setting['dry_run'] ) ) {
// Prevent normal emails.
remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );
remove_action( 'give_insert_user', 'give_new_user_notification', 10 );
remove_action( 'give_insert_payment', 'give_payment_save_page_data' );

foreach ( $raw_data as $row_data ) {
$import_setting['donation_key'] = $current_key;
give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting );
$current_key ++;
}
$csv_raw_data = give_get_donation_data_from_csv( $csv, 1, $end, $delimiter );
$import_setting['csv_raw_data'] = $csv_raw_data;
}

// Check if function exists or not.
if ( function_exists( 'give_payment_save_page_data' ) ) {
add_action( 'give_insert_payment', 'give_payment_save_page_data' );
}
add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );
} else {
foreach ( $raw_data as $row_data ) {
$import_setting['donation_key'] = $current_key;
give_import_donation_dry_run( $raw_key, $row_data, $main_key, $import_setting );
$current_key ++;
}
// Prevent normal emails.
remove_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );
remove_action( 'give_insert_user', 'give_new_user_notification', 10 );
remove_action( 'give_insert_payment', 'give_payment_save_page_data' );

foreach ( $raw_data as $row_data ) {
$import_setting['donation_key'] = $current_key;
give_save_import_donation_to_db( $raw_key, $row_data, $main_key, $import_setting );
$current_key ++;
}

// Check if function exists or not.
if ( function_exists( 'give_payment_save_page_data' ) ) {
add_action( 'give_insert_payment', 'give_payment_save_page_data' );
}
add_action( 'give_insert_user', 'give_new_user_notification', 10, 2 );
add_action( 'give_complete_donation', 'give_trigger_donation_receipt', 999 );


if ( $next == false ) {
$json_data = array(
'success' => true,
Expand Down

0 comments on commit 86605bd

Please sign in to comment.