Support

Home Forums Event Espresso Premium ee4 mer add date to title in mini cart

ee4 mer add date to title in mini cart

Posted: August 17, 2020 at 5:34 pm


wayne

August 17, 2020 at 5:34 pm

hi, apologies for multiple posts. The MER table mini cart displays the name of the event but not the date. I am trying to stay away from adding the date to the event title because they are repeated daily. As you can purchase multiple events for different days is there a way to add the date to the line item, i can’t see the date in $line_item object in EE_Mini_Cart_Table_Line_Item_Display_Strategy class

Any pointers will be appreciated.


Tony

  • Support Staff

August 18, 2020 at 10:35 am

Hi Wayne,

The problem with doing this on an event level, is single events can have multiple datetimes and then individual tickets within that event can have access to specific datetimes within that event so outputting an ‘Event Date’ is actually more related to the datetime and ticket than it is the event itself.

Right now we don’t have a hook you can use the event name on the event row, but you can do so on the ticket row using FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name which will allow you to do something like {ticket name} (datetime event start/end) on the ticket row, would that work for you?


wayne

August 18, 2020 at 4:30 pm

This sound perfect Tony, Thanks is there a code snippet for the date? Also, will this then show it across all line items when displayed i.e the minicart and checkout etc?

I’m assuming the event name is passed in the filter but nothing is happening for me – is this the correct approach?

function ee_mer_change_item_name($ticketrowname){
return $ticketrowname.'(date test)';
}

add_filter( 'FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name', 'ee_mer_change_item_name' );


Tony

  • Support Staff

August 19, 2020 at 4:47 am

Also, will this then show it across all line items when displayed i.e the minicart and checkout etc?

No, the filter only applies to the mini cart display strategy.

Let’s get the mini cart working how you want first and I’ll show you how you can apply the same logic elsewhere.

I’m assuming the event name is passed in the filter but nothing is happening for me – is this the correct approach?

Event name? No, that row alters the ticket row, so its the ticket name.

It’s the correct approach but to confirm you are looking in the same location, this is what it should output with your code: https://monosnap.com/file/eHbvw3VXWuMrwVlKVXW26SvzxFyU7L

If you take a look at that filter you’ll see it has this:

apply_filters( 'FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name',
    $line_item_name,
    $line_item
);

Which means it is passed the current line item name in $line_item_name which was created using $line_item->name() and the $line_item object which you can wock with. If you also look at the _ticket_row method that filter sits within you can see how to pull the ticket object from the line item, from there you can pull it’s datetime to output the correct date.

All of the above is done using our model system so if you haven’t done so already take a look here:

https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System

As it makes it really simple to pull the various object that you need.


wayne

August 19, 2020 at 8:04 am

Hi Tony
Thanks again for your support on this. yes the image sent is correct but not what it outputs my end. It just shows the name of the ticket (which is the time) with appending the test string. See http://kickabout.adigitalengagement.co.uk/sessions/technical-centre-free-play-5/

I was using something similar
but this was before I added the MINI cart


function ee_revise_registration_checkout_line_item_desc( $original_description, $line_item, $options ) {

if( $line_item->ticket() instanceof EE_Ticket && $line_item->OBJ_type() !== 'Promotion' ) {
$datetime_dates = array();
foreach( $line_item->ticket()->datetimes() as $datetime ) {
$datetime_names[] = $datetime->get_dtt_display_name(true);
}
return sprintf( __( ' for "%1$s", <br />Date/time: %2$s', 'event_espresso' ),
$line_item->ticket_event_name(),
implode(", ", $datetime_dates )
);
}
return $original_description;
}
add_filter('FHEE__EE_SPCO_Line_Item_Display_Strategy__item_row__desc', 'ee_revise_registration_checkout_line_item_desc', 20, 3);


Tony

  • Support Staff

August 19, 2020 at 8:50 am

Thanks again for your support on this. yes the image sent is correct but not what it outputs my end.

Where are you adding the code on the site?

I was using something similar
but this was before I added the MINI cart

Yeah that’s my snippet from here: https://gist.github.com/Pebblo/2b0433f851e18d6ddd6fb85eca78b440

That’ll work on the Single Page Checkout (SPCO for short) but not on the mini cart widget.


wayne

September 11, 2020 at 4:20 am

Hi Tony – apologies for losing momentum on this – Had a few other things to sort and missed your last reply.

All the snippets are in my functions.php, however it seems some filters are not working. So far, the mini cart shows the time (name of the ticket) which is good but no date (this could simply be the start date of the event).
see

I have also used your snippet https://gist.github.com/Pebblo/2b0433f851e18d6ddd6fb85eca78b440 to add append the date to the line as per your visual here https://monosnap.com/file/skTMJ4JGjhdFoWinXX8Sd1YZ1jART1 but this does not seem to work either which i assume is because its a multi cart check out not single?

you can see the site here if easier http://kickabout.adigitalengagement.co.uk/sessions/technical-centre-free-play-2/ or see attached images
https://freeimage.host/i/2KTwfR
https://freeimage.host/i/2KThiv
https://freeimage.host/i/2KTXWJ

Am I correct in thinking that using the multiple events- i can choose multiple events on separate days? Also if a choose multiple events it only asks for 1 attendee info which in the case of this site (booking a 1 hour football slot by a parent) could have separate details. Is using multiple events the wrong choice for the situation and would be best to remove it?


Tony

  • Support Staff

September 17, 2020 at 5:39 am

All the snippets are in my functions.php, however it seems some filters are not working.

Remove the code from functions.php and place it in a custom functions plugin:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

The code above works as I’m using it on a test site so it could be a load order issue.

