Support

Home Forums Event Espresso Premium Need to change Empty Cart Message in EE3

Need to change Empty Cart Message in EE3

Posted: July 6, 2014 at 3:40 am

Viewing 10 reply threads


Randy Joy

July 6, 2014 at 3:40 am

I added a view cart button link to my site navigation. When the cart is empty, the message reads:

It looks like you are attempting to refresh a page after completing your registration or your cart is empty. Please go to the events page and try again.

Where do I go to edit this copy?


Lorenzo Orlando Caum

  • Support Staff

July 6, 2014 at 1:54 pm

Hi Shaun,

That is from a core file: /event-espresso/includes/functions/cart.php

Any edits to core files will be lost so try using a gettext filter instead in your child theme’s functions.php file or a site specific plugin:

function ee_empty_cart_message( $translated, $original, $domain ) {
 
    // This is an array of original strings
    // and what they should be replaced with
    $strings = array(
        'It looks like you are attempting to refresh a page after completing your registration or your cart is empty.  Please go to the events page and try again.' => 'Change the messaging here',
        // Add some more strings here
    );
 
    // See if the current string is in the $strings array
    // If so, replace its translation
    if ( isset( $strings[$original] ) ) {
        // This accomplishes the same thing as __()
        // but without running it through the filter again
        $translations = &get_translations_for_domain( $domain );
        $translated = $translations->translate( $strings[$original] );
    }
 
    return $translated;
}
 
add_filter( 'gettext', 'ee_empty_cart_message', 10, 3 );


Lorenzo


Randy Joy

July 6, 2014 at 2:00 pm

Thank you for the quick reply Lorenzo. Can I drop this into Custom CSS?


Lorenzo Orlando Caum

  • Support Staff

July 6, 2014 at 2:15 pm

Hi Shaun,

Reaktiv CSS Builder or My Custom CSS are for styling. This is actually a PHP code snippet.

You could add it to your child theme’s functions.php file or create a site specific plugin:

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

Let us know if you are able to get this working.

BTW: be sure to change the following sample text in the PHP code snippet.

Change the messaging here


Lorenzo


Randy Joy

July 6, 2014 at 2:20 pm

Makes sense, sorry for not reading your original post more carefully and thank you for the link to creating a plugin. I’ll try this now and let you know if I run into any issues.

Cheers!


Lorenzo Orlando Caum

  • Support Staff

July 6, 2014 at 2:25 pm

No problem. There is a slight learning curve but its worth it so that your customizations are not lost on a software update.

Its also helpful because you’ll know exactly where your edits are should you need to make changes in the future.


Lorenzo


Randy Joy

July 7, 2014 at 11:31 pm

Hi Lorenzo,

Followed the steps you provided and I wasn’t able to get this plugin to work. Here’s the code:

<?php
/*
Plugin Name: Site plugin for ridesmartcotaevents.info
Description: Site specific code for riedsmartcotaevents.info
*/
/* Begin Adding Functions Below This Line */

function ee_empty_cart_message( $translated, $original, $domain ) {

// This is an array of original strings
// and what they should be replaced with
$strings = array(
‘It looks like you are attempting to refresh a page after completing your registration or your cart is empty. Please go to the events page and try again.’ => ‘Cart is empty.’,
// Add some more strings here
);

// See if the current string is in the $strings array
// If so, replace its translation
if ( isset( $strings[$original] ) ) {
// This accomplishes the same thing as __()
// but without running it through the filter again
$translations = &get_translations_for_domain( $domain );
$translated = $translations->translate( $strings[$original] );
}

return $translated;
}

add_filter( ‘gettext’, ‘ee_empty_cart_message’, 10, 3 );

/* Stop Adding Functions */

I have the file permissions set to write / read for user and read for World and permission is set to 604. Hope you can help me find out what I did wrong.

Thanks,

Shaun


Dean

July 8, 2014 at 2:53 am

Hi Shaun,

I also could not get it to work as a plugin, I think there is a load order issue occurring for some reason.

If you create a file called custom_functions.php in the wp-content/uploads/espresso directory, then copy and paste Lorenzos original code to that file, that should work fine.


Randy Joy

July 8, 2014 at 8:36 am

Thanks Dean – I tried what you suggested and still not working. I even removed the new plugin I created in case there was some sort of conflict. Any other suggestions? If not, then is there an old school way of just updating this text. We’re ready to push the site out to customers next Monday, so anxious to get this all buttoned up. Thanks in advance for your help.

Shaun


Lorenzo Orlando Caum

  • Support Staff

July 8, 2014 at 10:30 am

Please give this a try:

https://gist.github.com/lorenzocaum/c29e360427c2b3491b05


Lorenzo


Randy Joy

July 8, 2014 at 11:00 am

Thanks Lorenzo, that did it!

Viewing 10 reply threads

The support post ‘Need to change Empty Cart Message in EE3’ 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.

Event Espresso