Okay
  Public Ticket #2549068
Role based Pricing
Closed

Comments

  •  1
    Sunny Dadi started the conversation

    Hi There,

    Thank you for such a great and Powerful plugin

    We have 2 questions.

    1> 

    Is it possible to send custom emails based on a selection on registration form?

    We have salons register on our website and we would like to add a field with question "Would you like to be listed as a Stuckists on our website?"

    When they "Yes" - We would like to receive an email about their interest, so we will add them as Stockist.

    2>

    How do i apply price based on user roles?

    We are currently using gravity forms as registration form on our website and we assign user to particular role based on their selection.

    I cant see any option in plugin to assign the price based on user role.

    There is a registration role, but its not a user role.

    How do we assign the custom pricing to the user signed up through Grabvity forms, thanks.

    Looking forward to hear from you soon.


    Regards

    Sunny






  •  2,218
    WebWizards replied

    Hi Sunny,

    Thank you for purchasing our plugin first of all,


    1) To send custom emails based on a registration form selection.

    Step 1) you would add some custom code to functions.php

    add_action('woocommerce_created_customer', function(){
        // Here you have access to all the fields submitted during registration
        $your_custom_field = sanitize_text_field($_POST['b2bking_custom_field_1234567']); 
        // you need to replace 1234567 with the ID of the B2BKing field. You can find the id
        // by clicking on the field in the backend and copying the NUMBER in the LINK
        if ($your_custom_field === 'yes'){
            // if the user said yes, run your custom code that sends emails
        }
    });

    The code above needs some modifications and you need the actual code to send emails, because B2BKing does not have a custom emailing function. It would be helpful if you have a developer in your team, because there is quite a bit of custom code that needs to be done to fully set this up.


    2)

    B2BKing only sets prices based on GROUP, it cannot set prices based on role.

    The solution is simple: just connect your registration form to a b2bking group, so that when users register, they are added to the group automatically.

    I did this integration a little time ago.

    I believe the code to add to functions.php looks like this:

    add_action( 'gform_user_registered', 'add_custom_user_meta', 10, 4 );
    function add_custom_user_meta( $user_id, $feed, $entry, $user_pass ) {
        // to set b2bking group, first set that user is b2b
        update_user_meta ($user_id, 'b2bking_b2buser', 'yes');
        // then add the group id to the user meta. Replace 123456 with your b2bking b2b group ID
        update_user_meta ($user_id, 'b2bking_customergroup', 123456);
    }
    


    I hope this helps a little,

    If you are familiar with coding or you have a developer in your team, this should make sense to you.

    If not, I can help a little with some customizations if you give me a temporary login to your site. I can set the registration for you, though setting up the emails would be quite difficult, there's a lot to do there.


    Kind Regards,

    Stefan


  •   Sunny Dadi replied privately
  •  2,218
    WebWizards replied

    Hi Sunny,

    I set it up for you.

    I tested and I think it works correctly:

    7436985394.png


    I added the code using this plugin here, so don't delete/deactivate it:


    3788006976.png


    Best Regards, 

    Stefan

  •  2,218
    WebWizards replied

    I did one more adjustment to set the role to customer too, not salon:

    4639976639.png


  •   Sunny Dadi replied privately
  •  2,218
    WebWizards replied

    Hi Sunny,

    1) I understand you already checked the documentation, but just to be sure, this setting should be disabled:

    It should look like this:

    7668101283.png


    2)

    Make sure to clear cache and/or try with a new browser or incognito mode. Caching is a frequent issue for visibility.


    I tried to login with the previous link you gave me but that's no longer valid.

  •   Sunny Dadi replied privately
  •  2,218
    WebWizards replied

    Hi Sunny,

    I increased the priority of the function I added, which hopefully should make it so that it's used last and the correct group is set.

    Can you check if it works now?


    If not, I'll look more into it.

    - Stefan

  •   Sunny Dadi replied privately
  •  2,218
    WebWizards replied

    Hi,

    I did some more changes:

    I think it works now?

    6157591446.png


  •  1
    Sunny Dadi replied

    Thank you Stefan, I can see that problem is coming from AffiliateWp gravity form addon.

    But, kudo's to your attention to the ticket when i stuck with something.

    Regards

    Sunny


  •  2,218
    WebWizards replied

    Sure, my pleasure, let me know if I can help with anything.