Code

Discussion on WooCommerce Role-O-Matic

Discussion on WooCommerce Role-O-Matic

Cart 510 sales

vanquish supports this item

Supported

207 comments found.

Hi,

I have a rule that gives auto “Member” User role upon hitting $120 value in a checkout.

However, I noticed that the User will have two roles “Customer” , “Member”.

Is it possible to remove “Customer” when he has become a “Member”?

Thank you for the prompt response!

What is the difference on Role(s) removal and how would it impact anything?

How will I be able to get the new feature?

The role(s) removal feature removes the roles assigned if the rule is no longer satisfied.

For example you assign a customer the addtional “Member” if he spens 120$ during the current year. Let’s supporse that last year he spent 120$, so he was Customer and Member. This year hasn’t spent 120$, so the Member role is automatically removed by the plugin. This can be done be cause he still have a base role of Customer.

In case I’ll implement to remove all the current roles and then assign the new one (in this case Memeber), I have to disable the Role(s) removal option for this kind of rule. This to avoid that an user can be without any role.

For what concerns the update, I’ll release via codecanyon. Meanwhile you can send me a private message (click on my name then use the low-right box), I’ll send the update via email.

... But I can easily avoid the case of an user can be without any role. In case a role is removed and the user would have none assigned, the plugin will assign again the base role of Customer…. so do not take care of what I wrote before :)

Is it possible to change a role per amount spent per order?

Hi,
no unfortunately the plugin doesn’t not have that feature. It is a good suggestion, I’ll try to see if it can be implemented in a future release, but I cannot give you any eta.

hi its not working for me, not changing the user role. i would really need some guidance. thanks

also i get this: Cannot load woocommerce-role-by-amount-spent.

Is then the plugin active? I need some more clues about your woocommerce installation.
Have you properly installed and activated the plugin? If so you should see the Role-O-Matic menu voice on the left menu.
Could you report me a screenshot of the role assignment rule you are try to appling? would be possible to have a backend access? (if so send me a private message using clickng on my name and the using the low-right box)

Hi,, sorry if this question is already answered in plugin information but I think its not there. If a user has 5 days remaining of X role and he triggers the plugin again to give him 30 days more of that role, does he start with 30 days or with 35? thanks.

The variations inside the same product is a great idea, although they can be different products if it is more easy to code for you. Example

Product1: Editor subscription 1 week Product2: Editor subscription 1 month

Or you can make it with variations inside the same product. As you wish.

That is correct, a user would not be very happy if they have 5 days remaining and when they buy 30 days more the other 5 days disappear.

I really think that you can be the first one on making this type of plugin that a lot of people requires.

ok, all clear!
I think I can both support product and variations. I’ll let you know in case of news! :)
Thank you for the suggestion and the explanation! :)

Hi,
good news, I’ve release a plugin update that now allows to associate roles to products.
Plugin page and demo have been updated, it will be ready to download in half a day (codecanyon approval system takes a while).

The plugin is now named WooComemrce Role-O-Matic and now allows you to associate to a product one or more role, expiration date (fixed or relative) rebuy and product buy restrictions.

It has the features you have listed except for the expiration date extension. For now, if rebuy is allowed and the customer rebuys the product, it will loose the remaining day of the old subscription. Is in the work to implement this feaure.

Meanwhile I hope you enjoy :)

Hello! First of all thanks for this awesome plugin! Totally I found what I need!

Tell me please how to echo how many money current user spent?

Hi victorslate,
thank you for your words :)
For now there isn’t any method by which echoing how much money an user spent.

To know which users beleongs to the various created roles (and so know how much money they have minimum spent) you can go to the Users -> All users menu voice. On the top of the list are reported the current existing roles. Clicking on them you can filter the list and know which usere belong to selected role.

To have a more deep users stats (products bought, how much money they have spent in all time or a specific period, which users have bouught specific products,...) you could consider to use this other plugin of mine: WooCommerce Customers Manager.

Let me know if this could be useful or if you had in mind another idea!

Why not? Here is a method to display: echo wc_get_customer_total_spent() I trying to understand how your plugin processing this function and how can I use it to display anywhere on my site. I need to display spend for selected periods (i.e 12 month).

I’m tried to change Woo function and add this line AND date > NOW – INTERVAL 12 MONTH but this isn’t work…

Maybe you can help? Here is a code:

function wc_get_customer_total_spentNEW( $user_id ) { if ( ! $spent = get_user_meta( $user_id, ‘_money_spent’, true ) ) { global $wpdb; }

$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
        FROM $wpdb->posts as posts
}
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
    LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id
WHERE   meta.meta_key       = '_customer_user'
AND     meta.meta_value     = $user_id
AND     posts.post_type     IN ('" . implode( "','", wc_get_order_types( 'reports' ) ) . "')
AND     posts.post_status   IN ( 'wc-completed', 'wc-processing' )
AND     meta2.meta_key      = '_order_total'
AND date > NOW() - INTERVAL 12 MONTH
" );
update_user_meta( $user_id, '_money_spent', $spent );
return $spent;