you can see the site here if easier http://kickabout.adigitalengagement.co.uk/sessions/technical-centre-free-play-2/ or see attached images
https://freeimage.host/i/2KTwfR
https://freeimage.host/i/2KThiv
https://freeimage.host/i/2KTXWJ

All of those locations have different filters from the mini cart widget and your throwing various snippets into the mix here.

Work through one section and at a time and I’ll show you how to expand that to the others, otherwise, you’ll end up with either incorrect/duplicated code or simply running in circles fighting against your own snippets.

So which section would you like to get working first?
Mini cart?
SPCO attendee information/payment options?
MER cart modal?

What code are you using right now to change the display strategy of the line items? If any.

Am I correct in thinking that using the multiple events- i can choose multiple events on separate days?

Correct, MER allows you to select various tickets from multiple events (or event just the same event, which you can do without MER) and checkout as a single group.

You have multiple tickets within single events, if you only need registrants to select tickets from a single event at a time you could leave MER out of this but it depends what you are doing.

Also if a choose multiple events it only asks for 1 attendee info which in the case of this site (booking a 1 hour football slot by a parent) could have separate details.

Thats based on your events settings and means you are only collecting the Primary Registrant details.

So do you want to only collect a single set of details for the group but want to separate out the parent info and send the email to them? Keeping the registration in the ‘childs’ name?

Is using multiple events the wrong choice for the situation and would be best to remove it?

It really depends on what you want to do.

What’s the goal with your ticket setup?


wayne

September 17, 2020 at 10:18 am

Hi Tony again thanks for your great support.
I would like to get the date in the mini cart first either in the title or in the line item. This image https://freeimage.host/i/2xce4V shows two separate events which are on different days (they all have the same title). Appending the start date to the title would be best but as I recall it is not that simple. The
function ee_mer_change_item_name($line_item_name,
$line_item){
return $line_item_name.'(date test)';
}
and other functions are in a custom functions plugin – using the woo theme customisations plugin and this one is not working.

Should i be using “FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy” instead of “FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name” as I have hard coded the widget in the single_espresso_events.php template using <?php the_widget(‘EEW_Mini_Cart’); ?>

I am comfortable with the attendee settings and will grab all attendees to be COVID safe.

Thanks again


Tony

  • Support Staff

September 18, 2020 at 4:30 am

The code you posted above HERE works fine for my in a custom functions plugin, if it’s not working on your site there is something else going on than the code itself.

This is using that code pretty much as is: https://monosnap.com/file/k6uwrPuLp1NlC2OOXKSgiMO8xP07oM

I’ve altered it to add a space at the beginning but nothing else.

The fact that you’ve mentioned my others snippets not working (which are know good with other users) suggests the code isn’t loading on your site.

This is the exact code I’m using: https://gist.github.com/Pebblo/35b194a7f091dd6346b156f6aa5cd72b

Should i be using “FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy” instead of “FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name” as I have hard coded the widget in the single_espresso_events.php template using

Not unless you want to load your own display strategy class.

FHEE__EEW_Mini_Cart__widget__minicart_line_item_display_strategy allows you to change the display strategy loaded in the widget.

FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name filters the lint item name within the current display strategy. That is the correct filter to use to add the date on the ticket line item.

Hardcoding the widget shouldn’t make any difference, that’s just calling the widget itself, everything else is from within EE itself on an ajax call.


wayne

September 21, 2020 at 10:02 am

Hi Tony – I can’t find any reference to where the apply_filters for “FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name” in any of the plugins in the core, MER, or table template. For some reason, it was not in …display_strategy.php file and hadn’t searched for it beforehand (sorry). I have re-uploaded a fresh EE4 MER and is working – so am now working on getting the start date.


Tony

  • Support Staff

September 21, 2020 at 11:35 am

I can’t find any reference to where the apply_filters for “FHEE__EE_Mini_Cart_Table_Line_Item_Display_Strategy___ticket_row__line_item_name” in any of the plugins in the core, MER, or table template.

It’s in MER, specifically \wp-content\plugins\ee4-mer\EE_Mini_Cart_Table_Line_Item_Display_Strategy.php

Line 147 here: https://github.com/eventespresso/ee4-mer/blob/master/EE_Mini_Cart_Table_Line_Item_Display_Strategy.php#L146-L150

I have re-uploaded a fresh EE4 MER and is working – so am now working on getting the start date.

The gist you linked to above shows you how to pull the datetime fro the ticket:

https://gist.github.com/Pebblo/2b0433f851e18d6ddd6fb85eca78b440

Depends how you want to output the date what you use on the datetime object but that should get you going.


wayne

September 22, 2020 at 4:11 pm

Thanks again Tony – not sure why it wasn’t in my files – anyways sorted for the mini cart. I have also used ‘FHEE__EE_Event_Cart_Line_Item_Display_Strategy___ticket_row__name_and_desc’ to update the description to a similar format in the session cart, however, I cant find a similar filter for the check out section (3 steps) see https://freeimage.host/i/25J5sn. Is there another filter for this?

Again thanks for your continued support.

W


Tony

  • Support Staff

September 23, 2020 at 4:40 am

Yes, for the above you’ll need this filter:

FHEE__EE_Default_Line_Item_Display_Strategy__item_row__name

And possibly:

FHEE__EE_Default_Line_Item_Display_Strategy__item_row__desc

Take a look in \event-espresso-core-reg\core\libraries\line_item_display\EE_Default_Line_Item_Display_Strategy.strategy.php

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  Tony 3 days, 18 hours ago ago

Topic Tags

Tagged: ,

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!