• Resolved odeal4ik

    (@odeal4ik)


    Hello, your job is very good)
    But can you help with a questuion.
    It’s needed to send to admin a new customer/user his name, which typed in billng name field. How to get access to this fireld?

    Using your old gist

    add_filter( ‘direct_stripe_success_user_email_content’, function( $message, $token, $amount, $currency, $email_address, $description, $user_id, $button_id){

    $message = ‘User ‘ . $email_address . ‘ have been charged ‘ . $amount . $currency . ‘ for ‘ . $description;

    return $message;

    }, 10, 8 );

    thanks.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @odeal4ik ,

    Thank you for using Direct Stripe.

    I understand that you want to show the Stripe user’s name in the email sent to the admin, is that correct ?

    If yes, note that you have access to the $user_id from the filter hook you found, that means you can use get_user_by('id', $user_id ) to retrieve the user’s object and then get the field you need from it.
    Then you would need to use the field retrieved and add it to the $message.

    Let me know if that helps or if I misunderstood the question and that doesn’t make sense.

    Kind regards

    Thread Starter odeal4ik

    (@odeal4ik)

    Hello, thanks for an answer. Bad news, i’he tried, but it still not workin and in email it’s an empty field.
    Even after trying var_dump, print_r etc.

    And $user_info, $user_id is always – 1.

    Maybe this hook works not in his time?

    add_filter( 'direct_stripe_success_admin_email_content', function( $token, $amount, $currency, $email_address, $description, $user_id, $button_id, $message){
        $today = date("j, n, Y");
    
        $user_info = get_user_by('id', $user_id );
        $user_email = $user_info->user_email;
    
        $message = '<h1>TEXT - somesite.ru</h1><br/>' .
            "https://{$_SERVER['HTTP_HOST']}<br/>" .
            'TEXT - ' . $email_address . '<br/>' .
            'TEXT- ' . number_format( $amount/100, 2) .' &nbsp; '. $currency . '<br/>' .
            'TEXT - '. $description . '<br/>' .
            'TEXT - ' . $today . '<br/>' .
            'TEXT - ' . print_r($user_info) . '<br/>';
    
        $message .= 'Пользователь - ' . $user_email . '<br/>';
    
        return $message;
    
    }, 10, 8 );

    And when i try to get user in other frontend point, it works correctly and returm to me all field i want. But i need to sent them right after payment.

    • This reply was modified 5 years, 5 months ago by odeal4ik.
    • This reply was modified 5 years, 5 months ago by odeal4ik.
    • This reply was modified 5 years, 5 months ago by odeal4ik.
    Thread Starter odeal4ik

    (@odeal4ik)

    And 1 comment.
    Any there any possibility to add currency? For example for russian rubles or ukrainian hrivnas?

    Thread Starter odeal4ik

    (@odeal4ik)

    Ok, problem solved.

    For me it’s small problem but $user_id contains id of user and Stripe customer ID in format cus_…. in array.

    $user_info = get_user_by(’email’, $email_address) works fo me;
    I have all access.

    Thanks for plugin.

    Can you answer about currencies?

    Thread Starter odeal4ik

    (@odeal4ik)

    Thank you, visa converts my money)
    For test i didn’t knowed about minimal currency.

    Plugin Author Nicolas Figueira

    (@nahuelmahe)

    Hello @odeal4ik ,

    I’m glad you found solutions !

    And I’m sorry I mislead you with the User ID, it actually make sense it holds the stripe ID but I failed to name it at the time.

    Kind regards,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to send billing name to admin after succes transaction’ is closed to new replies.