Support

Home Forums Event Espresso Premium One event, 1 adult and 1 child ticket, multi event asks for information of child

One event, 1 adult and 1 child ticket, multi event asks for information of child

Posted: March 24, 2014 at 4:59 pm


Wim Brouwer

March 24, 2014 at 4:59 pm

I have the multi event addon. I have 1 event with 2 ticket prices for adults and children. When I select 1 adult ticket and 1 child ticket, EE ask for info of adult and also for the child (with a “copy from” option). How can I avoid the questions for the child ticket? I have already set the field extra info for additional reg. set to No info required.


Tony

  • Support Staff

March 25, 2014 at 4:16 am

Hello,

This is a limitation of the Multi Event Registration Add-on in that each ticket type requires Personal information at least once.

We have seen in the past that users have hidden these fields and then used JavaScript to copy over the information from the Primary attendee to work around this limitation.

EE4 allows multiple ticket types to be purchased when providing only one single registrant’s information although this will depend on whether or not you need the functionality of the Add-on’s as EE4 currently does not support them.


Wim Brouwer

March 25, 2014 at 7:20 am

As long as there is no iDeal payment gateway, EE4 is useless in Holland. Everybody pays by iDeal, the solution of all banks in Holland. Pronamic has built a superb plugin for EE3, which works without any problems.

Is there a standard Javascript to make the workaround to copy the info to the second and extra attendees?


Josh

  • Support Staff

March 26, 2014 at 5:24 pm

Hi Wim,

Usually it’s something that they develop custom for their registration form. We provide and support the copy buttons.

This is one example of a custom built JavaScript solution that copies the attendee info:

https://github.com/sidharrell/eventespresso/blob/master/simplify-mer-attendee-page.js


Wim Brouwer

April 3, 2014 at 2:06 pm

Sorry to bother you again, but somehow that script doesn’t seem to copy the info to the other attendees when there are 2 different ticket types. Is that possible, or do I do something wrong?

Many thanks for your kind co-operation this far.


Wim Brouwer

April 9, 2014 at 5:45 pm

Is there anyone who might answer this? see http://www.paleisconcerten.nl/overzicht and fill in some figures and click the button and you know what I mean when I want the copy to other attendees automated in a script.


Tony

  • Support Staff

April 14, 2014 at 1:48 am

Hi Wim,

Event Espresso includes the option to select an attendee you would like to copy the information from http://take.ms/VXsw2

The script Josh provided was to be used as an example, you may need to alter this to to fit your specific registration, although looking at the script it should work.

Where/how did you add that script?


Wim Brouwer

April 14, 2014 at 12:31 pm

I added the script of Josh to the file event-espresso/scripts/espresso_cart_functions.js

I added the lines 2-7 of the script in the top of the file, and the rest I used to overwrite lines 374-419. Is that correct, or should I also delete lines 289-366 ?

At this moment I reinstalled the old script, because it did not work.
I can put it back online if this would help.

