A single user with multiple subscriptions of the same subscription

4 years 11 months ago #312312 by GizaLook
Hi, I have a club with an annual membership, so each member of the club would have an annual subscription, basic stuff.

My problem, a lot of the members are children, under 18 and their parents register, subscribe and pay for these subscriptions on their children's behalf.

Is it possible for one parent to register for their three children's (for instance) subscriptions, with he one set of login details?

So basically you have three children and you as the parent need to buy three subscriptions for your three children, with each of these subscriptions having the childs details, but accessed via the one parent login/registration?

Thanks

Please Log in to join the conversation.

4 years 11 months ago #312314 by krileon

Is it possible for one parent to register for their three children's (for instance) subscriptions, with he one set of login details?

That's basically a family subscription usecase, which we don't cover. The best I can suggest is using either of the below methods to try and force this.

www.joomlapolis.com/documentation/283-cb-paid-subscriptions/tutorials/18405-family-plan-membership-part-1
www.joomlapolis.com/documentation/283-cb-paid-subscriptions/tutorials/18407-purchasing-discount-coupons


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.

4 years 11 months ago #312317 by GizaLook
Thank you for this. Quite a lot involved.

I could probably occomplish what I need with maybe some repeated fields at point of registration, with each section of repeated fields being a child i.e. First name, surname, dob etc, and the subscription price could be (cost * number of repeats).

Does this sound as though it would be do able?

Thanks

Please Log in to join the conversation.

4 years 11 months ago #312325 by GizaLook
Hi, I've extended my registration form to include a repeatable section with the information I need, and as it stand, see attached image, this would work for me.
I don't need each individual to be able to login, just to have their subscription registered via their parents.

Based in the screenshot attached, I'd like the subscription cost for this subscription to be set based on the Licence Type Dropdown. i.e. Adults £20 & Juniors U18 £15

So if we have three repeated sections and each related section has a Junior U18 licence type selected this would be a £45 subscription.

I need a running total of the value coming from the LicenceType field
i.e. 3 X Junior U18 Repeats = £45, 3 X Adult Repeats = £60, 2 X Junior U18, and 1 x Adult Repeats = £50

Thanks
Attachments:

Please Log in to join the conversation.

4 years 11 months ago #312331 by krileon

I could probably occomplish what I need with maybe some repeated fields at point of registration, with each section of repeated fields being a child i.e. First name, surname, dob etc, and the subscription price could be (cost * number of repeats).

Does this sound as though it would be do able?

Yes that would work. You however will need a CB Code Field as well since you'll need to count the repeat rows. The below should work fine for this.

return count( json_decode( '[FIELD_NAME]' ) );

This should cause the CB Code Field to output the number of rows in a field group field. Replace FIELD_NAME with the name of the field group field. Now this just needs to be improved with how much it's going to cost per child. Lets say each child costs $30. Just add to the PHP to multiply it as necessary. Example as follows.

$children = count( json_decode( '[FIELD_NAME]' ) );

if ( ! $children ) {
	return 0;
}

return ( $children * 30 );

This should give you the total child cost. Next just add it as a negative promotion in CBSubs Promotions as a static value with a value of -[FIELD_NAME]. It's important it be negative so it can increase the price and not decrease it.

Based in the screenshot attached, I'd like the subscription cost for this subscription to be set based on the Licence Type Dropdown. i.e. Adults £20 & Juniors U18 £15

So if we have three repeated sections and each related section has a Junior U18 licence type selected this would be a £45 subscription.

I need a running total of the value coming from the LicenceType field
i.e. 3 X Junior U18 Repeats = £45, 3 X Adult Repeats = £60, 2 X Junior U18, and 1 x Adult Repeats = £50

This makes it significantly more complicated. Now you'll need to loop through the JSON data and check against their type so you can adjust the price more accurately. Example as follows.

$adult = 0;
$junior = 0;
$price = 0;

foreach ( json_decode( '[FIELD_NAME]', true ) as $child ) {
	if ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'adult' ) {
		$adult++;
	} elseif ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'junior' ) {
		$junior++;
	}
}

if ( $adult ) {
	$price += ( $adult * 20 );
}

if ( $junior ) {
	$price += ( $junior * 15 );
}

return $price;

This should give you the total price with adult and junior being different prices. Replace FIELD_NAME with the name of your fieldgroup field (e.g. cb_licenses) and replace FIELDGROUP_NAME_FIELDTYPE_NAME with the name of your type select field name (minus cb_) prefixed with the fieldgroup field name (e.g. cb_licenses_type). Now just do the same as instructed above using a negative promotion to increase the price of a plan.

If you need this actually itemized on their basket it gets even more tricky. Now you'll need a negative promotion for adults and a negative promotion for juniors and 2 code fields per type. Something like the below.

Adult Count Code Field (cb_licenses_adults):
$adult = 0;

foreach ( json_decode( '[FIELD_NAME]', true ) as $child ) {
	if ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'adult' ) {
		$adult++;
	}
}

return $adult;

Adult Price Code Field (cb_licenses_adults_price):
$adult = 0;

foreach ( json_decode( '[FIELD_NAME]', true ) as $child ) {
	if ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'adult' ) {
		$adult++;
	}
}

if ( ! $adult ) {
	return 0;
}

return ( $adult * 20 );

Junior Count Code Field (cb_licenses_juniors):
$junior = 0;

foreach ( json_decode( '[FIELD_NAME]', true ) as $child ) {
	if ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'junior' ) {
		$junior++;
	}
}

return $junior;

Junior Price Code Field (cb_licenses_juniors_price):
$junior = 0;

foreach ( json_decode( '[FIELD_NAME]', true ) as $child ) {
	if ( $child['FIELDGROUP_NAME_FIELDTYPE_NAME'] == 'junior' ) {
		$junior++;
	}
}

if ( ! $junior ) {
	return 0;
}

return ( $junior * 15 );

Now in your adult promotion you can use substitutions in the name of a promotion. So you'd have a promotion with a name of "Adults x[cb_licenses_adults]" and a fixed discount of -[cb_licenses_adults_price]. You should now have a plan that dynamically changes its price based off the number of children/adults they provide.


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.

4 years 11 months ago #312343 by GizaLook
Excellent, thank you for your help with this.

I need will need to upgrade my MYSQL Version before implementing. I'll get this put in place today.
:-)

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.212 seconds

Facebook Twitter LinkedIn