Limit Shared Subscriptions based on user choice

1 year 9 months ago #329959 by krileon

When it comes to 100 licences, I will have to create 100 options (not very convenient)?

Unfortunately yes as at this time we do not provide a free input field for CBSubs Options, but one is planned. I do not have a timeframe for when that will be available, but realistically how many people do you expect to be 100 licenses so it might be best to also consider if you even need to support that many for the time being.

How will I calculate a discount based on the number of licenses? Promotions have "CB Field containing percentage", so where can I set [PLAN_OPTS_OPTION_LICENSES] to relate the promotion (discount) with the number of users?
Tried something like the below using a code field but I suppose I do something wrong

You cannot use plan options substitutions there. They're only available inside of CBSubs when CBSubs substitutions are processed.

How will I relate the limit of Shared subscriptions to [PLAN_OPTS_OPTION_LICENSES] so it allows only as many subscriptions as licences paid ?
Maybe a code field for the limit using with the same logic as the previous one could make it work?

Again, you can't use those substitutions there. As explained above you need to push the number of licenses to your licenses integer field using CBSubs Fields integration then use the your licenses integer field in your code field to calculate the price adjustment as you were already doing.


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: galanopd

Please Log in to join the conversation.

1 year 9 months ago - 1 year 9 months ago #329961 by galanopd
I thought so...

Thank you

EDIT:

This should set the integer field in CBSubs Fields integration usage to 0, 1, 2, or 3 based off the pricing option selected.

I only now realised what you meant and how to implement it and it works very well. Additional users with price increase and relative discounts!

Thank you Kyle!

Please Log in to join the conversation.

1 year 9 months ago - 1 year 9 months ago #329976 by galanopd
I got happy that it works but something is still wrong…
Structure as follows

[cb:if PLAN_OPTS_OPTION_USERLICENSES_P="ver-p-2"]2[cb:elseif PLAN_OPTS_OPTION_USERLICENSES_P="ver-p-3"]3[/cb:elseif][cb:else]1[/cb:else][/cb:if]

a.
$licenses_p = (int) '[cb_lic_qty_p]';
if ( $licenses_p === 2 ) {
 return 3;
}
if ( $licenses_p === 3 ) {
 return 6;
}
return 0;


Now, I think that the reason why I don’t get the proper discount is because of 2b.
Either because there is a substitution syntax error or because int field doesn’t update upon plan option selection.

When I manually set the value of int field cb_lic_qty_p the discount returns correctly (either 3% or 6%).
I need the int field to update when user on subscription tab selects either a renewal plan option or an upgrade plan option, so he pays the correct amount when he clicks renew or upgrade.

Any idea why it doesn't work properly?

EDIT: I have also tried to set an AutoAction like below to update int field before user clicks on "Upgrade" or "Renew" but not luck...
Global
- Access: Everybody
- Type: Field
- Triggers: onCPayAfterPlanRenewalSelected, onCPayAfterPlanSelected, onCPayBeforeDisplaySubscriptionPeriodPrice
Action
- Field: cb_lic_qty_p
- Operator: Set (Field=Value)
- Value:
[cb:if PLAN_OPTS_OPTION_USERLICENSES_P="ver-p-2"]2[cb:elseif PLAN_OPTS_OPTION_USERLICENSES_P="ver-p-3"]3[/cb:elseif][cb:else]1[/cb:else][/cb:if]
-Translate Value: No
- Save directly: Yes
Output
-Display: Return
Attachments:

Please Log in to join the conversation.

1 year 9 months ago #329986 by krileon
As explained in my below reply you need to be using CBSubs Fields integration to set the fields value.

www.joomlapolis.com/forum/255-developer-members-support/245045-limit-shared-subscriptions-based-on-user-choice?start=0#329947

CB Auto Actions does not run content through CBSubs substitutions. Integrations > CB Code Field is for PHP based custom validation rules and has nothing to do with setting a fields value so that also won't work.


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 to join the conversation.

1 year 9 months ago #329988 by galanopd
I am sure you are stating it correctly but I still do not understand what you mean as I don't understand "...you need to be using CBSubs Fields integration...". How do I do that?

Please Log in to join the conversation.

1 year 9 months ago #329990 by krileon
CBSubs Fields is an integration for CBSubs that lets CBSubs change field values based off subscription status. You should find its parameters within your CBSubs plan under Integrations > CB Fields if installed. If not installed please do so. You should then be able to use that substitution there to set a fields value.


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 to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.223 seconds

Facebook Twitter LinkedIn