There are four emails that can be potentially triggered when Stripe modal form is sent, these four emails subject and content can be filtered.

Here is the list of filters for the subject :

  • direct_stripe_success_user_email_subject
  • direct_stripe_success_admin_email_subject
  • direct_stripe_error_user_email_subject
  • direct_stripe_error_admin_email_subject

Here is the list of filters for the content :

  • direct_stripe_success_user_email_content
  • direct_stripe_success_admin_email_content
  • direct_stripe_error_user_email_content
  • direct_stripe_error_admin_email_content

Parameters passed :

  1. $original_subject,
  2. $token,
  3. $amount,
  4. $currency,
  5. $email_address,
  6. $description,
  7. $user_id,
  8. $button_id
  9. $plan_id (only via subscription buttons, allows to retrieve $plan->name)

 

Example for creating custom email subject when the transaction fails for a precise button :

//Direct Stripe Filter Emails
add_filter('direct_stripe_success_user_email_content', 'ds_filter_email_content', 10, 8 );

function ds_filter_email_content( $original_subject, $token, $amount, $currency, $email_address, $description, $user_id, $button_id) {
   
  if( $button_id === 'my_id_passed_in_the_shortcode') {
     $email_subject = __('My custom subject', 'THEME_TEXT_DOMAIN');

     return $email_subject;

  } else {

   return $original_subject;
}

Example for creating custom email content when the transaction succeed for all buttons :

//Direct Stripe Filter Emails add_filter('direct_stripe_success_user_email_content', 'ds_filter_email_content', 10, 8 ); 
function ds_filter_email_content( $original_content, $token, $amount, $currency, $email_address, $description, $user_id, $button_id) {
     $amount = number_format( $amount/100, 2);
     $email_content = __('Thank you,', THEME_TEXT_DOMAIN);
     $email_content .= '<br />';
     $email_content .= __('A donation of ', THEME_TEXT_DOMAIN);
     $email_content .= $currency;
     $email_content .= $amount;
     $email_content .= __(' for ', THEME_TEXT_DOMAIN);
     $email_content .= $description;
     $email_content .= '<br />';
     $email_content .= __('Registration number :', THEME_TEXT_DOMAIN);
     $email_content .= $token;
     $email_content .= '<br />';
     $email_content .= __('Cheers', THEME_TEXT_DOMAIN);

     return $email_content; 
}

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *