[SOLVED] onCPayAfterPaymentStatusUpdateEvent and var3
- lousyfool
- OFFLINE
- Posts: 141
- Thanks: 46
- Karma: 5
I need to run a query once the plan with ID 1 has been purchased, meaning it's been in a basket and status is "Completed".
Created an Auto Action of type Query,
Trigger: onCPayAfterPaymentStatusUpdateEvent
Conditional 1: [var4] Equal to Completed
Conditional 2: [var3_plan_id] Equal to 1
Conditional 2 keeps failing (also if I use only [var3]):
What am I doing wrong? A hint would be greatly appreciated.
Please Log in or Create an account to join the conversation.
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9109
- Karma: 1434
Plan Active
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Equal To A
Plan Expired
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var3] Equal To PLAN_ID_HERE
2: [var2] Not Equal To A
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.
- lousyfool
- OFFLINE
- Posts: 141
- Thanks: 46
- Karma: 5
Thanks for your effort, but onCPayUserStateChange fires too early, way before the tables I need to query are populated. So, I went back to using onCPayAfterPaymentStatusUpdateEvent and worked my checks into the query.
It was a bit fiddly (a lot of trial & error as you said elsewhere ) but now it works the way I need it, I'm happy, and I'm marking this thread solved.
BTW, when using "IF" conditions in any form in an Auto Action of type Query, it causes strange effects, like a field name "slaughtered" and ` changed to '.
Example: the first `cb_field_name` in the code gets turned into `cb_fiel' or similar, causing a syntax error.
So, it might be worth mentioning that instead of "IF" conditions in Auto Action queries one should use "CASE" - which are passing unharmed.
Please Log in or Create an account to join the conversation.
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9109
- Karma: 1434
I've had no issues with IF usages in queries, but depends on your usage I guess. I would not use it to add to the SQL structure, but to condition a string value. Example as follows.
'[cb:if username="demo"]DEMO[/cb:if][cb:if username="admin"]ADMIN[/cb:if]'
All substitutions must be treated as strings for reliable usage.
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.
- lousyfool
- OFFLINE
- Posts: 141
- Thanks: 46
- Karma: 5
krileon wrote: The phpdoc and expected values of onCPayAfterPaymentStatusUpdateEvent are as follows if you need to use it then.
Yup, by now I'm finding my way better around in your code, so I had that figured already before my initial post.
But your posting the reference here may well help others.
krileon wrote: I've had no issues with IF usages in queries, but depends on your usage I guess. I would not use it to add to the SQL structure, but to condition a string value. Example as follows.
'[cb:if username="demo"]DEMO[/cb:if][cb:if username="admin"]ADMIN[/cb:if]'
Maybe you misunderstood, I'm talking the (My)SQL "IF()" function, like e.g. described here: www.w3resource.com/mysql/control-flow-functions/if-function.php
Again, after much trial and error it was clear that's definitely something Auto Action queries don't like, resulting in errors.
Please Log in or Create an account to join the conversation.
- krileon
- ONLINE
- Posts: 68609
- Thanks: 9109
- Karma: 1434
forge.joomlapolis.com/issues/5911
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.