- Posts: 14
- Thank you received: 0
Discount prices for children or seniors
- DPaW
- Topic Author
- Offline
- New Member
-
Less
More
10 years 10 months ago - 10 years 10 months ago #63416
by DPaW
Discount prices for children or seniors was created by DPaW
Hi All,
We struggled with this one for a while, but i think we've found a fairly good solution for Multiple ticket prices.
i hope this becomes part of core, as this really is the last piece in making this by far the best event booking system for Joomla!
This method only requires a small template override, and creation of a custom field.
What it does: It creates a dynamic select list based on the number of tickets you have selected, this way, it will apply a discount (set in a custom field) against the total owed.
very simple, very straight forward. it's by no means perfect, and could be made even better, that's where you the Joomdonation community can pitch in.
Note:
- Cannot be used with Shopping cart, works only with group booking.
- I haven't tested with Coupons, discounts, early bird etc but shouldn't be a problem, as we are firstly just offering multiple tier pricing
To-Do: try multiple tiers of discounts like:
Full price
- Child
- Senior
- Set against recurring events (Not a problem if the custom field is set to ALL events)
1) Create a new custom field:
Event: (Align to events you want to apply to)
Field Type: List
Name: number_children
Title: Number of children
Multiple: No
Required: yes
Date type validation: none
Validation rules: validate[required] (this field is automated)
Values: (Value not required here, as we will be building a drop down list based on the number of tickets)
Default values: (not required)
Fee Field: yes
Fee Values: (blank)
Fee Formula: [FIELD_VALUE]*-4
-- Note, This is where I am giving a $4 discount on the normal price (change to whatever you want)
Description: (not required)
Access: Public
Published: Yes
Css Class: (not required)
Size: (not required)
Extra: (not required)
Display in: Group Billing
Fields mapping (not required)
Depend on field: (not required)
2) Event
Price: Add your price (in my case: 16.00 is full price (eventual price for children will be 12)
Registration type: Both individual and Group Registration
3) template override
Copy: components/com_event_booking/register/group_billing.php to:
mytemplate/html/com_event_booking/register/
Edit file: group_billing.php
About Line 34 add
~ Line 114
Modify $fields
Straight after this, add our drop down select field.
This drop down looks at the number of tickets you are buying, and will deduct the chosen number of tickets from the total amount.
Basically, we've created a dynamic variant of the Number of children custom field.
add:
I've attached the file if you want to test, saved in the zip file.
We struggled with this one for a while, but i think we've found a fairly good solution for Multiple ticket prices.
i hope this becomes part of core, as this really is the last piece in making this by far the best event booking system for Joomla!
This method only requires a small template override, and creation of a custom field.
What it does: It creates a dynamic select list based on the number of tickets you have selected, this way, it will apply a discount (set in a custom field) against the total owed.
very simple, very straight forward. it's by no means perfect, and could be made even better, that's where you the Joomdonation community can pitch in.
Note:
- Cannot be used with Shopping cart, works only with group booking.
- I haven't tested with Coupons, discounts, early bird etc but shouldn't be a problem, as we are firstly just offering multiple tier pricing
To-Do: try multiple tiers of discounts like:
Full price
- Child
- Senior
- Set against recurring events (Not a problem if the custom field is set to ALL events)
1) Create a new custom field:
Event: (Align to events you want to apply to)
Field Type: List
Name: number_children
Title: Number of children
Multiple: No
Required: yes
Date type validation: none
Validation rules: validate[required] (this field is automated)
Values: (Value not required here, as we will be building a drop down list based on the number of tickets)
Default values: (not required)
Fee Field: yes
Fee Values: (blank)
Fee Formula: [FIELD_VALUE]*-4
-- Note, This is where I am giving a $4 discount on the normal price (change to whatever you want)
Description: (not required)
Access: Public
Published: Yes
Css Class: (not required)
Size: (not required)
Extra: (not required)
Display in: Group Billing
Fields mapping (not required)
Depend on field: (not required)
2) Event
Price: Add your price (in my case: 16.00 is full price (eventual price for children will be 12)
Registration type: Both individual and Group Registration
3) template override
Copy: components/com_event_booking/register/group_billing.php to:
mytemplate/html/com_event_booking/register/
Edit file: group_billing.php
About Line 34 add
Code:
-- add javascript tag here --
Eb.jQuery(document).ready(function($){
var showcounter;
var select = $("#adminForm input[name=number_children]");
showcounter = $('#eb-form-number-group-members input[name=number_registrants]').val();
for (i = 0; i <= showcounter; i++) {
$("#number_children").append($('<option></option>').val(i).html(i));
}
})
-- end javascript tag here --
~ Line 114
Modify $fields
Code:
-- add open php tag here
}
$fields = $this->form->getFields();
if (isset($fields['state']))
{
$selectedState = $fields['state']->value;
}
$dateFields = array();
foreach ($fields as $field)
// -- Add check to hide number_children from being printed out (as it causes id duplicate problems)
if ($field->name != "number_children") {
//-- */
echo $field->getControlGroup($bootstrapHelper);
if ($field->type == "Date")
{
$dateFields[] = $field->name;
}
// -- Close if loop
}
//-- */
if (($this->totalAmount > 0) || $this->form->containFeeFields())
{
-- Add closing php tag here
Straight after this, add our drop down select field.
This drop down looks at the number of tickets you are buying, and will deduct the chosen number of tickets from the total amount.
Basically, we've created a dynamic variant of the Number of children custom field.
add:
Code:
-- add php open tag here
// Display discount drop down
if (($field->name == "number_children")) :
-- add closing php tag here
<div class="form-group payment-calculation" id="field_number_children">
<div class="col-sm-3 control-label">
<label id="number_children-lbl" for="number_children" class="">Number of children:<span class="star"> *</span></label>
</div>
<div class="col-sm-9">
<select id="number_children" name="number_children" class="validate[required]" onchange="calculateGroupRegistrationFee();"></select>
</div>
</div>
-- add open php tag here
endif;
-- add closing php tag here
I've attached the file if you want to test, saved in the zip file.
Last edit: 10 years 10 months ago by DPaW.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Away
- Administrator
-
10 years 10 months ago #63435
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Discount prices for children or seniors
Thanks for sharing your solution. At the moment, I am quite busy and could not look at it right now. But I will come back to look at your requirement and solution soon and hope to have it implemented in core (maybe with better code) in the future
Thanks again
Tuan
Thanks again
Tuan
The following user(s) said Thank You: DPaW
Please Log in or Create an account to join the conversation.
Moderators: Tuan Pham Ngoc
Support
Documentation
Information
Copyright © 2026 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.