Posted: 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:
Where do I go to edit this copy? |
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 ); — |
|
|
Thank you for the quick reply Lorenzo. Can I drop this into Custom CSS? |
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 — |
|
|
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! |
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. — |
|
|
Hi Lorenzo, Followed the steps you provided and I wasn’t able to get this plugin to work. Here’s the code:
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 |
|
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. |
|
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 |
Please give this a try: https://gist.github.com/lorenzocaum/c29e360427c2b3491b05 — |
|
|
Thanks Lorenzo, that did it! |
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.