Support

Home Forums Event Espresso Premium change default URL for "Return to Event list depending on event-category

change default URL for "Return to Event list depending on event-category

Posted: May 16, 2020 at 7:56 am


efransen

May 16, 2020 at 7:56 am

Hi,
I have read this solution, but I was wondering if I could change the url depending on the parent event-category. When adding this code to the functions.php, the button ‘return to Events lists’ sends me to the domain.com, regardless of the category the event was in.
Does it have to do with the permalinks in anyway?
Any suggestions are welcome. Thanks in advanced!


// change default URL for "Return to Events List"
function ee_mer_change_event_list_url(){
if (has_term( 'courses-seminars', 'espresso_event_categories' ) ){
return 'https://domain.com/courses-seminars/';
} elseif (has_term( 'summerschool', 'espresso_event_categories' ) ) {
return 'https://domain.com/summer-school/';
} else {
return 'https://domain.com/';
}
}

add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url', 'ee_mer_change_event_list_url' );


Tony

  • Support Staff

May 18, 2020 at 5:16 am

Hi there,

It’s not an issue with permalinks, the problem is that when FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url is fired, there is no post, so has_term() has nothing to work with.

The return to event list is displayed in 2 locations, 1 is on the modal when you add the individual events to the cart which I assume is the link you are wanting to change?

That’s done on an ajax request and has the event ID posted, so you can do something like this:

https://gist.github.com/Pebblo/14acf044ca0a4aef2cc417be742f7400

The second location is on the main ‘cart view’, which the above will leave as the default location.


efransen

May 19, 2020 at 2:55 am

Hi there,

The solution works just perfect! Thanks a million.
Almost there I hope… two other -related- questions…

1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?

2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’

Thanks in advanced for the excellent support!


Tony

  • Support Staff

May 19, 2020 at 8:50 am

1. I have placed 2 courses in my cart, one from the category ‘summerschool’ and another from the category ‘courses and seminars’. When looking in my cart through -let’s say- the widget ‘EE Mini cart widget’, there is another button ‘return to events list’ which sends me to the url from ‘event slug’ (EE4 > events > templates > event listing url). Is it possible that the button ‘return to events list’ returns me to the page with the events from the category that I last used or added?

Possible, yes, however we don’t have any examples of how to do it.

You’ll need to dig into the EE_Registry::instance()->SSN->checkout() object to pull the data you need.

2. Is there a way to add a specific sidebar to ‘single-espresso_events.php’ in my child theme, depending on the ‘espresso_event_categories’:
sidebar ‘summer school’ for espresso_event_category ‘summerschool’ and
sidebar ‘courses & seminars’ for espresso_event_category ‘summerschool’

Sure, if you are within single-espresso_events.php you’ll have Post object which means you can pull the current term and include any sidebar you want.

I can’t walk through all of the code to do this so is there a particular part you a stuck on?


efransen

June 3, 2020 at 2:43 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 3:44 am

The site is behind basic auth so I can’t view anything.


efransen

June 3, 2020 at 6:14 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 6:26 am

I haven’t gone through and looked at all of your events, but the first 5 I checked all have ‘Display Ticket Selector’ set to No.

It is expected that Event Espresso will not display the ticket selector when you set that option to no.


efransen

June 3, 2020 at 6:31 am

Hi Tony,
The events in the category ‘summerschool’ all have the ‘display ticket selector’ on yes, and they just don’t show up.


Tony

  • Support Staff

June 3, 2020 at 6:37 am

Is this using your own custom single-espresso_events.php template?

If so, are you calling for the ticket selector within the template and if so, can you post the template so I can take a look?


efransen

June 3, 2020 at 6:56 am

This reply has been marked as private.


Tony

  • Support Staff

June 3, 2020 at 7:31 am

Ok, so within your custom template your not calling any of the EE templates and just using it to change the layout of the page, correct?

Event Espresso injects the event details into the_content call but if you are using a custom template (single-espresso_events.php or archive-espresso_events.php) then it automatically assumes your are taking full control over the output and calling each specific section yourself.

In your template you are not doing that so you can add:

