Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

[SOLVED] plan depending of an active user

  • erilam
  • erilam
  • OFFLINE
  • Posts: 787
  • Thanks: 98
  • Karma: 22
12 years 3 weeks ago - 11 years 11 months ago #213805 by erilam
Hello,

I'm working on a project where a promotion can be offer for a member if someone of his familly is already a member (and his subscription is active of course).
So my question is how can I set my registrtion form to check this condition ? I think it will be a great thing if I could insert a field (i.e my parent ID) and if the system check in the database if this member is activ or not.

Is there someone who do that or not ?

Thank you by advance for your answers

PS: here are the subscription plan I want to set :
- enterprise (exclusive),
- association(exclusive),
- private individual(exclusive)
-- family (depends on private individual)

Eric Lamy (erix)
www.agerix.fr/
Last edit: 11 years 11 months ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
12 years 3 weeks ago #213883 by krileon
Replied by krileon on topic Re: plan depending of an active user
I suggest creating a field for them to supply username or user id of the family member. Then use CB Query Field to query the database to see if that username or user id has an active subscription. You could then condition that field in a CBSubs Promotion to give them a discount.


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.

  • erilam
  • erilam
  • OFFLINE
  • Posts: 787
  • Thanks: 98
  • Karma: 22
11 years 11 months ago #216601 by erilam
Replied by erilam on topic Re: plan depending of an active user
Hello,

krileon wrote: I suggest creating a field for them to supply username or user id of the family member.


Done


krileon wrote: Then use CB Query Field to query the database to see if that username or user id has an active subscription.


Done




With this query :
Code:
SELECT a.`id` FROM `ey43k_users` AS a INNER JOIN `ey43k_comprofiler` AS b ON b.`[cb_numaderentparent]` = a.`id` INNER JOIN `ey43k_cbsubs_subscriptions` AS c ON c.`user_id` = b.`[cb_numaderentparent]`,WHERE a.`block` =0 AND b.`confirmed` =1 AND b.`approved` =1 AND b.`banned` =0 AND ( c.`status` = 'A' OR c.`status` = 'R' )

krileon wrote: You could then condition that field in a CBSubs Promotion to give them a discount.


Done but it doesn't wok so here are the sreenshot, may be you will see what is wrong (I hope so) :

FireShot Screen Capture #008.png



Condition tab, timing tab and group tab no settings and


Eric Lamy (erix)
www.agerix.fr/
Attachments:

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
11 years 11 months ago #216622 by krileon
Replied by krileon on topic Re: plan depending of an active user
There's "rn" in your screenshot with your query. Please don't use linebreaks in your query as you could end up with this problem. It also seams the tab or the query plugin isn't published, I only speak English so don't know what that error says specifically when editing the field. Please try the below query.
Code:
SELECT `id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[cb_numaderentparent]' AND `status` IN ( 'A', 'R' )

The above will basically output the subscription id for a user matching the parent field with an active or renewed status.

Once the above is tested working (display it on profile for a user with the parent field correctly set to see if it outputs fine) you'll need to configure your promotion as follows.

Promotion Type: Applies to all purchases
Which plans must be purchased at same time: Your plan
First condition: This condition:
Date A, Field A or Value A: Constant Value or String (CB substitutions can be used)
Value A: [cb:userfield field="YOUR_QUERY_FIELD_NAME" /]
Date B, Field B or Value B: Constant Value or String (CB substitutions can be used)
Value B: 0
Condition 1 (> for Dates): A > B (Value A is larger than Value B)

All other parameters are assumed left default (except promotional amount of course). This should do the trick.


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.
The following user(s) said Thank You: erilam

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

  • erilam
  • erilam
  • OFFLINE
  • Posts: 787
  • Thanks: 98
  • Karma: 22
11 years 11 months ago #216632 by erilam
Replied by erilam on topic Re: plan depending of an active user

krileon wrote: There's "rn" in your screenshot with your query. Please don't use linebreaks in your query as you could end up with this problem. It also seams the tab or the query plugin isn't published, I only speak English so don't know what that error says specifically when editing the field.


The message said that the field wasn't publish, I change. Thx for rn, I was searching why this prefix was there after registration ;)

krileon wrote: Please try the below query.

Code:
SELECT `id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[cb_numaderentparent]' AND `status` IN ( 'A', 'R' )

The above will basically output the subscription id for a user matching the parent field with an active or renewed status.


I change to
Code:
SELECT `user_id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = '[cb_numaderentparent]' AND `status` IN ( 'A', 'R' )

and it works :


krileon wrote: Once the above is tested working (display it on profile for a user with the parent field correctly set to see if it outputs fine) you'll need to configure your promotion as follows.


Promotion Type: Applies to all purchases
Which plans must be purchased at same time: Your plan
First condition: This condition:
Date A, Field A or Value A: Constant Value or String (CB substitutions can be used)
Value A: [cb:userfield field="YOUR_QUERY_FIELD_NAME" /]
Date B, Field B or Value B: Constant Value or String (CB substitutions can be used)
Value B: 0
Condition 1 (> for Dates): A > B (Value A is larger than Value B)

All other parameters are assumed left default (except promotional amount of course). This should do the trick.[/quote]

You're the best it works perfectly !!



You are the best ! ;)

Eric Lamy (erix)
www.agerix.fr/
Attachments:
The following user(s) said Thank You: krileon

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

  • erilam
  • erilam
  • OFFLINE
  • Posts: 787
  • Thanks: 98
  • Karma: 22
11 years 11 months ago #216940 by erilam
Replied by erilam on topic Re: plan depending of an active user
Finaly I don't made enought test... :(

1) First problem

If I write a false number I have the promotion.
In phpmyadmin a query with a false number send empty



and the condition A>B with A empty and B='false number' give the promotion

2) Second problem

If I don't write anything in the B field I always have the promotion. So I set the default value for the B field to 0 and add a condition like this



Maybe the same problem ?

Eric Lamy (erix)
www.agerix.fr/
Attachments:

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

Moderators: beatnantkrileon
Powered by Kunena Forum