Skip to Content Skip to Menu

Free subscription to underage

8 years 11 months ago #274655 by PresidenteMensaMexico
Free subscription to underage was created by PresidenteMensaMexico
Hi,
I need to offer a free subscription to underage members. I first thought about making it a promotion that would check their birthday and apply it only if they where underage but that requires them to renew their subscription every time it expires.

So I was thinking about a new plan for underage, but how can I specify the expiration date to their 18th birthday?

Thanks for your help

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

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
8 years 11 months ago #274689 by nant
Replied by nant on topic Free subscription to underage

PresidenteMensaMexico wrote: Hi,
I need to offer a free subscription to underage members. I first thought about making it a promotion that would check their birthday and apply it only if they where underage but that requires them to renew their subscription every time it expires.

So I was thinking about a new plan for underage, but how can I specify the expiration date to their 18th birthday?

Thanks for your help


You would have to manipulate the database table after each such subscription.
I guess you could use a CBSubs SQL integration to do this based on some birthday date field.

If you sre SQL savvy you could follow the SQL integrations example of this tutorial (and make needed changes) to accomplish this:

www.joomlapolis.com/support/tutorials/107-use-cases/18405-family-plan-membership-part-1

It is not easy but it is doable.
The following user(s) said Thank You: PresidenteMensaMexico

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

8 years 11 months ago - 8 years 11 months ago #274745 by PresidenteMensaMexico
Replied by PresidenteMensaMexico on topic Free subscription to underage
Awesome, I almost have it, except when I set "cbsubs_subscriptions expiry_date" all subscriptions expiry dates are modified, even a subscription that was unsubscribed when subscribing to the new plan is set to Unsubscribed on "modified date". How can I modify only the child subscription and not the parent one or any other?

Sorry solved it. Added the "WHERE plan id =" part.

Thanks again.
Last edit: 8 years 11 months ago by PresidenteMensaMexico.

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

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
8 years 11 months ago #274775 by nant
Replied by nant on topic Free subscription to underage

PresidenteMensaMexico wrote: Awesome, I almost have it, except when I set "cbsubs_subscriptions expiry_date" all subscriptions expiry dates are modified, even a subscription that was unsubscribed when subscribing to the new plan is set to Unsubscribed on "modified date". How can I modify only the child subscription and not the parent one or any other?

Sorry solved it. Added the "WHERE plan id =" part.

Thanks again.


Great!

Would be awesome to post back summary of your use case and the code/process you used to solve this.

This way others can benefit from your solution.

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

8 years 11 months ago #274856 by PresidenteMensaMexico
Replied by PresidenteMensaMexico on topic Free subscription to underage
Sure
I created a new plan that expires 5 minutes after being activated.
Then in the Integrations tab you go into the SQL actions subtab and this is where you need to configure SQL actions.

The code I used is this:
UPDATE #__cbsubs_subscriptions SET expiry_date = date_add('[cb_mensanacimiento]', interval 18 year) WHERE (plan_id='11' and user_id =[user_id]);

I setup a cb field named cb:mensanacimiento where I save the birthdate when a new user registers. This code sets the expiry date of the plan with id 11 for the current user to their birthdate plus 18 years, (that is legal age in Mexico).

Be careful to include the plan_id and user_id with the WHERE command or else all the values for expiry date of your table will get rewritten for all users and all plans.

You need to post the code both in the Activation and Renewal part of an SQL action for it to work on both cases. Check the radio button to execute internally.

And voila, whenever you assign a new user to this plan, the expiration date of its membership will automatically be rewritten to 18 years after his birthdate.

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

  • nant
  • nant
  • OFFLINE
  • Posts: 12339
  • Thanks: 1467
  • Karma: 877
8 years 11 months ago #274922 by nant
Replied by nant on topic Free subscription to underage

PresidenteMensaMexico wrote: Sure
I created a new plan that expires 5 minutes after being activated.
Then in the Integrations tab you go into the SQL actions subtab and this is where you need to configure SQL actions.

The code I used is this:
UPDATE #__cbsubs_subscriptions SET expiry_date = date_add('[cb_mensanacimiento]', interval 18 year) WHERE (plan_id='11' and user_id =[user_id]);

I setup a cb field named cb:mensanacimiento where I save the birthdate when a new user registers. This code sets the expiry date of the plan with id 11 for the current user to their birthdate plus 18 years, (that is legal age in Mexico).

Be careful to include the plan_id and user_id with the WHERE command or else all the values for expiry date of your table will get rewritten for all users and all plans.

You need to post the code both in the Activation and Renewal part of an SQL action for it to work on both cases. Check the radio button to execute internally.

And voila, whenever you assign a new user to this plan, the expiration date of its membership will automatically be rewritten to 18 years after his birthdate.


Awesome!

Thanks for sharing!
The following user(s) said Thank You: PresidenteMensaMexico

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

Moderators: beatnantkrileon
Powered by Kunena Forum