add_filter('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );

to your theme’s functions.php file.

That will tell EE to continue to inject the additional event details even though you are using your own single template.


efransen

June 3, 2020 at 7:59 am

Hi Tony,
The piece of code you suggested to use in the functions.php of the child theme
add_filter('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_true' );was already included on line 13. So I don’t know what my next step should be to show the ticket selector on the single events.


Tony

  • Support Staff

June 3, 2020 at 8:10 am

Apologies, I missed that filter in your functions file.

Something else I missed is the fact that the ticket selector is indeed loading on your single event page, but your hiding it using CSS:

https://monosnap.com/file/x2iXd3NmriMEtCur1CyfAyXMIKDqMK

Line 890 of your child theme’s CSS has .tkt-slctr-tbl-wrap-dv {display:none;}

That is hiding the ticket selector on every page it would display.

You’ll need to remove that and whatever it was in use for will need to use a more specific selector.

Apologies for missing that earlier, templates on the brain I guess.


efransen

June 3, 2020 at 9:13 am

Now it’s my turn to apologize…
It just works perfect now.


efransen

June 3, 2020 at 10:44 am

Another question.
How can I change the url of the button ‘return to events list’?
I have this code already in a custom plugin, but it doesn’t work on the registration checkout page:

//Filter to change the URL for the "Back to List" button from the Multi Event Registration cart. Event Espresso 4 + Multi Event Registration
// Event espresso
// change default URL for "Return to Events List"

function tw_ee_mer_change_event_list_url_from_term($default_event_list){
	// Check if this is an ajax request.
	if (wp_doing_ajax()){
		// Check we have an event id.
		if (!empty($_POST['tkt-slctr-event-id'])) {
			$EVT_ID = absint($_POST['tkt-slctr-event-id']);
			if (has_term( 'courses-seminars', 'espresso_event_categories', $EVT_ID ) ){
				return 'https://url/courses-seminars/';
			} elseif (has_term( 'summerschool', 'espresso_event_categories', $EVT_ID ) ) {
				return 'https://url/summer-school/';
			}
		}
	}
	// Return the default event list url.
	return $default_event_list;
}
add_filter( 'FHEE__EED_Multi_Event_Registration__set_definitions__events_list_url', 'tw_ee_mer_change_event_list_url_from_term' );


efransen

June 3, 2020 at 11:47 am

Problem resolved. Thanks for all the help!

You must be logged in to reply to this support post. Sign In or Register for an Account

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: publish

Updated by  efransen 4 months, 3 weeks ago ago

Topic Tags

Notifications

This topic is: resolved
Do NOT follow this link or you will be banned from the site!
[gravityform id=80 title=false description=false ajax=false]
<div class='gf_browser_unknown gform_wrapper' id='gform_wrapper_80' ><form method='post' enctype='multipart/form-data' id='gform_80' action='/topic/change-default-url-for-return-to-event-list-depending-on-event-category/'> <div class='gform_body'><ul id='gform_fields_80' class='gform_fields top_label form_sublabel_below description_below'><li id='field_80_1' class='gfield gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible' ><label class='gfield_label' for='input_80_1' >First name<span class='gfield_required'>*</span></label><div class='ginput_container ginput_container_text'><input name='input_1' id='input_80_1' type='text' value='' class='medium' aria-required="true" aria-invalid="false" /></div></li><li id='field_80_2' class='gfield gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible' ><label class='gfield_label' for='input_80_2' >Email address<span class='gfield_required'>*</span></label><div class='ginput_container ginput_container_email'> <input name='input_2' id='input_80_2' type='email' value='' class='medium' aria-required="true" aria-invalid="false" /> </div></li><li id='field_80_3' class='gfield gfield_contains_required field_sublabel_below field_description_below gfield_visibility_visible' ><label class='gfield_label' >GDPR Agreement<span class='gfield_required'>*</span></label><div class='ginput_container ginput_container_checkbox'><ul class='gfield_checkbox' id='input_80_3'><li class='gchoice_80_3_1'> <input name='input_3.1' type='checkbox' value='I consent to have this website store my submitted information so they can respond to my inquiry.' id='choice_80_3_1' /> <label for='choice_80_3_1' id='label_80_3_1'>I consent to have this website store my submitted information so they can respond to my inquiry.</label> </li></ul></div></li><li id='field_80_4' class='gfield gform_validation_container field_sublabel_below field_description_below gfield_visibility_visible' ><label class='gfield_label' for='input_80_4' >Email</label><div class='ginput_container'><input name='input_4' id='input_80_4' type='text' value='' autocomplete='off'/></div><div class='gfield_description' id='gfield_description_80_4'>This field is for validation purposes and should be left unchanged.</div></li> </ul></div> <div class='gform_footer top_label'> <input type='submit' id='gform_submit_button_80' class='gform_button button' value='Download Now' onclick='if(window["gf_submitting_80"]){return false;} if( !jQuery("#gform_80")[0].checkValidity || jQuery("#gform_80")[0].checkValidity()){window["gf_submitting_80"]=true;} ' onkeypress='if( event.keyCode == 13 ){ if(window["gf_submitting_80"]){return false;} if( !jQuery("#gform_80")[0].checkValidity || jQuery("#gform_80")[0].checkValidity()){window["gf_submitting_80"]=true;} jQuery("#gform_80").trigger("submit",[true]); }' /> <input type='hidden' class='gform_hidden' name='is_submit_80' value='1' /> <input type='hidden' class='gform_hidden' name='gform_submit' value='80' /> <input type='hidden' class='gform_hidden' name='gform_unique_id' value='' /> <input type='hidden' class='gform_hidden' name='state_80' value='WyJbXSIsIjBiNjdjZjkyMDUzOWUxOWY5Y2NiZjIwMzM4YjA1Mjk4Il0=' /> <input type='hidden' class='gform_hidden' name='gform_target_page_number_80' id='gform_target_page_number_80' value='0' /> <input type='hidden' class='gform_hidden' name='gform_source_page_number_80' id='gform_source_page_number_80' value='1' /> <input type='hidden' name='gform_field_values' value='' /> </div> </form> </div><script type='text/javascript'> jQuery(document).bind('gform_post_render', function(event, formId, currentPage){if(formId == 80) {} } );jQuery(document).bind('gform_post_conditional_logic', function(event, formId, fields, isInit){} );</script><script type='text/javascript'> jQuery(document).ready(function(){jQuery(document).trigger('gform_post_render', [80, 1]) } ); </script>
[i]
[i]