CBSubs Promotion based on quantity of subscriptions

7 years 8 months ago #285425 by kweb
I would like a promotion based on quantity of subscriptions (or total amount of basket).
Example :
If the client take more that 4 subscriptions in the same order, a 10% discount will be appliable.
Is it possible ? I can't find it on forum or manual
Thank you

Regards

Please Log in to join the conversation.

7 years 8 months ago #285427 by krileon
Yes that's doable, but you'll need to write custom SQL for it. You'd use CB Query Field to query the database for their number of active or I guess past active subscriptions then multiply it by the discount you want to offer per plan (e.g. 5% per plan). You'd then substitute in the query field as the discount value in a CBSubs Promotion.


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.

7 years 8 months ago #285436 by kweb
Ok, so I guess subscriptions are saved in the database before the basket are validate ?

Please Log in to join the conversation.

7 years 8 months ago #285440 by krileon
Yes, they're stored in _cbsubs_payment_items. You can query _cbsubs_payment_baskets for their most recent basket then check its ID against rows in _cbsubs_payment_items. The count of rows in _cbsubs_payment_items where their payment_basket_id matches the id column of _cbsubs_payment_baskets is how many plans they've in their basket.

The below query for example should give you the plan count of the users most recent basket. You may want to add more conditions to ensure it hasn't already been paid, etc.. but should be a starting point.

SELECT COUNT(*) FROM `#__cbsubs_payment_items` WHERE `payment_basket_id` = ( SELECT `id` FROM `#__cbsubs_payment_baskets` WHERE `user_id` = '[user_id]' ORDER BY `time_initiated` 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.

7 years 8 months ago #285441 by kweb
ok great, thank you

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.243 seconds

Facebook Twitter LinkedIn