Posted: December 4, 2018 at 1:06 pm
|
Hi, We just purchase the plugin month ago and would like to do some experiments on how to list tickets and add the ticket to the cart using RPC without using Ticket_Selector. However, when I use add_ticket_to_cart(), I got an error. $cart = EE_Registry::instance()->CART; Please help and thanks |
Hi, May I ask where is $ticket_id set and does it set a valid ticket ID? |
|
|
Hi Josh, Thanks for the reply. it is a valid ticket id. $event = EEM_Event::instance()->get_one_by_ID(4196); Thanks |
That does not show where you’ve set the $ticket_id though. Have you done a An aside: There are a few things to watch out for when getting tickets from an event: You’ll want to avoid deleted tickets, tickets not on sale yet, tickets that are past their sale date, and so on. Since it’s not clear what’s going on from the few lines of code you’ve posted here, maybe what you can do is post the entirety of the code you’re working with into a GitHub gist. Hopefully you already have an account on GitHub. If you do not, it’s free to sign up. Then, once you have an account, you can post a gist on GitHub, then link here. If the code you’re working with is more than a few files, you could upload it to a repository instead. This way we can take a look to get have a better idea of what’s missing and leading up to the resulting NULL value. |
|
|
Thank you, I will post some code on GitHub, and then will ask you again. thank you for the quick support. I am very appreciated. Thanks. |
|
This reply has been marked as private. |
Hi there, Can you recheck that link please, it doesn’t appear to be valid. |
|
Hi, I’m afraid the URL in the link you posted, |
|
|
This reply has been marked as private. |
Ok, thanks. If you put a |
|
|
yes, it is. line 11 or line 16 without if condition is causing the same error. Thanks, |
OK, but what’s displayed with the var_dump()? Is it a valid ticket ID? Also, if you do a var_dump() for $cart, do you get a valid cart object? As an aside, I think you’ll also need to hook into e.g. |
|
|
HI Josh Thank for the reply, it returns Null when I do the var_dump for the $cart. it does return the cart object. however, it just skips the function add_ticket_to_cart(). there is no ticket being added to the cart. Thank and please help. |
Hi, It sounds like a loading issue, where the other required items related to the cart are not available when your AJAX call happens. With that, I’m afraid there isn’t much further I can do to help you with your coding project. I can point you to the Multi Event Registration plugin, that has similar work in it where it adds quantities of tickets to the cart. Have you checked the source of the Multi Event Registration plugin? |
|
The support post ‘Call to a member function add_ticket_to_cart() on null’ 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.