Support

Home Forums Event Espresso Premium Customising the shopping cart

Customising the shopping cart

Posted: November 30, 2017 at 10:47 am

Viewing 15 reply threads


drkings1

November 30, 2017 at 10:47 am

Hi there,

I’m sorry if this has been answered elsewhere, but after 15 mins of searching I couldn’t find it.

I’m using EE4 and the Multi-Event module.

I want to do 2 things:

1) Relabel the buttons in the shopping cart
2) Delete one of the buttons that appears when you add an event to the cart (if possible).

https://screencast.com/t/eTaAx7s7HHYV

So with regard to the picture above I would like to relabel the top two buttons and (if possible) delete the View Cart button.

1) I’m not a developer, but it seems to be that changing the labels should be pretty easy (I found what the labels are called by looking in your manual) – I just don’t know where to look to access the code. So – what’s the easiest way for me to access this code in order to change the labels?

2) Is it possible to delete the “view cart” button on this screen? Is it easy to do?

~~

3) I would also like to change the labels on the cart screen itself – see this screenshot:

https://screencast.com/t/I9LWaGEp

Similarly – I can imagine it’s just a matter of editing some text here, but I don’t know (a) where to look to find the text and (b) the easiest way of editing it cleanly and safely.

Can you help please?

many thanks

Daniel


Tony

  • Support Staff

November 30, 2017 at 3:10 pm

Hi Daniel,

You don’t actually edit any of the core code as any edits to the code will be lost on the next update, you would create a Custom Functions Plugin and then code to that to change the text you needed.

Can you let me know the specifics of what you want to change? There are various options but it depends on the exact changes you want to make as to the best solution to use.

In regards to the view cart button, the easiest option is to hide the button using some CSS, for example:

#cart-results-modal-dv #cart-results-view-cart-dv {
    display: none;
}

You can add that to Appearance -> Customize -> Additional CSS

Please refer to this guide for more detailed information about the CSS customizer: https://codex.wordpress.org/CSS#Custom_CSS_in_WordPress


drkings1

November 30, 2017 at 3:34 pm

Hi Tony,

What we want to do is:

1) Hide the “View the Cart” button on the modal – when someone puts an event into the cart.
2) Change the label in the button on the modal: “proceed to registration” to other text (probably something like “Register and Pay”), and also change the “go back to event list” text to other text (probably something like “add another event”).
3) Make button label changes similar to (2) in the Cart itself.

The modal will then just show 2 buttons (but the labels on them will be changed).
The cart will be exactly as it was, but with 2 of the button labels changed.

Does that make sense?


Tony

  • Support Staff

November 30, 2017 at 4:01 pm

Ok, so the first step you need to do is to follow this guide:

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

You will then have a custom functions plugin you can add some functions to on your site.

Then you can use the functions here: https://gist.github.com/Pebblo/385e46712013a3ee5908#file-ee-site-specific-plugin-php-L8-L17

Copy those into your custom functions plugin and edit Line 9 to be:

return 'Add another Event';

Or whatever string you prefer to use.

Then edit line 15 to be:

return 'Register and Pay';

That will change the text for you.

The CSS I provided above will hide the View cart button on the modal.


drkings1

December 1, 2017 at 3:31 am

Thank you Tony.

I have a couple of questions that follow on from what you suggest.

1) I think it’s possible that my previous developer may have already customised the module – how would I know? (Obviously I don’t want to lose any work he’s already done).

2) With regard to altering the button text – I’ve found the relevant strings in the php templates for the MER module. I had imagined it was simply a matter of editing this PHP to alter the text strings. Are you telling me that the customisation route you suggest is more effective than this?

Many thanks again

Daniel


Tony

  • Support Staff

December 1, 2017 at 3:38 am

1) I think it’s possible that my previous developer may have already customised the module – how would I know? (Obviously I don’t want to lose any work he’s already done).

It depends on how the customizations have been done, the above method will not break any previous customizations, but if they’ve edited the template files directly within the plugin itself (like it appears you are suggesting to do) it’s the incorrect method to use as they will be lost when you update the plugin.

