Skip to Content Skip to Menu

Monthly Model using CB Content Module Time Function

  • fede312
  • fede312
  • OFFLINE
  • Posts: 166
  • Thanks: 28
  • Karma: 1
5 years 3 weeks ago #314548 by fede312

Use a CB Query Field and condition against it with an IF substitution.


That sounds like a good idea! What would the IF Substitution have to say in order to condition the 4 lessons within a permission to show up one at the time?

Also. How exactly do I setup the field?

Go to Field Management --> NEW -->
In the Global tab
Type Field: what kind of type field should I choose?
And then on the tab Parameters --> sub-tab Query and paste

SELECT ( `regular_recurrings_used` + 1 ) FROM `jos_cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `plan_id` = 1

Is it something like that?

Thanks again!

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
5 years 3 weeks ago #314553 by krileon

That sounds like a good idea! What would the IF Substitution have to say in order to condition the 4 lessons within a permission to show up one at the time?

It's just a counter so you'd condition against the count. Example as follows.

[cb:if cb_subscount>="4"]I've renewed 4 or more times.[/cb:if]

Replace cb_subscount with whatever the name of your field is.

Also. How exactly do I setup the field?

Ensure CB Query Field is installed then for "Type" select "Query" then under Parameters > Query place the SQL provided in my previous reply with PLAN_ID_HERE replaced by your actual plan id to the "Query" parameter. Verify on their profile it displays the correct number of renewals. If it does you can move it to a tab in a not shown on profile position so it won't actually be visible then start using it in your IF substitutions.


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.

  • fede312
  • fede312
  • OFFLINE
  • Posts: 166
  • Thanks: 28
  • Karma: 1
5 years 3 weeks ago #314568 by fede312

[cb:if cb_subscount>="4"]I've renewed 4 or more times. [/cb:if]


I don't understand how would I use this substitution to show 4 lessons. One every week.

Let's say

[cb:if cb_subscount>="4"]Lesson 1[/cb:if]

How about the other 3 lessons?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
5 years 2 weeks ago #314573 by krileon
If your plan is a month by month plan the counter will increment every month. This fits with your below criteria.

Subscriber Pays. Subscriber gets [month 1] access.
Subscriber Cancels: Subscriber keeps [month 1] access.
Subscriber Renews: Subscriber gets [month 2] access.
Subscription Expires: Subscriber keeps [month 2] access.


This means all you have to do is the following.

[cb:if cb_subscount>="1"]Lesson 1[/cb:if]
[cb:if cb_subscount>="2"]Lesson 2[/cb:if]
[cb:if cb_subscount>="3"]Lesson 3[/cb:if]
[cb:if cb_subscount>="4"]Lesson 4[/cb:if]

This could go on forever in theory as well.


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.

  • fede312
  • fede312
  • OFFLINE
  • Posts: 166
  • Thanks: 28
  • Karma: 1
5 years 2 weeks ago #314576 by fede312

If your plan is a month by month plan the counter will increment every month. This means all you have to do is the following.

[cb:if cb_subscount>="1"]Lesson 1[/cb:if]
[cb:if cb_subscount>="2"]Lesson 2[/cb:if]
[cb:if cb_subscount>="3"]Lesson 3[/cb:if]
[cb:if cb_subscount>="4"]Lesson 4[/cb:if]


If I understand correctly that method will show one new lesson every month.

[cb:if cb_subscount>="1"]Lesson 1[/cb:if] (Month 1)
[cb:if cb_subscount>="2"]Lesson 2[/cb:if] (Month 2)
[cb:if cb_subscount>="3"]Lesson 3[/cb:if] (Month 3)
[cb:if cb_subscount>="4"]Lesson 4[/cb:if] (Month 4)

But I have 4 new lessons every month.

[cb:if cb_subscount>="1"]Lesson 1, Lesson 2, Lesson 3, Lesson 4[/cb:if] (Month 1)
[cb:if cb_subscount>="2"]Lesson 5, Lesson 6, Lesson 7, Lesson 8[/cb:if] (Month 2)
[cb:if cb_subscount>="3"]Lesson 9, Lesson 10, Lesson 11, Lesson 12[/cb:if] (Month 3)
[cb:if cb_subscount>="4"]Lesson 13, Lesson 14, Lesson 15, Lesson 16[/cb:if] (Month 4)

What I want to do is to show one new lesson every week, instead of all 4 lessons all at once.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48438
  • Thanks: 8275
  • Karma: 1443
5 years 2 weeks ago #314594 by krileon
I guess the best way to do that then is count the number of weeks they've been subscribed. You'd do this by diffing the expiration date to the subscription date. This gives you the days between the two. Now divide that by 7 and you've the number of weeks they've subscribed. We want whole weeks rounded down though for accuracy so FLOOR also needs to be applied. This looks like the following in SQL.

Code:
SELECT FLOOR( DATEDIFF(`expiry_date`,`subscription_date`) / 7 ) FROM `jos_cbsubs_subscriptions` WHERE `user_id` = '[user_id]' AND `plan_id` = PLAN_ID_HERE

Next you'd just IF substitution against it like the following.

[cb:if cb_subscount>="1"]Month 1 Week 1[/cb:if]
[cb:if cb_subscount>="2"]Month 1 Week 2[/cb:if]
[cb:if cb_subscount>="3"]Month 1 Week 3[/cb:if]
[cb:if cb_subscount>="4"]Month 1 Week 4[/cb:if]

[cb:if cb_subscount>="5"]Month 2 Week 1[/cb:if]
[cb:if cb_subscount>="6"]Month 3 Week 2[/cb:if]
[cb:if cb_subscount>="7"]Month 4 Week 3[/cb:if]
[cb:if cb_subscount>="8"]Month 5 Week 4[/cb:if]

It should just continue to increment the weeks as they subscribe with 4 weeks per month. Beyond that you'll need to adjust the query to better fit your needs. If you need it significantly more accurate down to the number of days then you'd just remove the divide by 7 and the FLOOR usage and you can condition against the number of days they've subscribed.


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.

Moderators: beatnantkrileon
Powered by Kunena Forum