Posted: June 24, 2024 at 12:26 am
Original discussion: https://eventespresso.com/topic/using-ee-shortcodes-outside-of-ee/ Summary. Looking to include a shortcode in a GroundHogg email for “Abandoned Carts” allowed the user to continue with their registration. Event Espresso does appear to provide transaction continuation links with [payment_url], however adding that to an email does not work out of the box. Based on the original forum post this is what I was able to come up with, however it is throwing an error for me when delivering the email function generate_ee_transaction_link_by_user($atts) { // Shortcode attributes, expecting 'user_id' $attributes = shortcode_atts(array( 'user_id' => '', ), $atts); if (empty($attributes['user_id'])) { return 'Error: User ID not provided.'; } global $wpdb; $reg_url_link = $wpdb->get_var($wpdb->prepare( "SELECT REG_code FROM {$wpdb->prefix}esp_registration WHERE ATT_ID = %d AND STS_ID = 'RIC' LIMIT 1", $attributes['user_id'] )); if (empty($reg_url_link)) { return 'Error: No pending transaction found for the provided user.'; } $reg_page_url = EE_Registry::instance()->CFG->core->reg_page_url(); $url = add_query_arg(array( 'e_reg_url_link' => $reg_url_link, 'step' => 'payment_options', 'revisit' => true, 'clear_session' => false, ), $reg_page_url); return esc_url($url); } add_shortcode('ee_pending_transaction_link_by_user', 'generate_ee_transaction_link_by_user'); Inserting the shortcode into the email with
This appears to be properly generating the URL correctly to appear in the email. Example:
However, after visiting that link we are seeing the following errors:
|
|
Hi there, So the issue related to the specific error here is relatively simple, So However, there are also some other issues with what you have here. Something I should note early on is So then when you have this You’re looking for a registration linked to a specific EE Contact ID (ATT_ID) with a STS_ID of I think what you are looking for is an abandoned transaction, which is an EE_Transaction with a status of So presumably you want the ‘last’ abandoned transaction link to a user? What data do you have for that user when generating the email? |
|
That is correct, that would work for our needs. As for what is available, I believe the entire user object should be available or something similar. I was using it in my shortcode like this with the WordPress User ID {contact.user_id} [ee_pending_transaction_link_by_user user_id=”{contact.user_id}”] However, yeah I guess if there is no user_id it doesn’t really make sense. I didn’t use the EE model because I didn’t find it at the time, so I just wrote the SQL I needed, happy to update it to have better code though. |
|
Yeah, but what is — I’ll give you some details, but what/how you use them depends on your setup. If you are using the WP User integration add-on and users are required to log in to start a registration within EE then you can using something like:
To pull in the ATT_ID related to the current user (if indeed there is one). Then just use the Registrations models to pull in the registration linked to a transaction with a status of TAB (I hightly recommend digging into the models, it makes much more complex queries relatively simple to do. If doing anything within EE you cangeneral use the models to get the data quickly and ‘easily’), like so:
This gets more complex when you don’t require login and/or don’t use the WP user integration add-on to sync the ATT_ID to the WP user, you then need to use the data you have available to try and find the correct Attendee (EE_Contact). Which is possible, but can be error prone depending on your setup. But… the models make these queries easier than you would expect. So lets say we only have the email address, we want the same as above but all we have is an email, meaning in English we want ‘The registration linked to an abandoned transaction if its linked to an EE_Contact with the email address of {X}’
(Note we don’t use ATT_ID anymore, we don’t have that in this example) Done. Narrow it down more with more attendee data like first name, last name etc. Oh, and grabbing the
|
|
The support post ‘Using EE Shortcodes outside of Event Espresso’ 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.