We provide various hooks and methods to change the output of EE ‘correctly’ with no need to edit core files.

2) With regard to altering the button text – I’ve found the relevant strings in the php templates for the MER module. I had imagined it was simply a matter of editing this PHP to alter the text strings. Are you telling me that the customisation route you suggest is more effective than this?

Not more effective, but the correct way to edit the output.

Whenever you edit any plugin within WordPress you run into the same problem, its why WordPress is full of hooks:

https://www.smashingmagazine.com/2011/10/definitive-guide-wordpress-hooks/

To allow you to change the output with altering the files itself.

In short, you don’t edit core files, be that WordPress core file or a plugins core files. You use the hooks available within the code to change the output. Editing core files means we can’t provide support and you can’t update.


drkings1

December 1, 2017 at 11:11 am

Hi Tony,

The CSS you created worked a treat for hiding the cart button – thank you!

I’ve created the custom plugin, but I’m having trouble activating it because of what wordpress says is a fatal error. Hopefully you can see where the error has crept in. I can’t understand why there should be one as I’ve simply copied and pasted the functions from the link you gave me.

The error message I’m getting is:

Parse error: syntax error, unexpected ‘function’ (T_FUNCTION), expecting identifier (T_STRING) in /home/presen61/public_html/wp-content/plugins/Presence Training/presencetraining-customisations.php on line 8

Line 8 is the line that starts: “function ee_change_events_list_btn_txt()…”

Here is the complete code for the plugin as it currently stands:

<?php\
/*\
Plugin Name: Site plugin for presencetraining.com\
Description: Site specific code for presencetraining.com\
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
//Filter the ‘Return to Event List’ text.
function ee_change_events_list_btn_txt() {
return ‘Add another Event’;
}
add_filter( ‘FHEE__EED_Multi_Event_Registration__return_to_events_list_btn_txt’, ‘ee_change_return_to_event_list’);
//Filter ‘Proceed to Registration’ text
function ee_change_proceed_to_registration_btn_txt() {
return ‘Register and Pay’;
}
add_filter( ‘FHEE__EED_Multi_Event_Registration__proceed_to_registration_btn_txt’, ‘ee_change_return_to_event_list’);
\
/* Stop Adding Functions */}

~

Many thanks

Daniel


drkings1

December 1, 2017 at 11:13 am

p.s. here is a screenshot of the plugin in the editor so you can see it exactly as it appears:

https://screencast.com/t/elmkIkKX8


Tony

  • Support Staff

December 1, 2017 at 11:37 am

Remove both of these – http://take.ms/P8Nxd

Does it work then?


drkings1

December 1, 2017 at 2:55 pm

Hi Tony,

The short answer is yes, it now runs, so the syntax is OK, but no, it doesn’t relabel the buttons!

I deleted the two slashes, plus one stray curly bracket on line 19 and the plugin was then able to activate.

Here’s how the code looked: https://screencast.com/t/coLeHsdRB

Here’s how the modal looks before activating the plugin:

https://screencast.com/t/Ew4UTvn5iK8

(Note that your custom CSS has successfully removed the cart button).

Here’s how the modal looks after the plugin is activated:

https://screencast.com/t/iC6wyzk9eTp

And this is what the cart looks like:

https://screencast.com/t/bU7z5fyYX

~

So the code as it stands isn’t functioning as intended at all!

Any suggestions?

Warmly

Daniel

~

Just for your ease of viewing here’s the code as it stands right now:

<?php
/*\
Plugin Name: Site plugin for presencetraining.com\
Description: Site specific code for presencetraining.com\
*/
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */
//Filter the ‘Return to Event List’ text.
function ee_change_events_list_btn_txt() {
return ‘Add another Event’;
}
add_filter( ‘FHEE__EED_Multi_Event_Registration__return_to_events_list_btn_txt’, ‘ee_change_return_to_event_list’);
//Filter ‘Proceed to Registration’ text
function ee_change_proceed_to_registration_btn_txt() {
return ‘Register and Pay’;
}
add_filter( ‘FHEE__EED_Multi_Event_Registration__proceed_to_registration_btn_txt’, ‘ee_change_return_to_event_list’);

