Support

Home Forums Event Espresso Premium Querying ticket purchased in cart

Querying ticket purchased in cart

Posted: September 22, 2019 at 8:46 pm

Viewing 18 reply threads


Patrick

September 22, 2019 at 8:46 pm

Good evening,

After several hours digging into EE4 model structure to find out how to “get” some data during the checkout process, I am seeking some orientations.

I am trying to hide some custom questions in the registration form based on ticket selection.

Would you please help me point in the right direction as of how to get this data (conditional statement) :

1) Does a given ticket (for which I know the ticket ID) is in the cart ?

After reading most of your documentation, it appear there is several ways to achive that :

$ticket_345_purchased = EEM_Registration::instance()->exists(
    array(
        array( 'Ticket.TKT_ID' => 345 )
    )
);

EEM_Ticket::instanceof()...

EE_Registry::instance()->CART->getonebyID('ticket ID')

get_child_line_item();

Or do I have to make a query ? If so, which one ?

Thanks in advance for you guidance.

Cheers.

Patrick Sergerie

  • This topic was modified 5 years ago by Tony. Reason: Code formatting


Josh

  • Support Staff

September 23, 2019 at 12:32 pm

Hi Patrick,

I’m afraid I do not quite understand your question: “1) Does a given ticket (for which I know the ticket ID) is in the cart ?”

That said, if you know your ticket ID and you know the question ID of the question you want hidden for a specific ticket ID, you can use CSS or some similar JavaScript.

For example if a registration for ticket ID 345 must not show registration question ID 13, your CSS would be:

.spco-attendee-ticket-345 .ee-reg-qstn-13-input-dv {
display: none;
}


Patrick

September 23, 2019 at 4:36 pm

Thank you Josh.

For some reasons, that is working for my first ticket only over 3 tickets available for purchase. I can indeed hide any questions using your proposed CSS if the first ticket is in the cart but nothing happen if the other 2 tickets are selected. Does it have anything to do with the fact that the first ticket in my ticket selector is mandatory and the other 2 are not ?

Sorry for asking dumb questions…

Patrick


Josh

  • Support Staff

September 24, 2019 at 7:48 am

Does it have anything to do with the fact that the first ticket in my ticket selector is mandatory and the other 2 are not ?

No that would make no difference to the html classes involving ticket IDs.

The thing to check in this case is you’ll need to make sure you have the ticket IDs correct. Each ticket will have its own ID, and you can find the ticket’s ID by opening the advanced settings for that ticket, in the ticket editor.


Patrick

September 24, 2019 at 8:05 am

I’ve already double check that. Please point me in another direction, it must be something obvious but, for some reasons, ir’s not.


Josh

  • Support Staff

September 24, 2019 at 8:08 am

Hi,

Have you modified any templates in Event Espresso? At this point I can only guess because you’ve provided very little information, so no clear direction can be given in this case.


Patrick

September 24, 2019 at 8:26 am

I modified the Single Event template and some category template. I did not modified the ticket template nor the SPCO template.


Tony

  • Support Staff

September 24, 2019 at 8:29 am

Can you add a link to the event in question so we can add some tickets and view the output/css?


Patrick

September 24, 2019 at 4:43 pm

Hi Tony,

Before going through configuring an access for you on my site, please have a look one last time on the following observation :

I have 2 div sections on the SPCO page :
– id=”spco-attendee-panel-dv-1-db7624165f7af5280f61d66b975496dd” class=”spco-attendee-panel-dv spco-attendee-ticket-906″
– id=”spco-attendee-panel-dv-2-d773d854cdbdf12bc8bd203d93515e95″ class=”spco-attendee-panel-dv spco-attendee-ticket-913″

It is possible to control question’s visibility using :


.spco-attendee-ticket-906 .ee-reg-qstn-34-input-dv {
display: none;
}

but the following has no effect :


.spco-attendee-ticket-913 .ee-reg-qstn-34-input-dv {
display: none;
}

In addition, when using Chrome inspector, registration questions all appear are under panel dv 1. Panel dv 2 is empty. Would that explain something ?


Josh

  • Support Staff

September 24, 2019 at 5:02 pm

It sounds like only one of the tickets gets a registration form. This would be the case if no question groups are selected in the event editor for “Questions for Additional Registrants”.

