Okay
  Public Ticket #3810399
Email send to customer
Closed

Comments

  •  2
    Timothy started the conversation

    Hello,

    I have a question about the emails that are sent when you approve or reject a B2B account.

    First: When you apply to be a B2B customer, you recive an email with a link to set your password, ect.
    But when the account is not approved yet so they can’t login to the site.
    Is there an option that when they apply they can already get access to their account but only as on B2C costumer until approval?

    Second: When they are approved for B2B they get the same email as when you approve there account for B2C.
    Is it possible to differentiate in emails where they get approved for B2b or B2C?
    When the first question would be possible this is something that may not be necessary.

    Tirth: When you reject somebody they will never get an email.
    Is there an option that you can let them know their application is rejected?
    Even when the first question would work, when you reject them to be a B2B customer they get an email of rejection.

    Thank you in advance and best regards,
    Timothy

  •  2,330
    WebWizards replied

    Hello Timothy,

    First: When you apply to be a B2B customer, you recive an email with a link to set your password, ect.
    But when the account is not approved yet so they can’t login to the site.
    Is there an option that when they apply they can already get access to their account but only as on B2C costumer until approval?

    In general, what we recommend here is to allow the customer to directly choose their password during registration, rather than use the password link option. Indeed when using approval the password link flow doesn't work that well.

    To allow customers to directly choose their password during registration, you can disable the following setting in WooCommerce -> Settings -> Accounts: https://prnt.sc/HqiNz7sQG0y5

     

    It is also possible to allow customers to access their account as a B2C customer until approval. For that, please enable the setting 'Existing users can apply' in B2BKing -> Settings -> Registration: https://prnt.sc/FgMrJEiZQ6uq

     

    Second: When they are approved for B2B they get the same email as when you approve there account for B2C.
    Is it possible to differentiate in emails where they get approved for B2b or B2C?

    This is possible, but you would need to copy the .php email template to your child theme and edit it there. This process of customizing templates is explained in more detail here: https://woocommerce-b2b-plugin.com/docs/how-to-customize-b2bking-emails/

    If you decide to go this route, let me know and I will send more details as to how you can differentiate between B2B and B2C in the PHP template code.

     

    Tirth: When you reject somebody they will never get an email.
    Is there an option that you can let them know their application is rejected?

    It is possible to add an email for this, by adding this PHP code snippet to your site:

    add_action('b2bking_reject_user_admin_before_delete', function($user_id){
        $user = new WP_User($user_id);
        $user_email = $user->user_email;
        $message = 'Thank you for taking the time to register, however, we were unable to approve your application...';
        do_action( 'b2bking_new_message', $user_email, $message, get_current_user_id(), 0 );
    }, 10, 1);

     

    You can customize the $message content per your needs.

    This snippet can be added to functions.php, or by following our guide here: https://woocommerce-b2b-plugin.com/docs/how-to-add-a-snippet-php-or-js/

    Something I'd like to mention: For this to work, it is necessary to enable the email in WooCommerce -> Settings -> Emails -> New message / conversation (this snippet uses that email).

     

    Kind regards,

    Stefan

  •  2
    Timothy replied

    Hello Stefan,

    Thank you for the extended and detailed answer.

    The first question is solved, this works perfectly.

    For the second question: I would like to get some more information on how to differentiate the 2 emails.

    For the third question, this works but I have one remark. If you reject the approval, the account is also deleted.
    Is there an option that if you reject the approval it stays a B2C account?
    This would also make the second question not necessary.

    But if that’s not possible we can put a reject message if we approve them just for B2C.

    Best regards,
    Timothy

  •   WebWizards replied privately
  •  2
    Timothy replied

    Hello,

    Thank you for your support.

    (2) I added the given code to php Snippet but I got the error “Attempt to read property "ID" on false”
    Scherm-afbeelding-2025-02-02-om-14-54-38.png
    And also how can I add content? With the Echo routine?

    (3) I updated the plugin to the attached version, Can I just update when the next official release comes?
    And do I have to use the code snippet that you provided when the new realise comes?

    I tested it and it works perfectly.

    Only when you reject the user in his account, he still get the message that his approval is pending although he is rejected.
    Scherm-afbeelding-2025-02-02-om-19-34-27.png

    And for the email he gets for his rejection, you made the code snippet so that it shows the User and the Message.
    Scherm-afbeelding-2025-02-02-om-19-49-49.png

    To not show the user name can I just delete  $user = new WP_User($user_id);  ?
    And to not show the “Message” Can I also use the Echo routine?

    Best regards,
    Timothy

  •  2,330
    WebWizards replied

    Hi again,

    (2) Regarding the error there: This code is not complete / standalone code, so it cannot be added as a snippet.

    To use it, you must copy the email template .php file to your child theme, edit that .php file, and then that code can be used as a block of code within the template. It requires some understanding of PHP to properly place the code within the template. 

    Is the idea that you're trying to set a different "your account is approved" text within that email? If you already have a child theme on the site, and you can share a backend login to the site with us, I can try to set that up directly.

     

    (3) Yes, we always merge these changes before releasing official versions, so you can always update to the latest official release without losing changes.

    To solve the issue with that message that shows 'your application is pending', please change the snippet to this:

    add_filter('b2bking_reject_user_delete','__return_false');
    add_action('b2bking_reject_user_admin_before_delete', function($user_id){
    	update_user_meta($user_id, 'b2bking_b2buser', 'no');
    	update_user_meta($user_id, 'b2bking_b2b_application_pending', 'no');
    	update_user_meta($user_id, 'b2bking_account_approved', 'yes');
    }, 10, 1);

     

     

    To not show the user name can I just delete  $user = new WP_User($user_id);  ?
    And to not show the “Message” Can I also use the Echo routine?

    If you edit the new message email template under the child theme, you can delete the lines that start with 'echo' to prevent the user: / message: text from showing.

  •  2
    Timothy replied

    Hello,

    We ended up not making the different emails between the B2b and B2C because of the rejection part.
    This works perfect!

    In the next update do I need to keep my 2 code snippets?

    Best regards,
    Timothy


  •  2,330
    WebWizards replied

    Good to hear that's working!

    The code snippets always need to be kept on the site, as these are unique to your specific site.

     

    However, the B2BKing plugin can always be updated to the latest official version and you will not lose any changes by doing that. We have already merged all versions of B2BKing we sent you with the official version, so you will never lose changes by updating.