The total code of the file is then:
<pre class=”brush: javascript; gutter: true; first-line: 1; highlight: []; html-script: false”>jQuery(document).ready(function() {
jQuery('#event_espresso_checkout_form div.multi-reg-page:not(:first)').css('display', 'none');
jQuery('.copy-all-button-wrapper').parent().parent().css('display', 'none')
jQuery('.event_questions input').change(function() {
jQuery('.copy-all-button').click();
});
// clear firefox and safari cache
jQuery(window).unload( function() {});

if ( ! jQuery('#event_espresso_notifications').hasClass('no-hide') ) {
jQuery('#event_espresso_notifications').hide();
}

jQuery.ajaxSetup({
cache: false,
xhr: function()
{
if (jQuery.browser.msie)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
return new XMLHttpRequest();
}
},
type: "POST",
url: EEGlobals.ajaxurl
});

var EECART = {

progress: function(container){

jQuery(container).html('');
},
add_item : function(params){
var _eecart = this;
_eecart.progress(params.container);
var data = {
action: 'event_espresso_add_item',
regevent_action: "event_espresso_add_item",
item_type : params.item_type,
id: params.id,
name: params.event_name,
direct_to_cart: params.direct_to_cart,
moving_to_cart: params.moving_to_cart,
event_page_id: EEGlobals.event_page_id
};

event_espresso_do_ajax( data, function(r){

params.container.html(r.html);

}) ;

},

delete_item : function(params){

//alert( 'params = ' + params.toSource() );

var _eecart = this;
_eecart.progress(params.loader_container);
var data = {
action: 'event_espresso_delete_item',
item_type : params.item_type,
id: params.id,
name: params.event_name
};

event_espresso_do_ajax( data, function(r){

params.main_container.slideUp('fast', function(){
params.main_container.remove();

}).delay(1500).queue(function() {

});
_eecart.calculate_total();
}) ;

},

calculate_total: function(grand_total){
var _eecart = this;
_eecart.progress(jQuery('#event_total_price'));

if (grand_total){
jQuery('#event_total_price').html(grand_total);
return;
}

var data = "action=event_espresso_calculate_total&" + jQuery("#event_espresso_shopping_cart").serialize();

event_espresso_do_ajax(data,function(r){
jQuery('#event_total_price').html(r.grand_total);
if ( r.msg != undefined && r.msg != '' ) {
jQuery('#event_espresso_notifications').hide().html(r.msg).fadeIn();
} else {
jQuery('#event_espresso_notifications').fadeOut();
}

});

}

};

jQuery('body').on('click', '.ee_add_item_to_cart',function(){

var data = {
item_type: 'event',
id : jQuery(this).attr('id'),
event_name : jQuery(this).attr('title'),
direct_to_cart : jQuery(this).attr('direct_to_cart'),
moving_to_cart : jQuery(this).attr('moving_to_cart'),
container : jQuery(this).parent()

}

EECART.add_item(data);

return false;

});

jQuery('.ee_delete_item_from_cart').on('click',function(){

var data = {
item_type: 'event',
id : jQuery(this).attr('id'),
loader_container: jQuery(this).parent(),
main_container : jQuery(this).parents('.multi_reg_cart_block')

}

EECART.delete_item(data);

return false;

});

jQuery('#event_espresso_refresh_total').click(function(){

EECART.calculate_total()

return false;

});

jQuery('#event_espresso_checkout_form').submit(function(){

var data = "action=event_espresso_update_item&" + jQuery(this).serialize()

//progress(jQuery('#event_total_price'));
/*event_espresso_do_ajax(data,function(r){

//return true;

});
//return false;

/*jQuery(this).validate({

submitHandler: function(form) {
form.submit();
}

});*/
//return false;
});

jQuery('#event_espresso_shopping_cart').submit(function(e){

//var data = "action=event_espresso_calculate_total&" + jQuery(this).serialize()

//progress(jQuery('#event_total_price'));
//event_espresso_do_ajax(data,jQuery('#event_total_price'),'');
//return false;
});

/*
* Constructs qty dropdown
* el= dd that is being processed
* num_options = number of options to create. Corresponds to # of open spaces
**/
function populate_qty_dd(el, num_options){

var temp_val =0;
temp_val = el.val(); // in case there is a selected value, remember

if (temp_val > 0)
num_options = parseInt(temp_val) + parseInt(num_options);

//remove all the <options> and reconstruct
el.children().remove();
//Reconstruch the dd based on avaiable spaces left
for (var i=0;i<=num_options;i++){
jQuery(el).append(
jQuery('<option></option>').val(i).html(i)
);

}
//assign the previously selected value to the newly modified dd
el.val(temp_val);

}

//Couppon codes
jQuery('#event_espresso_shopping_cart :input[id^="price_option-"], .price_id, #event_espresso_coupon_code, #event_espresso_groupon_code').on( 'change', function(){

var me = jQuery(this);
//alert( 'me id = ' + me.attr("id") + "\n" + 'me type = ' + me.prop("type") );

if (me.prop('type') == "select-one"){ //only run the code if a select is modified

//all selects have an id
var id = me.attr("id");
id = id.replace(/\D+/,"");
//maximum attendees in a hidden field in each block
var max_attendees = jQuery('#max_attendees-' + id).val();

var num_selected_attendees = 0;
var open_spaces = 0;

//First, find total value of all selected elements. This is required if more than 2 prices are available for the event
jQuery('#event_espresso_shopping_cart :input[name^="price_id[' + id + ']"]').each(function(){

num_selected_attendees += Number(jQuery(this).val());

});

//find the number of available spaces left
open_spaces = max_attendees – num_selected_attendees;

//loop through each element again and determine the number of options to give in each.
jQuery('#event_espresso_shopping_cart :input[name^="price_id[' + id + ']"]').each(function(){

populate_qty_dd(jQuery(this), open_spaces);

});
}

EECART.calculate_total();

});
jQuery('#event_espresso_continue_registration').click(function(){

/* var data = "action=event_espresso_load_regis_form&" + jQuery('#event_espresso_shopping_cart').serialize()

progress(jQuery('#event_espresso_multi_regis_form'));
event_espresso_do_ajax(data,jQuery('#event_espresso_multi_regis_form'),'');
*/

//return false;
});

jQuery('#event_espresso_confirm_pay').click(function(){

var data = "action=event_espresso_confirm_and_pay&" + jQuery('#event_espresso_shopping_cart').serialize()

progress(jQuery('#temp'));
event_espresso_do_ajax(data,jQuery('#temp'),'');
return false;
});

/*
* Copies info from one section of the form to another. Will help the user so
* they don't have to enter info again.
*/
jQuery('.event_questions input').on( 'change', function() {

var from_attendee_no = '1';

jQuery('.multi_regis_wrapper_attendee-additional .event_form_field :input').each(function(){
// console.log(jQuery(this).attr('id') + ' > ' + jQuery(this).val());
var id = jQuery(this).attr('name').split('[');
var from_event_id = id[1].substring(0, id[1].length -1);
var from_price_id = id[2].substring(0, id[2].length -1);
var val = jQuery(this).val();
var name = jQuery(this).attr('name');
var input_type = jQuery(this).attr('type');

var copy_field_name = name.replace(/(\[\d+\])(\[\d+\])(\[\d+\])/,"[" + from_event_id + "][" + from_price_id + "][" + from_attendee_no + "]");
// alert(copy_field_name);

var copy_from = jQuery(":input[name='" + copy_field_name + "']");
//console.log(jQuery(this).attr('name') + ' > ' + copy_field_name + ' > ' + copy_from.val());

switch (input_type) {

case 'text':
case 'textarea':
jQuery(this).val(copy_from.val());
break;

case 'radio':
case 'checkbox':
if (copy_from.attr('checked') && val == copy_from.val())
jQuery(this).attr("checked", "checked");
break;

default:
jQuery(this).val(copy_from.val());

}
//console.log(jQuery('#multi_regis_form_fields-' + to + " input[name='" + new_name + "']").val());

});

});

//Updated in Event Espresso 3.1.31 to suport Jquery 1.9
function event_espresso_do_ajax(data, callback){
jQuery.ajax({
data: data,
dataType: 'json'
})
.done(function(response, textStatus){
process_response(response, callback);
})
.fail(function(resp) {
//alert('Error.');
})
.complete(function(resp){
//alert('Complete.');
});

}

function process_response(from_server, callback)
{
if (from_server == null){
return false;
}

if (from_server.code == 1)
{
callback(from_server);
}
else
{
callback(null);
}

return;
}

})