In other words, if the only ticket that was selected was ticket with ID 913, then the CSS would have an effect.


Patrick

September 24, 2019 at 5:08 pm

Indeed, it is configured that way in the event editor as we do not require additional registrants. All tickets are available to the primary registrant only. We don’t need the additional registrants feature.


Josh

  • Support Staff

September 24, 2019 at 5:14 pm

In that case, you could write some custom jQuery that checks for the presence of a div with this class:

spco-attendee-ticket-913

and if found, then hide the div with this class:

ee-reg-qstn-34-input-dv


Patrick

September 24, 2019 at 5:18 pm

OK, let me try this and I’ll get back to you very soon. I am not expert but I have done quite well up now with PHP and JS. With my event configuration completed at 99%, I will not withdraw at this time !

Thanks again for your patience.


Patrick

September 24, 2019 at 10:24 pm

Hi Josh,

Just to let you know that I did the effort without success and here my final attempt and, without surprise, it’s not working :

function rc_ee_hide_custom_questions_convention() {

wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).ready( function( $ ) {
if ( $("div").hasClass(".spco-attendee-ticket-910") ) {
$(".ee-reg-qstn-34-input-dv").hide();
}
});'
);
}
add_action( 'wp_enqueue_scripts', 'rc_ee_hide_custom_questions_convention', 99 );

After several hours trying to hide a single question on my registration form, I withdraw !!! Please close this topic as a cannot spend more time performing such a basic task.

Thanks anyway for your help to the extend of this forum.

Cheers.

Patrick


Patrick

September 24, 2019 at 10:28 pm

Hi Josh,

I withdraw !

Here is my final attemp to show you, at least, that I did the effort :


function rc_ee_hide_custom_questions_convention() {

wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).ready( function( $ ) {
if ( $("div").hasClass(".spco-attendee-ticket-910") ) {
$(".ee-reg-qstn-34-input-dv").hide();
}
});'
);
}
add_action( 'wp_enqueue_scripts', 'rc_ee_hide_custom_questions_convention', 99 );

Please close this topic as I cannot spend more time on this issue.

Thanks anyway for your help.

Cheers.

Patrick


Patrick

September 24, 2019 at 10:29 pm


function rc_ee_hide_custom_questions_convention() {

wp_add_inline_script(
'single_page_checkout',
'jQuery( document ).ready( function( $ ) {
if ( $("div").hasClass(".spco-attendee-ticket-910") ) {
$(".ee-reg-qstn-34-input-dv").hide();
}
});'
);
}
add_action( 'wp_enqueue_scripts', 'rc_ee_hide_custom_questions_convention', 99 );


Patrick

September 24, 2019 at 10:48 pm

Hi Josh,

I withdraw !

Here is my last attemp to hide a single custom question !!!
`
function rc_ee_hide_custom_questions_convention() {

wp_add_inline_script(
‘single_page_checkout’,
‘jQuery( document ).ready( function( $ ) {
if ( $(“div”).hasClass(“.spco-attendee-ticket-910”) ) {
$(“.ee-reg-qstn-34-input-dv”).hide();
}
});’
);
}
add_action( ‘wp_enqueue_scripts’, ‘rc_ee_hide_custom_questions_convention’, 99 );
`
Please close this topic as I cannot spend more time performing such a basic task.

Thanks again for your support.

Cheers.

Patrick


Josh

  • Support Staff

September 25, 2019 at 12:34 pm

Hi Patrick,

I changed your code to use the find() method and it works:

https://gist.github.com/joshfeck/c553d579962480410be45f51df074144


Patrick

September 25, 2019 at 5:41 pm

Confirmed ! It works !

Thanks for you Platinum Support and your patience !

I am telling you this : should you decide to offer Event Espresso code online structure courses, I’m in…whatever the price ! My event is now all set but I have spent tens and tens of hours (if not hundreds !) figuring out how to make (in my eyes) insignificant changes even if your OOP structure seems quite well organized ! I am sure that with my indermediate skills and a good knowledge of EE code structure, I could set up any event with a professional look !

Thanks again and continue the good work !

Patrick

Viewing 18 reply threads

The support post ‘Querying ticket purchased in cart’ 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