Skip to Content Skip to Menu

[SOLVED] CB list and advanced sorting with cbsubs

  • activha
  • activha
  • OFFLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 10 months ago - 7 years 10 months ago #289745 by activha
Hello

We would like to make an advanced sorting of a CB list combining cbsubs information.

Our query is :
Code:
( ( SELECT COUNT(*) FROM `#__cbsubs_subscriptions` AS sub WHERE sub.`user_id` = u.`id` AND `expiry_date` < NOW() AND sub.`status` = 'X' ) >= 1 )

and we would like to sort the list by expiry_date.

I have tried different things with no success, indexing with table name did not work neither
Code:
`expiry_date ` DESC or table.`expiry_date ` DESC

Could you help me on this ?

Thanks
Jean
Last edit: 7 years 10 months ago by krileon. Reason: Added [SOLVED] tag to subject

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
7 years 10 months ago #289765 by krileon
Replied by krileon on topic CB list and advanced sorting with cbsubs
Your filter is just a part of the WHERE and isn't a join so you won't be able to do it like that. The below should work.

Code:
( SELECT sub.`expiry_date` FROM `#__cbsubs_subscriptions` AS sub WHERE sub.`user_id` = u.`id` AND `expiry_date` < NOW() AND sub.`status` = 'X' ) DESC


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.

  • activha
  • activha
  • OFFLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 10 months ago #289792 by activha
Replied by activha on topic CB list and advanced sorting with cbsubs
Much better this way, thanks a lot :-)
The following user(s) said Thank You: krileon

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

  • activha
  • activha
  • OFFLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 2 months ago #296771 by activha
Replied by activha on topic CB list and advanced sorting with cbsubs
Hello Kyle

I am coming back on this subject as we have some difficulties with this search.

The intent is to get the list of users who have an expired subscription without any active one for the given plan number.

So if we use
Code:
( SELECT sub.`expiry_date` FROM `#__cbsubs_subscriptions` AS sub WHERE sub.`user_id` = u.`id` AND `expiry_date` < NOW() AND sub.`status` = 'X' ) DESC

we get the expired plans for the users even if they already have renewed it and have an active subscription.

Is it possible to alter it to avoid users who already have a renewed or active subscription ? and how ?

I think it would be great to add more sorting functionalities from cbsubs, for instance to get all users who have expired subscription without any active one right now

Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48547
  • Thanks: 8290
  • Karma: 1445
7 years 2 months ago #296773 by krileon
Replied by krileon on topic CB list and advanced sorting with cbsubs

Is it possible to alter it to avoid users who already have a renewed or active subscription ? and how ?

You'll need to add a subquery to that to make sure they don't have an active subscription since your query is just finding the first expired subscription row for the user and isn't plan specific. You could probably also order by active then by expired so active subscriptions would show first.

I think it would be great to add more sorting functionalities from cbsubs, for instance to get all users who have expired subscription without any active one right now

You can add whatever you want and it'll directly add to the query. If you mean for CBSubs it self to extend the sorting that'll never happen.


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.

  • activha
  • activha
  • OFFLINE
  • Posts: 2334
  • Thanks: 117
  • Karma: 13
7 years 2 months ago #296774 by activha
Replied by activha on topic CB list and advanced sorting with cbsubs

You'll need to add a subquery to that to make sure they don't have an active subscription since your query is just finding the first expired subscription row for the user and isn't plan specific. You could probably also order by active then by expired so active subscriptions would show first.


Thanks, do you mind to provide a working example so that we can use CB List to sort active subscribed members instead of CBsubs then ?

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

Moderators: beatnantkrileon
Powered by Kunena Forum