Posted: June 7, 2021 at 2:17 am
Hey there, This is a follow-up to a previous support thread in which I successfully set up a custom shortcode to be used in the messages (thanks, Tony!). This shortcode actually display a code that was previously generated during checkout which is then used by the buyer to redeem some promotion. I know this is somewhat posible because EE4 can display tickets ID on each ticket within a transaction, but I’m not sure how I can do the same within my own custom shortcode. My shortcode doesn’t need to look for the code and retrieve it from the database, because it’s easy enough that it can build it from the informations it receives from the ticketing generation process, but I would need to be able to iterate over x many tickets were bought and display one on each ticket following this method. Of course, I’m open to suggestions if this isn’t the right way to go about it! Thanks |
|
Hi there, HERE is a quick link to the previous thread for any future readers. If you are using the snippet I gave you in that thread then you are adding a transaction based shortcode. Which means you have access to the Confirm it is indeed an The Or if you are looking to include the info in a specific section of the message template I’ll need to know which section to check what is available there. |
|
Hi Tony, That’s correct; I can successfully get to the array of EE_Registration object; but how do I tell the shortcode that it needs to print array[i] on the first ticket then array[i+1] for any subsequent ticket that was purchased in a single transaction? I’m not sure how the custom shortcode code I’ve written knows every single execution in a transaction needs to be taking place on the next array element. |
|
With a transaction shortcode, it doesn’t (and can’t) know that you want to loop through an array if the shortcode is being processed multiple times. Where in the message template are you including the details? |
|
Ah, this makes sense of course! Still getting my head around EE’s ecosystem. The shortcode is placed within the message template in its own div, so that I can position its output wherever I want with HTML/CSS (on my other thread with the tickets issue, you’ll see it displaying a code which is in fact the promo code). |
|
Should I maybe take a look in the Messages model to find what’s available to me within this context? |
|
Because your using this shortcode within the ticket template and need the value to be unique for each registrant, you can’t use a transaction-based shortcode. Well, technically you could but I wouldn’t. I’d add my shortcode to the This example should help: https://gist.github.com/Pebblo/b8b9b804bcd709c988ad6794f990b4dc |
|
Note that you can pull the EE_Registration object from the It should be something like:
|
|
The support post ‘Custom shortcode in messaging system: series of tickets’ 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.