Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[#5819] Trouble (bug?) with Auto Actions

8 years 8 months ago - 8 years 8 months ago #278346 by akasharkbow
[#5819] Trouble (bug?) with Auto Actions was created by akasharkbow
Hi there

I've run into some trouble with the CB AutoActions plugin, in particular the CB Paid Subscriptions "renew" function. I am running CB 2.0.13, CBSubs 4.0.1 and CB Auto Actions 6.3.4.

Objective: to create or renew a subscription for any user who logs in IF the field [cb_gge_coupon] contains the value 2016.

I have created an AutoAction as follows:
Type: Cb Paid Subscriptions
Trigger: onAfterLogin
Conditions: [cb_gge_coupon] Equal to 2016
Action: Subscribe (subscription name)
Reload User: Yes

This works for users (i) who have never had a subscription before, or (ii) who have had a subscription before but cancelled it. It does not work for users who have current or expired subscriptions: their subscription status appears unchanged.

So, I created a second AutoAction (and unpublished the first one) to test with users who have active or expired subscriptions.

Type: Cb Paid Subscriptions
Trigger: onAfterLogin
Conditions: [cb_gge_coupon] Equal to 2016
Action: Renew (subscription name)
Reload User: Yes

I've tried this with users who have either expired or active subscriptions, and it does not change the subscription status.

Could this be a bug, or is there something I should double check? I've been beating my head against the wall trying to test different AutoActions to see when this is / is not working.

Thanks so much.
Last edit: 8 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #278369 by krileon
Replied by krileon on topic Trouble (bug?) with Auto Actions
Each Mode in the CB Paid Subscriptions action has conditions that are checked against each subscription as follows.

Subscribe: Current subscription can not be active
Renewal: Current subscription can not be active
Unsubscribe: Current subscription must be active

In short you're trying to renew an existing active subscription? The problem with that is you're using after login and checking a static field value. Every login attempt would renew the subscription, which is why the above condition check is there.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

8 years 8 months ago #278375 by akasharkbow
Replied by akasharkbow on topic Trouble (bug?) with Auto Actions
Thanks for the reply. A few things:

1. Renewal does not work when user has an expired subscription. So the question still stands.

2. To simplify the question, I did not describe my entire set-up - which also includes a second auto-action to change the [cb_gge_coupon] variable; this means that the next time the user logs in, the 1st AutoAction (subscribe) does NOT fire. So - no - this does not subscribe the user every time they log in. However, if I did want them to be resubscribed each time they logged in (and I can imagine some scenarios), I don't see why this should be a problem or prevented by Autoactions.

3. Better documentation would help a lot here. A subscriber with a current subscription can renew herself, so why would this not work with AutoActions?

4. How do I remove the check "Renewal: Current subscription can not be active"? Or, instead, how can I use a different AutoAction (code?) to achieve the same thing?

Thanks.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago - 8 years 8 months ago #278413 by krileon
Replied by krileon on topic Trouble (bug?) with Auto Actions

1. Renewal does not work when user has an expired subscription. So the question still stands.

Are you users subscriptions marked expired in CBSubs > Subscriptions? It's directly checking that status. A grace period for example can prevent them from being expired until the grace period ends.

2. To simplify the question, I did not describe my entire set-up - which also includes a second auto-action to change the [cb_gge_coupon] variable; this means that the next time the user logs in, the 1st AutoAction (subscribe) does NOT fire. So - no - this does not subscribe the user every time they log in. However, if I did want them to be resubscribed each time they logged in (and I can imagine some scenarios), I don't see why this should be a problem or prevented by Autoactions.

Will review removing the hard condition in next release.

forge.joomlapolis.com/issues/5819

3. Better documentation would help a lot here. A subscriber with a current subscription can renew herself, so why would this not work with AutoActions?

Documentation has nothing to do with it. I'm not going to document what every action does with every little IF condition, sorry. CB Auto Actions is a tool. Its documentation will consist on how to use said tool. It's not going to transcribe its PHP to you.

4. How do I remove the check "Renewal: Current subscription can not be active"? Or, instead, how can I use a different AutoAction (code?) to achieve the same thing?

Modify the below action or use Code action with PHP method to execute CBSubs API.

components/com_comprofiler/plugin/user/plug_cbautoactions/models/cbsubs.php


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 8 years 8 months ago by krileon.

Please Log in or Create an account to join the conversation.

8 years 8 months ago #278427 by akasharkbow
Replied by akasharkbow on topic Trouble (bug?) with Auto Actions
1. Thank you - that may well be the issue. I will test again.

2. Thank you - that fix would be great.

3. I'm trying hard not to read your comment as condescending - but I do not agree with what you say. Really, given that the command "renew" works for an active subscriber in EVERY other context (- for that same user via the front end, and also for an admin - ) I think that if you are going to deliberately impose conditions that make it impossible to renew this SAME user within AutoActions then it is reasonable to expect a note about it. I've been managing Joomla websites for more than a decade, and usually if I have to try to decipher the php to figure out why something that seems obvious in the component is not working, to me that is a bug or badly thought-out programming. While sometimes it is my inadequacy, in this case I don't believe so:

- Renew FRONT end -> anyone who has active or expired subscription
- Renew ADMIN -> anyone who has active or expired subscription
- Renew AUTOACTIONS -> only users with expired subscriptions who have also passed the grace period

4. Thank you.

***If you have a moment I would be *extremely* grateful if you could tell me which line needs editing and how***, as I've been trying to find a workaround for this issue for days and am now way past my deadline and at my wits end.

Thanks.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48460
  • Thanks: 8280
  • Karma: 1443
8 years 8 months ago #278435 by krileon
Replied by krileon on topic Trouble (bug?) with Auto Actions

3. I'm trying hard not to read your comment as condescending - but I do not agree with what you say. Really, given that the command "renew" works for an active subscriber in EVERY other context (- for that same user via the front end, and also for an admin - ) I think that if you are going to deliberately impose conditions that make it impossible to renew this SAME user within AutoActions then it is reasonable to expect a note about it. I've been managing Joomla websites for more than a decade, and usually if I have to try to decipher the php to figure out why something that seems obvious in the component is not working, to me that is a bug or badly thought-out programming. While sometimes it is my inadequacy, in this case I don't believe so:

It would be a bug as a result of badly though-out programming. I implemented the hard condition as a safe guard against poor auto action usage, but it's really unnecessary. It should mimic backend user edit subscription tab behaviors as close as possible. So you're absolutely not wrong that it needs work. I apologize for coming off a bit strong.

***If you have a moment I would be *extremely* grateful if you could tell me which line needs editing and how***, as I've been trying to find a workaround for this issue for days and am now way past my deadline and at my wits end.

On line 58 is where it begins the switch case for the modes. The cases translate as follows.

1 = Subscribe
2 = Renew
3 = Unsubscribe
4 = Delete

With in the 2 switch usage you'll see the following IF check.

Code:
if ( $subscriptionStatus != 'A' ) {

That's responsible for stopping the renewal if the plan is already active. Changing it as follows should allow active subscriptions to renew.

FROM:
Code:
if ( $subscriptionStatus != 'A' ) { $subscription->activate( $user, $_CB_framework->now(), true, 'R' ); }
TO:
Code:
$subscription->activate( $user, $_CB_framework->now(), true, 'R' );


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum