Skip to Content Skip to Menu

[SOLVED] CB Subs Promotions action after subscription

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 327
  • Thanks: 42
  • Karma: 9
7 years 5 months ago #288632 by cpaschen
Replied by cpaschen on topic CB Subs Promotions action after subscription
Actually, I have found a way to do this easily IF you can just tell me what triggers to use for these two different needs:

#1 - Before the subscription begins
I need to populate a cb field at the beginning of the checkout process (so that I can populate a cb field with the integer to use for the promotions discount)
NOTE: This needs to fire BEFORE the promotions system would go looking for the integer value of the custom cb field.

#2 - After the subscription is done
I need to check the value of that same cb field (after CB Subs promotions subtracts the amount that it used from the integer value).

With knowing the proper triggers to use I'll be able to do this rather easily.

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 68605
  • Thanks: 9108
  • Karma: 1434
7 years 5 months ago #288644 by krileon
Replied by krileon on topic CB Subs Promotions action after subscription
The promotion handles adjusting the field value. So you only need to push the field value back to AUP after the promotion is used. You don't need to know the promotion amount as the field was already adjusted, which makes this much easier to implement. The below should work fine.

Global
Triggers: onCPayAfterPaymentStatusUpdateEvent
User: Automatic
Access: Everybody
Conditions
1: [var4] Is REGEXP /Completed|Processed/

Next you'd just substitute in the points field since it should already be adjusted by this point. This could be a Query action to update AUP or a Code action with PHP method to utilize AUP API.

#1 - Before the subscription begins
I need to populate a cb field at the beginning of the checkout process (so that I can populate a cb field with the integer to use for the promotions discount)
NOTE: This needs to fire BEFORE the promotions system would go looking for the integer value of the custom cb field.

I don't understand why you need to do this if you're already pushing the points from AUP to CB. At any rate the promotions are calculated at time of basket so this has to be done extremely early in the basket creation process. I'm guessing you'd have to use onCPayBeforeComputeTotalizersPaymentBasketUpdated as it needs to be before the totalizers calculate. For that trigger var1 is the basket object and var2 is an array of items in the basket.

#2 - After the subscription is done
I need to check the value of that same cb field (after CB Subs promotions subtracts the amount that it used from the integer value).

Both onCPayAfterPaymentStatusUpdateEvent and onCPayUserStateChange should work fine for this as long as you're checking for completed (status update event) or active (state change) status as CBSubs Promotions will have updated the field by then.


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.

  • cpaschen
  • cpaschen
  • OFFLINE
  • Posts: 327
  • Thanks: 42
  • Karma: 9
7 years 5 months ago #288810 by cpaschen
Replied by cpaschen on topic CB Subs Promotions action after subscription
Well, I thought that the trigger wasn't working, and then wondered if my code wasn't working, then during testing (removing the conditions) I realized that there was a problem with the REGEX.

In case anyone else is trying to do similar, here is what I found...

IF you have the possibility that the coupon amount is more than the value of the cart/basket, then you will need to use the following Condition:

[var4] Is REGEX /Completed|Processed|FreeTrial/

Having the checkout price be Free requires the 'FreeTrial' to be added to the REGEX.

Now all is working just perfectly!

Thanks.
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn