Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created May 2, 2023 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/d854e7b795cf818a365dea031a9b4f86 to your computer and use it in GitHub Desktop.
Save Pebblo/d854e7b795cf818a365dea031a9b4f86 to your computer and use it in GitHub Desktop.
Creates a log entry when a payment method has been deactivate.
<?php // Please do not include the opening PHP tag if you already have one.
//Debug function to easily write various vars to the log.
if ( ! function_exists('tw_ee_write_log')) {
function tw_ee_write_log( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
add_action('AHEE__EEM_Payment_Method___create_objects_auto_deactivated_payment_method', 'tw_ee_log_pm_deactivate');
function tw_ee_log_pm_deactivate($payment_method) {
//Exception for stack trace
$e = new \Exception;
tw_ee_write_log(
array(
'payment_method_deactivated' => $payment_method->name(),
'stack_trace' => $e->getTraceAsString()
)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment