Changing parent plant

6 months 2 weeks ago #328815 by krileon
Replied by krileon on topic Changing parent plant
Probably the easiest way to do that is use CB Code Field. So first create your integer field for them to supply the number of licenses. Next in your code field multiply that by the discount per license. Now you just use that code field as the discount amount in your promotion. Example as follows.

Code:
$licenses = (int) '[cb_licenses]';

if ( $licenses >= 10 ) {
 return 10;
}

if ( $licenses >= 3 ) {
 return 5;
}

return 0;

The above would give a 10% discount if buying 10 or more licenses or a 5% discount if buying 3 or more licenses, but less than 10. Now you'd create the following automatically applied promotion.

Promotion Type: Applies to all purchases
The promotion is: R: A percentage R of the item price from a CB field
CB Field containing percentage: SELECT_CODE_FIELD_HERE

Now during registration and/or profile edit they fill out their licenses field with how many they need.


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.

6 months 2 weeks ago - 6 months 2 weeks ago #328816 by galanopd
Replied by galanopd on topic Changing parent plant
That is excellent, thank you but still the plan price is not increased by the increase of the number of licenses. It only discounts the plan price based on the promotion discount. Unless you mean something like calculating the price of the plan based on the discount rather than keeping the discount constant within the promotion, is that right? (I'm a bit confused) The orange color is what I expect to achieve somehow. Is that possible?

The above it is just an example to explain the structure, not the actual calculations.
Attachments:

Please Log in to join the conversation.

6 months 2 weeks ago - 6 months 2 weeks ago #328825 by krileon
Replied by krileon on topic Changing parent plant
To increase the price you just need to use a negative promotion. So instead of returning 10 you'd return -10. Example as follows.

$licenses = (int) '[cb_licenses]';

if ( $licenses >= 10 ) {
 return -10; // Increase price by 10%
}

if ( $licenses >= 3 ) {
 return -5; // Increase price by 5%
}

return 0; // No price change


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.

6 months 2 weeks ago #328830 by galanopd
Replied by galanopd on topic Changing parent plant
Perfect Kyle,

Thank you!
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

2 months 3 weeks ago - 2 months 3 weeks ago #329906 by galanopd
Replied by galanopd on topic Changing parent plant
One more question on this.

All work fine except that the price of the plan does not increase according to the int userfield. It only applies the discount.
In integrations->Family plans I have set as Limit the int userfield. To my understaning the number of shared users does not increase the price, so how can I make this do so?

EDIT: Sorry, it seems that you have already answered this above. So I suppose I will use the int userfield to increase the price of the plan. That means that there is no option to multiply the number of users by the plan price, correct?

EDIT 2: Unless there is another way, what I 've done so far and it seems to work is something like
$licenses = (int) '[cb_licenses]';

if ( $licenses = 1 ) {
 return 'no price change';
}

if ( $licenses = 2 ) {
 return -100; // Increase price by 100%
}

if ( $licenses = 3 ) {
 return -200; // Increase price by 200%
}

return 0; // No price change

Please Log in to join the conversation.

2 months 3 weeks ago #329915 by krileon
Replied by krileon on topic Changing parent plant

All work fine except that the price of the plan does not increase according to the int userfield. It only applies the discount.
In integrations->Family plans I have set as Limit the int userfield. To my understaning the number of shared users does not increase the price, so how can I make this do so?

That parameter doesn't increase the price, but just limits how many users they can share with.

EDIT: Sorry, it seems that you have already answered this above. So I suppose I will use the int userfield to increase the price of the plan. That means that there is no option to multiply the number of users by the plan price, correct?

cb_licenses can't directly increase the price, no. You need to use a CB Code Field as provided above to calculate the price increase based off the value of cb_licenses. This can even just be simple multiplying math as shown below.

$licenses = (int) '[cb_licenses]';

if ( ( ! $licenses ) || ( $licenses === 1 ) ) {
    return 0; // No price change
}

return -( ( $licenses - 1 ) * 100 ); // Increase price by 100% per additional license 


Note your above PHP was not correct. I've corrected it for you.

$licenses = (int) '[cb_licenses]';

if ( $licenses === 1 ) {
    return 0; // No price change
}

if ( $licenses === 2 ) {
   return -100; // Increase price by 100%
}

if ( $licenses === 3 ) {
   return -200; // Increase price by 200%
}

return 0; // No price change


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.

Moderators: beatnantkrileon
Time to create page: 0.215 seconds

Facebook Twitter LinkedIn