Tony

  • Support Staff

April 16, 2014 at 3:02 am

Almost right.

Lines 1-7 need to be placed in the multi-registration_page_display.php template.

So copy event-espresso/templates/multi_registration_page.php and multi_registration_page_display.php to wp-content/uploads/espresso/templates/

Then in that new location add

<script type="text/javascript">
jQuery(document).ready(function() {
	jQuery('#event_espresso_checkout_form div.multi-reg-page:not(:first)').css('display', 'none');
	jQuery('.copy-all-button-wrapper').parent().parent().css('display', 'none')
	jQuery('.event_questions input').change(function() {
		jQuery('.copy-all-button').click();
	});
});
</script>

To the bottom of the page, like this: http://take.ms/e7QMx

That will hide the ‘extra’ fields and call the new function we added to espresso_cart_functions.js every time we change the info.


Wim Brouwer

April 17, 2014 at 6:51 am

Hello Tony, thank you for your kind reply.
I changed the files like this. It works fine if I only choose 2 adult
tickets for event A and 3 adult tickets for event B. But when I add 1
child ticket for event A, the button below gives no response. What am I
missing? See http://www.paleisconcerten/overzicht

I posted the files in github. https://github.com/wibro58/event-espresso.git

Would you please be so kind to check if more than 1 price-type per event doesn’t work?


Wim Brouwer

April 21, 2014 at 7:27 am

I think the problem is that I work with 2 different prices. Is it possible that the new script does not look if the var from_price_id changes? And that therefore the data for price_type 2 don’t get filled?
Just a suggestion and question from someone that can’t write javascript himself…

Thanks for any reply!

Wim


Wim Brouwer

April 22, 2014 at 4:29 am

In the script I see 2 lines of code concerning price_type:
… var from_price_id = id[2].substring(0, id[2].length -1);
… var copy_field_name = name.replace(/(\[\d+\])(\[\d+\])(\[\d+\])/,”[” + from_event_id + “][” + from_price_id + “][” + from_attendee_no + “]”);
// alert(copy_field_name);

What should I change so that also the data are copied to tickets with another price type?

A reply would be more than welcome. Please take a few minutes to check. I would be very grateful if this problem could be solved….


Sidney Harrell

April 23, 2014 at 1:51 pm

I played around with it on your checkout pages, and it looks like the copy from dropdown is not functioning. I would suggest reverting back to the original version and see if the copy from dropdown is functioning. If it is not, then the cause is probably the same reason the customized copy from script is not working.


Wim Brouwer

April 23, 2014 at 5:57 pm

Hello Sidney,

With this suggestion you really helped me out!!! I corrected the espresso_cart_functions.js and now the second price type is no longer a problem with all my normal fields. I am very, very grateful for your comment!!!

However, I have one problem: When I add a REQUIRED field of type radiobutton or checkbox to the question group suddenly the the automatic copy function does not work. If I make it MANDATORY everything works fine. It seems the radiobutton info is not copied to the other attendees. Is this related to your script, or is this another problem?


Sidney Harrell

April 25, 2014 at 9:44 am

I did a little debugging on your checkout page, and it looks like I should have put these lines:

var id = jQuery(this).attr('name').split('[');
var from_event_id = id[1].substring(0, id[1].length -1);
var from_price_id = id[2].substring(0, id[2].length -1);

up under this line:

var from_attendee_no = '1';

otherwise, it’s picking up the event id and price id of the field in the additional attendee form instead of the primary attendee form.


Wim Brouwer

April 28, 2014 at 12:48 pm

That small change in lines really did the trick! I am very, very grateful for your kind co-operation to make this thing work. Without you I would have been lost in the big big script world…..

Now it works like a horse, we say in Holland. Thanks!

The support post ‘One event, 1 adult and 1 child ticket, multi event asks for information of child’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso