CB Auto Action on use of CBSubs Promotion?

5 years 6 months ago #307675 by cpaschen
Is there any way to update a CB field based on a user using a promotion?

I need to increment a CB field (either by CB Auto Action or by PHP code) whenever a user uses a specific promotion.

I also need to store (in a cb field in their cb profile) the name of the last promotion used.

I'm not sure what trigger that might be or what condition might allow me to check for the use of a promotion.

Is there a 'master list' of all the conditions and/or Triggers yet that would help me figure this out?

Please Log in to join the conversation.

5 years 6 months ago #307686 by krileon
Replied by krileon on topic CB Auto Action on use of CBSubs Promotion?
A basket can have more than 1 coupon applied so the multiple coupons are stored together as part of the promotions_coupons integration parameter of a basket. You'll probably need to use the same trigger as the affiliate tracking integrations for CBSubs, which is onCPayAfterPaymentStatusUpdateEvent and need to check that the payment was completed. Example as follows.

Global
Triggers: onCPayAfterPaymentStatusUpdateEvent
User: Automatic
Access: Everybody
Conditions
1: [var4] Equal To Completed

Then hopefully the below should work for getting the coupon codes applied to the basket.

[var2_integrations_promotions_coupons]

Variables available to that trigger are as follows.

/**
 * Event handler for onCPayAfterPaymentStatusUpdateEvent, called each time an update occurs to the payment status of the payment basket
 *
 * Paypal status mappings:
 * CB Unified status				Paypal status
 * Completed				<--		Completed
 * Processed				<--		Processed, Canceled_Reversal
 * Denied					<--		Denied, Expired, Failed, Voided
 * Refunded					<--		Reversed, Refunded, Partially-Refunded
 * Pending					<--		Pending, In-Progress
 * RegistrationCancelled	<--		A new cb registration got cancelled by user (e.g. paypal cancel payment button)
 *
 * @param  UserTable           $user                   User paying the payment basket
 * @param  cbpaidPaymentBasket $paymentBasket          Payment basket
 * @param  cbpaidSomething[]   $subscriptions          Subscriptions in the basket
 * @param  string              $unifiedStatus          New Unified status (see above)
 * @param  string              $previousUnifiedStatus  Previous Unified status (see above)
 * @param  string              $eventType              type of event (paypal type): 'web_accept', 'subscr_payment', 'subscr_signup', 'subscr_modify', 'subscr_eot', 'subscr_cancel', 'subscr_failed'
 * @return void
 */
public function onCPayAfterPaymentStatusUpdateEvent( &$user, &$paymentBasket, &$subscriptions, $unifiedStatus, $previousUnifiedStatus, $eventType )

If the substitution for the coupons doesn't work you'll need to use a Code action instead of a Field action and code in PHP the coupon check and updating of your field.


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.164 seconds

Facebook Twitter LinkedIn