Posted: May 27, 2021 at 11:13 am
Hi there, My support question today is sort of a follow-up on my custom PHP promotion code topic two weeks ago, during which I successfully implemented a little code which creates new promotions every time someone buys a specific type of ticket. Now, I have a custom ticket template which the buyer receives through the messages system for this specific event, which needs to display the aforementioned generated promo code. Now, I want to display this code on the ticket generated by the messages system. What is the simplest way to do this? I would love it if I could simply use the shortcodes available to do the same simple string manipulation I did, but I don’t think it is possible. And I don’t think I can access the EE model system from within the messages either. Could you help me out and point me in the right direction? Thanks! |
|
Hi there, You can always use the model system within EE ๐ If I were doing this, I’d add a custom shortcode and we have some documentation for this here: https://eventespresso.com/wiki/messages-system-how-to-add-custom-message-shortcodes/ An example of adding a shortcode to the EE_Transaction_Shortcodes (because you mentioned the above uses the transaction ID) can be found here: https://gist.github.com/Pebblo/dc011b43b461064a831d The contents of Does that help? |
|
Hi Tony, But if that’s the way, no problem; I’ll start looking into it now. |
|
I’m not sure I follow, how would you run that code and how would the code know where to run in the message system? How would it know what registration is was related to? In short, adding a custom shortcode to do this is the easiest and quickest option for you do it.
Registering the shortcode is not really an issue here, the example function I gave you above gives you pretty much everything you need to register a new EE message shortcode. Set the shortcode you want to add on Line 12. Confirm that you are parsing that same shortcode one line 21. Return whatever you want from within the if statement used to check the correct shortcode (your custom promotion code). Getting the data you need to generate the matching promo is where it’s a little more tricky. What is the code you are using to generate the promotion code? |
|
Hey Tony, I actually managed this pretty easily because the documentation is easy to follow, so all good! Thank you. |
|
Awesome, I’m glad it helped ๐ |
|
The support post ‘Display custom promo code on ticket template’ 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.