Support

Home Forums Multiple Event Registration Add-on Getting Total Amount of Tickets in Cart

Getting Total Amount of Tickets in Cart

Posted: February 9, 2016 at 3:24 pm


espnicholas

February 9, 2016 at 3:24 pm

Hello, I have a shopping cart icon, and I just need to echo out the current total amount of tickets in the cart. How would I access this?

Thanks!


Josh

  • Support Staff

February 9, 2016 at 5:18 pm

Hi there,

This should give you the current count:

EE_Registry::instance()->CART->all_ticket_quantity_count();


espnicholas

February 9, 2016 at 5:28 pm

Hey Josh,

Thanks for the reply. I tried parsing it and I get this back:

Fatal error: Call to a member function all_ticket_quantity_count() on null


Josh

  • Support Staff

February 9, 2016 at 5:39 pm

It will help to know how you tried parsing that. You can see the same code in action if you load up one of the Multi Event Registration cart widgets.


espnicholas

February 9, 2016 at 5:58 pm

When I do a var_dump for the EE_Registry::instance()->CART I get null as a return. Now if I’m in the cart itself I get the proper Return I am looking for. Would this need to be parsed within the loop? I am trying to display the cart on everypage in the header.php


Josh

  • Support Staff

February 9, 2016 at 6:09 pm

Okay, so you need to add this to header.php before you echo that out:

<?php EE_Registry::instance()->load_core( 'Cart' ); ?>


espnicholas

February 9, 2016 at 6:10 pm

Spot on, it works! You’re the man, thanks!

The support post ‘Getting Total Amount of Tickets 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