/* Stop Adding Functions */


Josh

  • Support Staff

December 1, 2017 at 3:20 pm

Hi Daniel,

In order for your code to work, you’ll need to make sure the callback function is bound to the filter hook. Here’s a gist that includes some suggested corrections:

https://gist.github.com/joshfeck/40f5ffc9db451f0872bc92d8dd85e45e

I hope the above makes things a bit clearer.


drkings1

December 3, 2017 at 9:14 am

Hi Josh,

That seems to run better – thank you! (Forgive my lack of understanding as to how php works).

But strangely it’s only renamed one of the buttons (the right hand one) – see here:

https://screencast.com/t/9HqIebM0

I suspect that’s because my developer previously altered something renaming the other one elsewhere and his code is executing after your code. The left hand button is staying called “Return to Course List” (which I don’t think is your standard name for this button and which leads me to think this is his customisation).

Have you any idea where I should look to sort this out please?


Tony

  • Support Staff

December 4, 2017 at 6:20 am

This is one of the problems you run into when users customize core files like you were requesting above, I’m not saying that’s what has actually been done (‘Return to {place holder}’ is valid for that button) but based on your previous replies its possible.

The string used is ‘Return to %s’.

%s is a placeholder for the cart name which by default is ‘Event Cart’, but again is filterable so your developer may have correctly used the filter to change the cart name to ‘Course List’, if so that’s fine.

First, can you put all of the code you are now using onto Pastebin and post the URL for that here (the forum adds formatting to the code so we can’t be 100% sure its correct on the forums).

I’d like to confirm the correct code is in place to change the button.


drkings1

December 4, 2017 at 9:52 am

Hi Tony,

I do understand.

In my defence it was was my developer who made any customisations to the code and not me! (I followed your advice to the letter).

Here’s the link to the code as it currently exists in pastebin:

https://pastebin.com/ATj9pTQi

Thank you for your help in this.

Daniel


Tony

  • Support Staff

December 4, 2017 at 3:16 pm

My apologies, I wasn’t trying to point the finger (which on reading my reply back it does seem to), just highlighting why we are so ‘picky’ about not editing core files at all.

So the code looked fine and I tested it on one of my test sites, without issue – http://take.ms/Y33mc

What you can do is set the priority on your custom function to something really high, for example:


function ee_change_events_list_btn_txt() { // callback function
  return 'Add another Event';
}
add_filter(
  'FHEE__EED_Multi_Event_Registration__return_to_events_list_btn_txt', // filter name
  'ee_change_events_list_btn_txt', // matches callback from line 5
  999 
);
// Filter ‘Proceed to Registration’ text
function ee_change_proceed_to_registration_btn_txt() { // callback function
  return 'Register and Pay';
}
add_filter(
  'FHEE__EED_Multi_Event_Registration__proceed_to_registration_btn_txt',
  'ee_change_proceed_to_registration_btn_txt', // matches callback from line 15
  999 
);

(Note the additional comma at the end of the call back function name and then 999 as the ‘priority)

As long as your other developer hasn’t done the same that should mean your code runs later than his.

Something else to check is for any custom functions for EE within your themes functions.php file, look for anything that has FHEE (filter hook Event Espresso) or AHEE (action hook Event Espresso), add any you fine into a pastebin file and post the url here, we can tell you if they are conflicting.

Or, you developer may have created their own custom functions plugin to hold their functions, check for those.

Failing that it may mean the developer edited the core files which will take a little more digging.


drkings1

December 5, 2017 at 9:42 am

Yes Tony!

That’s done the trick.

I only set one of them to 999 priority as that is the customisation that didn’t appear to be running. The high priority now seems to over-ride whatever change my developer made, wherever he made it.

And I do completely understand why you’re so picky about editing the core files. This demonstrates it perfectly.

Thank you very much for your help on this.

Viewing 15 reply threads

The support post ‘Customising the shopping cart’ 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