Posted: August 3, 2022 at 11:55 am
Hi Tony, Related to this topic I have managed to set up Kint Debugger and I manage to pull out all the information that I need when I run examples like this:
However, I am unable to retrieve the current ATT_ID or any other array values for that matter in my function unless specified statically.
Any advice? |
|
Is going to output a STS_ID through kint. Try:
Now you’ll see a LOT more information like what properties are set and the methods available to pull data.
Can you explain this further, please? Similar situation with this:
Don’t do this all in one go, what if you want more than one detail?
There are ‘getter’ methods for pulling in the email rather than using Is that ATT_ID from the registration you pulled in earlier? Because you can pull the EE_Attendee object directly from the EE_Registration object using our models to make this easier. |
|
Thanks Tony! Let me try it and get back as soon as I can, thanks! |
|
You’re most welcome. Let me know and I’ll help more if needed π |
|
Hi Tony, Thanks for the reply and your suggestions are awesome; To clarify, where are the other ‘getter’ methods in the documentation in the Model system? I’ve scoured through the entire documentation to no avail unfortunately :/
And how may I go about this? Thank you Tony, I’m making great progress! |
|
We don’t have every single method within our models documented which is why I recommend kint. I’ll give you an example of how I use it so you can find various details. A EE_Registration’s link everything together, the contact, the event, the ticket etc. So first lets say we need an EE_Registration with ID 425… this is how I’d get it: https://monosnap.com/file/NNFJz1LjPfxEMx3pZS383XWy6qfoZy Kint gives me a nice readable format, click on the EE_Registration object (never use the + sign, it opens all children… not good with out models as there can be a lot of them, just click on the name to open that level). That gives you a breakdown of the objects properties: https://monosnap.com/file/xFvmU7KNxMZZSTPexlArUQ7dspbCzL What you need, are the available methods, there’s a tab for them: https://monosnap.com/file/ShjjiwwbgMVulx9xAiYcg67oZRvItP The EE_Registration object currently has 197 methods. ‘Getters’ and ‘setters’ are basically just methods used to ‘get’ or ‘set’ something (easy when you put that together π ) So to give an example there is a https://monosnap.com/file/ShKAKoLZaDqrkoV7QmX7IH0UNLDX4h You can go through and find all kinds of methods there and the names are pretty self-explanatory so in this case, if you are looking for get/set methods you are better looking over the method available and finding them by name rather than going through the documentation.
You do the above π What you’ll then find is an https://monosnap.com/file/SX6COxMAAk9wcpFq8pqQEZYZ7OFiHL Honestly, taking the time to learn how the models work will save you so much time if your going to be working with EE and custom code.
At this point you know that
Gives you all kinds of useful info: https://monosnap.com/file/sd54mvv3lJ0dzCrgsZgtyUTBBeE81i 164 methods on an EE_Attendee object, any related to email? lets check. Searching for email gives me 2 methods. email(): https://monosnap.com/file/lxq1QcsjY7RmsMEpmKuNMJJGxl1yCH Returns the attendees email address, that’s basically a getter for email and does It also gives you a setter, set_email(): https://monosnap.com/file/WzZ2XEPjKNVpBBqiLYboKoCYksvEAQ To be honest, you shouldn’t be using that unless you need to change the email address of the attendee through code, which you shouldn’t. But as I’ve mentioned setters I might as well use the example.
Would set the email on that attendee to the value you just passed… thats a setter. Again, you didn’t need to know about So the idea here is to get familiar with the methods available and how the models work. Spending the time to get familiar with them will help you much more than reading the docs for specific methods. There is more than enough info to get you familiar with them in the docs available: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System But playing around with them to find what you need with a little bit of basic knowledge of them, helps π |
|
Roger that Tony! Thank you for such a detailed explanation and examples. I will once again go with this new information and give it a try! Cheers! |
|
You’re most welcome π |
|
Hi Tony, at this juncture I have been working and experimenting with everything and it’s going smoothly; one question though, how do I dynamically select the EEM_Registration object? example:
|
|
I did some tinkering around and found $registration to use as EEM Registration object; Therefore my code ends up as this:
|
|
That’s if you already have the Registration ID, which generally you won’t. There are other ways to get the registrations based on the data you have, but no need for those currently. Most of the hooks within EE related to a registration will pass the current EE_Registration object it is related to (like hook you are using above does π ) Anyway, I’m glad you found a solution. — Just to provide some additional feedback on ‘improving’ your code, I don’t see any sense in doing things like this:
Why are you assigning the registration to another variable with another name? Just use If you really wanted the variable name for the EE_registration to be something different, declare it within the function parameters:
Still not sure why you would need to do that, but that gives you the same thing without an additional variable. Personally, I wouldn’t do this:
But just use the EE_Attendee object directly.
Same with price, you don’t ‘need’ an additional variable:
So you could use:
There’s no real harm in what you have now, just slightly more memory usage (which in this example would be almost nothing). |
|
Thanks Tony for the feedback! Yes I am in total agreement, my intention is to use the code and build upon it further as there are plenty more functions that I can utilize thanks to your resources π I shall refine the code further π Thanks for being awesome! |
|
The support post ‘REST API Payment amount credit/deduct points (cont'd)’ 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.