Using Conditional based on a Plan

6 years 4 months ago #300354 by RobGG
Using Conditional based on a Plan was created by RobGG
Hi,

On a back-end CBSubs registration Page I want to use conditionals based on the plan selected in the previous screen. I understand from a previous post that a conditional cannot be used based on this selection screen. Is it possible to use an Auto Action to extract the PLAN_ID, set it into a new variable (e.g. cb_planid) and then use this for conditionals?

If yes, what is the earliest Auto Action that could recover the PLAN ID?

Regards, Robert

Please Log in to join the conversation.

6 years 4 months ago #300373 by krileon
Replied by krileon on topic Using Conditional based on a Plan
You can use the below to perform various actions on plan state change.

Plan Active
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A

Plan Expired
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Not Equal To A

[var3] is the plan id. You could for example set that to a field using a Field action.

Alternatively instead of storing the plan id you can use CB Query Field to query for their subscription row and return their subscription id if they've an active subscription to a plan. This is done with the below query for example.

SELECT `id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `status` = 'A' AND `plan_id` = PLAN_ID_HERE ORDER BY `subscription_date` DESC LIMIT 1


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.145 seconds

Facebook Twitter LinkedIn