Support

Home Forums Event Espresso Premium Changing 'Cart' to 'Basket'

Changing 'Cart' to 'Basket'

Posted: September 8, 2016 at 8:14 am


deckchairuk

September 8, 2016 at 8:14 am

Hello,

As the site we’re building is mainly UK based, we’d like to change the wording ‘Cart’ to ‘Basket’.

I was just wondering what the best way to do this would be? If there might be a way to globally change it or if I’d have to do it individually, and if so how would I best go about this?

Thanks, Harry.


Lorenzo Orlando Caum

  • Support Staff

September 9, 2016 at 5:42 am

Hi Harry,

Here is an example that can be added to a site specific plugin (https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/) to update the messaging:

https://gist.github.com/joshfeck/ff986f3e848a2b910c47#file-change_mer_cart_name-php

You can change cart in the example to Basket.


Lorenzo


Tony

  • Support Staff

September 9, 2016 at 5:44 am

Hi Harry,

As the site we’re building is mainly UK based, we’d like to change the wording ‘Cart’ to ‘Basket’.

The easiest method to do this is to ‘translate’ the text to whatever you prefer. However you can’t globally change all instances of ‘cart’ in one go, any strings that use ‘cart’ as part of a string need to individually translated.

For example, translating ‘cart’ to basket will not change ‘Event Cart’ to Event Basket as it’s a different string.

Generally within EE we use ‘Event Cart’ so you could translate that to ‘Basket’ and that actually should cover most areas.

To do that you can use a function like the one shown here:

https://eventespresso.com/wiki/how-to-change-wording-with-poedit/#custom-function

Like this: https://gist.github.com/Pebblo/cde9d94c944bd6fc1a1d34d6dccd35c0

You can add that to your themes functions.php file or a Custom Functions Plugin.

It depends which feature you are using if that covers all areas you need, can you link me to the page you want to change so can see?


deckchairuk

September 9, 2016 at 7:43 am

Hey Both,

Thanks for your help, it’s much appreciated 🙂

You’ve given me a few options, is there a ‘best’ method?

The page you can see the basket on is here; http://aerosol.deckchair.co.uk/events/ddl27-2016/ if you scroll down to the ticket selector, choose 1 ticket and put some random details in and select a role you’ll see the popup with the cart link.

If you could let me know the best method, I’ll have a shot at making the change.

Thanks, Harry.


Tony

  • Support Staff

September 9, 2016 at 9:32 am

You’ve given me a few options, is there a ‘best’ method?

They actually both do almost exactly the same thing.

The code that outputs the cart name is this:


EED_Multi_Event_Registration::$event_cart_name = apply_filters(
			'FHEE__EED_Multi_Event_Registration__set_definitions__event_cart_name',
			__( 'Event Cart', 'event_espresso' )
		);

Josh’s example uses the filter, mine uses the translation function that the name is wrapped around – __()

Josh’s example would likely run a little quicker than mine so out of the 2 I’d go with that one an you can still add that to either functions.php or a Custom Functions Plugin.

Any problems just let us know.


deckchairuk

September 12, 2016 at 8:52 am

Hey again,

That’s great, thanks.

I first tried the filter method which worked perfectly. I then realised there were a few things to change and decided to switch to using the translation method instead which is also working perfectly!

One small thing i tried is change ‘items’ to ‘tickets’ but this didn’t translate. I tried adding ‘items’ > ‘tickets’ to the function but to no avail. Is this due to what you were describing before about it being part of the string rather than a whole string so it won’t translate?

Thanks for all your help.

Harry.


Josh

  • Support Staff

September 12, 2016 at 1:07 pm

Hi Harry,

Is this due to what you were describing before about it being part of the string rather than a whole string so it won’t translate?

Yes it is. You will need to translate the entire string.


deckchairuk

September 13, 2016 at 2:18 am

Thought so, that’s a shame.

The problem is I’m looking to translate these;
‘X item/s was successfully added for this event. > x ticket was added to your basket’

‘There is currently X item/s in the Event Cart. > There is currently 1 ticket in your basket’

The problem here is firstly the number changes so I can’t change the whole string and also the plural of items may change.

Am I going to have to leave this of am I able to change it with another method?

Thanks, Harry.


Tony

  • Support Staff

September 13, 2016 at 5:49 am

The problem here is firstly the number changes so I can’t change the whole string and also the plural of items may change.

We account for both of those situations within the translations 🙂

So this time you will need to use the translation although slightly different than the other.

Take a look at this:

https://gist.github.com/Pebblo/40b0ee35ac6841f0153498305ad4888c

Note that filter is separate from the other, you can not just add the strings to the other function.

%1$s is a place holder that dynamically adds the ticket quantity into the string.


deckchairuk

September 13, 2016 at 8:38 am

Perfect!

All has been solved, thanks so much for your time/explanation. The site is due to go live next week so it’s nice to get it all cleaned up before hand.

Thanks, Harry.


Tony

  • Support Staff

September 13, 2016 at 9:56 am

Great 🙂

Any further questions just let us know.

The support post ‘Changing 'Cart' to 'Basket'’ 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