Skip to Content Skip to Menu

trigger for cb subs promotion

9 years 4 months ago - 9 years 4 months ago #265698 by larleuchem
trigger for cb subs promotion was created by larleuchem
Hello,

I would like to know if there is a possibility to call a small script before a user press the 'apply' promotion button when subscribe a plan.

If there is no way to trigger this event, maybe I could hack the code, but I didn't find where I should do that.

Thanx for your help
Ben
Last edit: 9 years 4 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 4 months ago #265707 by krileon
Replied by krileon on topic trigger for cb subs promotion
CBSubs Promotions acts on onCPayEditBasketIntegration to display the input and button. That same trigger is also used to update the basket price by detecting if a coupon code is in the post data. What specifically are you trying to do?


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.

9 years 4 months ago #265713 by larleuchem
Replied by larleuchem on topic trigger for cb subs promotion
thanx for answering

what I need to do is :

when a user enter a coupon code, I want to check something in the database, and then, do a mysql update (depending the result)


I could do mysql request when the user clik the 'apply' button

Is it possible to do that?

thanx Ben

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48477
  • Thanks: 8281
  • Karma: 1443
9 years 4 months ago #265715 by krileon
Replied by krileon on topic trigger for cb subs promotion
Yes, you'd need to act on the above trigger and check that addcouponcode exists in the post. So for CB Auto Actions your condition would be as follows.

[post_addcouponcode] Is Not Empty

The coupon hasn't been validated at this point though. There's no trigger fired for when a valid coupon code is used.

onCPayAfterPaymentBasketUpdated is also fired when the coupon has successfully changed the basket value, but I don't think there's any information in that trigger for you to know a coupon is what changed the value.


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.

9 years 4 months ago #265718 by larleuchem
Replied by larleuchem on topic trigger for cb subs promotion
thanx it works fine

I've add my code after that :

if ( cbGetParam( $_POST, 'addcouponcode' ) ) {
$couponCode = cbGetParam( $_POST, 'couponcode' );
if ( $couponCode ) {

MY_CODE


thanx again for react so quick
Ben

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

9 years 4 months ago #265865 by larleuchem
Replied by larleuchem on topic trigger for cb subs promotion
hello again,
I have a little problem again about my request.

If I create an account on my website, my php code is executed when applying a promo, and it works fine.

But if I already had subscribed to a plan, and I try to upgrade with a new plan trying to use the promo code, it doesn't work, and tell me something like : this code doesnt exist

But what s wired, is that if I try a second time to use the code, it works OK the second time...

help me , I really don t understand what s happenig. This is the same function that is called when applying a promo code ?
it does not depend on the fact you are subscribing for the 1st time, or update a subscription ?


thanx for support
Ben

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

Moderators: beatnantkrileon
Powered by Kunena Forum