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.
Thank you to all of our customers!
- This topic has 19 replies, 6 voices, and was last updated 7 years, 2 months ago by
Philip Burton.
-
AuthorPosts
-
December 2, 2015 at 10:32 pm #17341
Mark
ParticipantI 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.
December 2, 2015 at 10:37 pm #17342WC Vendors Support
ParticipantWith 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….
December 7, 2015 at 2:22 pm #17829Mark
ParticipantHi 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,
MarkDecember 7, 2015 at 2:29 pm #17831WC Vendors Support
ParticipantHi 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
March 4, 2016 at 4:23 pm #25622Mark
ParticipantHi 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.
March 4, 2016 at 7:17 pm #25629WC Vendors Support
Participantfunction 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.
March 7, 2016 at 3:04 pm #25895Mark
ParticipantThis 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);March 7, 2016 at 4:32 pm #25908WC Vendors Support
ParticipantSure. 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.
March 7, 2016 at 10:30 pm #25936Mark
ParticipantDid 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’ );
}March 7, 2016 at 10:50 pm #25940WC Vendors Support
ParticipantYou’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
March 8, 2016 at 10:53 am #25989Mark
ParticipantOk, 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’ );March 8, 2016 at 11:55 am #26001Mark
Participantupdate…
I replaced
update_user_meta( $user_id, ‘_wcv_commission_amount’, ’65’ );
with
update_user_meta( $user_id, ‘_wcv_commission_percent’, ’65’ );and it WORKED 🙂
March 8, 2016 at 12:15 pm #26005Mark
Participantspoke 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 feeany suggestions?
March 8, 2016 at 1:52 pm #26016WC Vendors Support
Participantpdate_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
March 10, 2016 at 11:54 am #26328Mark
ParticipantI got this to work…this problem is solved. Thanks
September 24, 2016 at 12:45 pm #43456Reem Safdar
ParticipantHi 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% CommissionPremium Membership
10% CommissionGold Premium Membership
3.33% CommissionI’d really appreciate help here!
Best Regards,
Reem
reemsafdar@hotmail.comSeptember 25, 2016 at 10:30 am #43504Karol
ParticipantI also join to the please,
Best Regards
KarolOctober 4, 2016 at 5:48 am #44209Philip Burton
ParticipantHi 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
October 4, 2016 at 12:23 pm #44246Anna
Memberadd_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.October 5, 2016 at 10:59 am #44334Philip Burton
ParticipantThe 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
-
AuthorPosts
- The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.