Because the plugin was not designed to offer that feature and never claimed to have. Furthermore support service is not meant to be used as customize service.

However my plugin doesn’t use the nateive wc_get_customer_total_spent(). To compute how much user spent during the configured time period it simply retrieves all orders containing the selected products (if any) in the specified time range and then computes the total amount spent.
This function is the get_orders_by_date_and_user_id() defined in the classes/com/get_orders_by_date_and_user_id(). You can have a look there and try using it.

You could create a shortcode that simply calls it passing the user_id, using as $time_period value the “fixed” one, using as $date_rule an object containing the dates you need (maybe passed as parameter to the shortcode) and null for the $products_restiction paramenter.
Once done you have processes the data that function returns and then displays the total.

I want this if it can support woocommerce subscriptions! Very simple goal, create a role based on active subscription … if subscribe to print, then subscriber-print, if subscribed to digital then subscriber-digital if both then …. do not want to create elaborate groups/memberships data is already there!

Hi shawnholt,
unfortunatelly the plugin doesn’t support any 3rd party plugin. However I could try to see if it is possible to integrate. which is the plugin you are using to manage subscriptions?
can you send me a copy? if so, send me a private message clicking on my name and then use the low-rigth box. I’ll reply with my email address where you can send the plugin.

hi there, just a few pre-sale questions. 1. is it possible to set repeat rules? e.g. at the beginning of each month, it will verify how much money customer has spend during last month/last 3 months and set new rules? 2. when would the change of role happen? at the begining of each month? or at the time of purchase? what is the basis for the amount spend? is it product only? or product+shipping cost, or including tax as well? thanks

sorry I made you confused. Let us make it this way in following scenario:
1. During 1 January to 31 January, client made a purchase of $1500.
2. His role was changed from customer to customer_level_1 due to his purchase in January.
3. During 1 February to 28 February, he made a purchase of $800.
4. Due to his less purchase, the user role needs to be changed from customer_level_1 back to customer.
To achieve this, I will be setting 4 rules:
a) Rule 1: all clients(except for admin and shop managers) purchase above $1000 during 1 January to 31 January, the role are changed from customer to customer_level_1(with roles removal set to Yes)
b) Rule 2: all clients(except for admin and shop managers) purchase below $1000 during 1 January to 31 January, the role are changed from customer_level_1 back to customer.(with roles removal set to Yes)
c) Rule 3: all clients(except for admin and shop managers) purchase above $1000 during 1 February to 28 February, the role are changed from customer to customer_level_1(with roles removal set to Yes)
d) Rule 4: all clients(except for admin and shop managers) purchase below $1000 during 1 February to 28 February, the role are changed from customer_level_1 back to customer.(with roles removal set to Yes)
In my case, I do want the customer roles to vary automatically according to their purchase during last month. so if rule 1 and rule 2 are only effective during 1 Feb to 28 Feb, and rule 3 and rule 4 are only effective during 1 March to 31 March, it is then perfect, otherwise this four rules would conflict.

Major conflict is between rule 1 & rule 4, and also between rule 2 & rule 3, system would not know which user role the customer belong to if they have spent $1500 in January and $800 in February. And By default, we do not want one customer to belong to two user roles, that is also going to confuse them.
so solution is that if effective date can be set for each rule, then we can set when the rule is effective, so as to avoid conflicts.
also note that the rule effective date(if outside the effective date, the rule is disabled) is different from the time period type (e.g. the dynamic period and fixed periods) The specified time period means this rule is targeted for the sales during that period, but the rule effective date targets for when this rule is enabled.
Further, I don’t quite understand how the fixed periods date work in the rule. As it says, “Date rules have priority that goes bottom-up. Lower rules have higher priority”. So it means that it would only execute the rule for the first met date? I guess it might be better if an option says “And” or “Or” logic to the dates would make more sense.
I am sorry to put forward all above things, Please let me know if you need me to skype with you to discuss further(and I am really willing to as this is quite important for the rule effective date).

Ahh ok I’ve understood. It would be very usefull to specify and additiona effective time period/date in which the rule will be applied (because by now the rules are applied after the starting date is greater than “now”)... right?

So as you say, an user role can be assigned during june using the february month data…. right? this is not hard to implement (sorry if I’m asking confirm many times but I would like to waisting time implementing a thing that I’ve missunderstood :) )

By now, as I said previously, all the rules are applied whenever the starting date is greater than “now”. Rules are analyzing using the list order, so if there are two rules conflicting, the lower one would “win”.

For what concerns the 2 and 4 rule according to me can be avoided. Using the 1 and 3 rules with the roles removal option enabled, the customer_level_1 is already automatically removed (if the user has it) if the amout goal is not been reached.
Note that the plugin doens’t switch from a role to another but adds the specified roles to the users.
Anyway send me a private message (click on my name and then use the low-right box) so we can talk via email/chat

Hi there, I’ve sent you a private message. let me know if you didn’t receive it. thanks – scott

by
by
by
by
by
by

Tell us what you think!

We'd like to ask you a few questions to help improve CodeCanyon.

Sure, take me to the survey