Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

Cbsubs: How to extract info about plan duration + grace period

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 3 months ago #230587 by dotcom22
hello

I would like setup a CB content module and display conditionnaly a little bit before end of plan duration. Inside this module, I would like display conditionally some text such:

You have again "X" days available before your 30 days trial plan expire

Then if user do not renew his subscription before 30 days, I would like display:

- Your trial plan is now expired. You have a grace period of "Y" days for let you choose the plan who fit your need before auto-disabling your access.

For do that I need to know value related to X and Y but if I'm not wrong no substitution are available for get these info. CB Subscription module is a nice tools but is not very adapted for my case, reason why I would like build my own.

any suggestions please ?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago #230605 by krileon
There's no CBSubs substitution usages outside of CBSubs at this time unfortunately. You can try using CB Query Field and its Query fieldtype to query the database for substitution information such as expiration date then try using it in a substitution IF statement. You'll find a users subscription information in the _cbsubs_subscriptions database table.


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 3 months ago #231090 by dotcom22
I found in the forum this topic

www.joomlapolis.com/forum/153-professional-member-support/193063-solved-delimiter-date-if-statement?limitstart=0#193587


with this nice query field:

SELECT IF( DATEDIFF( `cb_memberexp`, NOW() ) <= 0, 0, 1 ) FROM `#__comprofiler` WHERE `id` = '[user_id]'

This allow to compare plan "expiration date" VS "today date" and return 1 or 0 according situation. I wondering how to modify this query for compare "expiration date less 15 days" VS "today date". My goal is to know if today remain again 15 days or less before expiration date. If yes the field will return 1 otherwise 0, like that I can display conditionally a message such "Your subscription will end in 15 days or less, we suggest to renew now".

Any clue ?

thank

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48466
  • Thanks: 8280
  • Karma: 1443
11 years 3 months ago #231092 by krileon
You can use MySQL functions to subtract from either of the date values before comparing. Example as follows.

Subtract 15 days from Expiration Date:
DATE_SUB( `cb_memberexp`, INTERVAL 15 DAY )

Subtract 15 days from Current Date:
DATE_SUB( NOW(), INTERVAL 15 DAY )

Please see the below MySQL documentation for further date function usage.

dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

Please note `cb_memberexp` is a CB field created within CB > Field Management so it doesn't exist unless you've created it. It also doesn't have their expiration date unless you setup your CBSubs plans to populate it with expiration date. Alternative is to query _subscriptions table for the expiration date directly.


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.

  • dotcom22
  • dotcom22
  • OFFLINE
  • Posts: 522
  • Thanks: 14
  • Karma: 4
11 years 2 months ago - 11 years 2 months ago #232147 by dotcom22
In complement of solution provided in this topic, I found another useful trick. I created a "countdown" query field who display remaining days before plan expiration. Then I created a delimiter field for get the value. Knowing this value, is now easy to use condition for show/hide anything according to remaining days.

For who need to do the same, here the query I use:

SELECT DATEDIFF(`expiry_date`,NOW()) AS days FROM `jos_cbsubs_subscriptions` WHERE `user_id` = '[user_id]';

I use Joomla 3.3.6 - CB 2.0.4 - CBSubs 4 - Several Incubator plugins
Last edit: 11 years 2 months ago by dotcom22.
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