Home Forums WC Vendors Pro Support Mulitple Commission Options for Vendors?

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 20 posts - 1 through 20 (of 20 total)
  • Author
    Posts
  • #17341
    Mark
    Participant

    I understand that we can set the Global commission percentage within WC Vendor and then you can manually override individual stores with a different percentage.

    Do you have any ideas or suggestions on how I might be able to setup Vendors in two groups or roles that automatically have different commission percentages. For example, the scenario Im thinking about is one PMpro Membership level would be vendor with a 5% commission and the second PMpro Membership level would be a vendor with 0% commission setting.

    #17342
    WC Vendors Support
    Participant

    With a little bit of elbow grease, you can do this pretty easily.

    Use the filter “wcv_commission_rate” as outlined in this example code:

    https://www.wcvendors.com/kb/commissions-fixed-dollar-amount-fixed-plus-percentage/

    …..and have it just check the members groups/roles/whatever and if they are in one group, give this commission, if in the other, that commission, etc….

    #17829
    Mark
    Participant

    Hi Ben,
    I’m not very good at PHP coding yet and it sounds like something you know how to do very easily and I would rather it be done right. Is this something you would be interested for custom coding? Would it take only an hour? Let me know and I will send you more info/details to your email like before.

    Thanks,
    Mark

    #17831
    WC Vendors Support
    Participant

    Hi Mark,

    Our minimum time for a custom job is 3 hours ($147). It’d probably take 2+ to do this, since we have to dig through Paid Memberships Pro in order to sort out how all the group stuff works to begin with. If you’d like to get it done, sure, shoot me an email and we can sort it all out.

    Ben

    #25622
    Mark
    Participant

    Hi Ben,

    I’m trying work through this and wanted to see if you see something obviously wrong with either of the two different methods I tried.
    Background…
    First my global commission settings is “Percentage” with 90 (ie 90%) goes to the vendor. This split is working correctly and displayed via paypal express checkout. Im testing in the paypal sandbox
    Next, Im trying to change this commission setting based on the vendor’s PMPro membership level.

    First thing I tested was using the code example(to play with this filter like you suggested) above just to see if it changed….tried the fixed dollar amount plus commission code. No split shows up in paypal express checkout, but then removed this code and changed the global commission settings to “percentage +fee” and this worked. Assuming the sample code is not needed anymore to accomplished the same thing in the current version of WC Vendors Pro. Is that correct?

    Next, I set my global commission settings back to “Percentage” with 90 (ie 90%) goes to the vendor and added the following code to try to get the commission rate to change based on Pmpro membership level, but the splits don’t show up anymore (ie, no commission is going to the vendor) for either of these two methods. Any ideas????

    * Changing the commission rate to vendor based on the vendors membership level */
    add_filter( ‘wcv_commission_rate’, ‘my_wcv_commission_rate’, 10, 6 );
    function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $level_id, $user_id ) {
    if($level_id == 1)
    {
    return;
    }
    elseif($level_id == 2)
    {
    // Want membership level 2 to match the global commission settings
    $commission = 90;
    return $commission;
    }
    elseif($level_id == 3)
    {
    // Want membership level 3 to have commission of 95 percent going to vendors
    $commission = 95;
    return $commission;
    }
    }

    The other way I tried was…..

    add_filter( ‘wcv_commission_rate’, ‘my_wcv_commission_rate’, 10, 6 );
    function my_wcv_commission_rate( $commission_rate, $product_id, $product_price, $order, $level_id, $user_id ) {
    if($level_id == 1)
    {

    return;
    }
    elseif($level_id == 2)
    {
    // Want membership level 2 to match the global commission settings
    $commission_rate = 90;
    return $commission_rate;
    }
    elseif($level_id == 3)
    {
    // Want membership level 3 to have commission of 95 percent going to vendors
    $commission_rate = 95;
    return $commission_rate;
    }
    }

    Note: was also using this code for ideas, https://www.wcvendors.com/help/topic/paid-membership-solution/

    Thanks.

    #25629
    WC Vendors Support
    Participant
    function my_wcv_commission_rate( $commission, $product_id, $product_price, $order, $level_id, $user_id ) {
    if($level_id == 1)

    This is the problem. What passes the $level_id to the filter? You’re just adding a variable that doesnt exist and that WC Vendors doesnt ask.

    You would want to look up everything INSIDE the filter, and then run your commission checks after you’ve defined all of your variables.

    #25895
    Mark
    Participant

    This might be another dumb idea, but since we can manually change a users “commission rate (%)” in that user’s “profile” and this will override the global settings, is it possible to assign value to commission rate like below?

    Just like I can change the user role from subscriber to vendor or vice versa in this code, could I add a line like: $wp_user_object->set_commission_rate(’50’);
    to change the percentage rate for that user to 50% and override the global default commission rate?

    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    //get user object
    $wp_user_object = new WP_User($user_id);

    //ignore admins
    if(in_array(“administrator”, $wp_user_object->roles))
    return;

    if($level_id == 1)
    {
    //New member of level #1. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    }
    elseif($level_id == 2)
    {
    //New member of level #2. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    }
    elseif($level_id == 0)
    {
    //Cancelling. Give them Subscriber role.
    $wp_user_object->set_role(‘subscriber’);
    }
    }
    add_action(“pmpro_after_change_membership_level”, “my_pmpro_after_change_membership_level”, 10, 2);

    #25908
    WC Vendors Support
    Participant

    Sure. There’s a few meta keys that control each users commission rate if individually set:

    1.) Commission type: _wcv_commission_type – Values of fixed, fixed_fee, percent, or percent_fee

    2.) Commission Amount: _wcv_commission_amount – The number for fixed, or percent

    3.) Commission Fee: _wcv_commission_fee – A number for the fee, if fixed_fee or percent_fee

    So let’s say that the vendors user ID is 100. And we want to give them a commission rate of 50% plus $2.00:

    update_user_meta( '100', '_wcv_commission_type', 'percent_fee' );
    update_user_meta( '100', '_wcv_commission_amount', '50' );
    update_user_meta( '100', '_wcv_commission_fee', '2' );

    As you can see, we set the commission type first, then entered the amount, then entered the fee. Tweak as you see fit.

    #25936
    Mark
    Participant

    Did I add the update_user_meta line correctly in modifying the code I posted above? Should this work? When I try it, the user role gets changed correctly, but the “Commision Rate (%)” field on the user profile is still blank (instead of showing 50).

    elseif($level_id == 2)
    {
    //New member of level #2. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    update_user_meta( $user_id, ‘_wcv_commission_amount’, ’50’ );
    }

    #25940
    WC Vendors Support
    Participant

    You’re running update_user_meta in the right place. But you’re just setting the amount. You still need to set the commission TYPE. 🙂 If you’re trying to give 50% commission to vendor, then you’d also want to include:

    update_user_meta( '$user_id', '_wcv_commission_type', 'percent' );

    Cheers

    #25989
    Mark
    Participant

    Ok, I have played around with this a little and I can only get 2 of the 3 to work.

    These lines work and show the updates appropriately in the user profile under the “Pro Commission” section. Note, the $user_id variable did not need quotes.
    update_user_meta( $user_id, ‘_wcv_commission_type’, ‘percent_fee’ );
    update_user_meta( $user_id, ‘_wcv_commission_fee’, ‘6’ );

    This line I could never get to update. Can you confirm the ‘_wcv_commission_amount’ is correct?
    update_user_meta( $user_id, ‘_wcv_commission_amount’, ’65’ );

    #26001
    Mark
    Participant

    update…

    I replaced
    update_user_meta( $user_id, ‘_wcv_commission_amount’, ’65’ );
    with
    update_user_meta( $user_id, ‘_wcv_commission_percent’, ’65’ );

    and it WORKED 🙂

    #26005
    Mark
    Participant

    spoke too soon….

    the meta data was updated in the profile, however when I purchased a product from this user, the global default commission settings were applied and not the commission settings that show up in that vendor’s user profile.

    for test example,
    my global settings are set for “percentage” only 90/10 split
    the individual settings for this vendor is “percent_fee with a 65/35 split and $6 fee

    any suggestions?

    #26016
    WC Vendors Support
    Participant
    pdate_user_meta( '100', '_wcv_commission_type', 'percent_fee' );
    update_user_meta( '100', '_wcv_commission_amount', '65' );
    update_user_meta( '100', '_wcv_commission_fee', '6' );

    That should do the trick right there. I’ve checked by adding a test vendor with those 65% $6 parameters & percent + fee and checked the user_meta for the vendor and those fields match up 100%.

    Attached is a screenshot from the commissions code showing the meta keys

    #26328
    Mark
    Participant

    I got this to work…this problem is solved. Thanks

    #43456
    Reem Safdar
    Participant

    Hi guys.

    Can you please share the final code? I’ve been trying to implement the same thing and I’m going nuts with it. I’d really appreciate it if you can share the code..

    I am using WC Vendors, PMPro memberships and I’ve the following commissions that I need to set up for Vendors:

    Basic Membership
    15% Commission

    Premium Membership
    10% Commission

    Gold Premium Membership
    3.33% Commission

    I’d really appreciate help here!

    Best Regards,
    Reem
    [email protected]

    #43504
    Karol
    Participant

    I also join to the please,

    Best Regards
    Karol

    #44209
    Philip Burton
    Participant

    @mtgame21

    Hi Fella could you post the code that you got to work, I’m close but no cigar at the moment with the bit below

    function my_pmpro_after_change_membership_level($level_id, $user_id)
    {
    //get user object
    $wp_user_object = new WP_User($user_id);

    //ignore admins
    if(in_array(“administrator”, $wp_user_object->roles))
    return;

    if($level_id == 1)
    {
    //New member of level #1. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    update_user_meta( ‘$user_id’, ‘_wcv_commission_type’, ‘percent’ );
    update_user_meta( $user_id, ‘_wcv_commission_percent’, ’90’ );
    }
    elseif($level_id == 2)
    {
    //New member of level #2. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    update_user_meta( ‘$user_id’, ‘_wcv_commission_type’, ‘percent’ );
    update_user_meta( $user_id, ‘_wcv_commission_percent’, ’100’ );
    }
    elseif($level_id == 3)
    {
    //New member of level #3. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    update_user_meta( ‘$user_id’, ‘_wcv_commission_type’, ‘percent’ );
    update_user_meta( $user_id, ‘_wcv_commission_percent’, ’100’ );
    }
    elseif($level_id == 4)
    {
    //New member of level #4. Give them Vendor role.
    $wp_user_object->set_role(‘vendor’);
    update_user_meta( ‘$user_id’, ‘_wcv_commission_type’, ‘percent’ );
    update_user_meta( $user_id, ‘_wcv_commission_percent’, ’94’ );
    }
    elseif($level_id == 0)
    {
    //Cancelling. Give them Subscriber role.
    $wp_user_object->set_role(‘subscriber’);
    }
    }
    add_action(“pmpro_after_change_membership_level”, “my_pmpro_after_change_membership_level”, 10, 2);

    Knowing me I will be missing something blatantly obvious 😉

    Cheers

    Phil

    #44246
    Anna
    Member

    add_action('pmpro_after_change_membership_level', 'my_pmpro_after_change_membership_level', 10, 2);
    The double-quotes you have in the action were incorrect. Use single quotes.

    That being said, I have NOT checked the rest of the code or its functionality.. Currenlty I do not have a dev install with PMPRO active so I cannot jump in and check the function of your codework.

    So.. if I have time later I will, as I would like to help if possible, but not at the moment as I have a lot of support requests for WC Vendors to handle.

    One thing for sure– Go through and make sure all of the quotes are NOT fancy quotes. I am not sure if you copied the base code for this in a properly formatted chunk of code or not. If the single or double quotes show straight up and down like this:' " Then they are correct for coding. If they are styles like this: ‘ “ Then they’ll be an issue.

    #44334
    Philip Burton
    Participant

    @fervous

    The double quotes were straight off https://gist.github.com/fervous/9ae6e29b59581ac7559f#file-pmp-and-wc-vendors

    I am but a mere copy and paste merchant. 😉

    Don’t know where the fancy quotes came from – changed those to straight & the aforementioned doubles to single quotes. still no joy.

    Will keep on plugging away as it will be something silly.

    Cheers

Viewing 20 posts - 1 through 20 (of 20 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.