Posted: 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 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 |
|
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 |
|
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. The modal will then just show 2 buttons (but the labels on them will be changed). Does that make sense? |
|
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:
Or whatever string you prefer to use. Then edit line 15 to be:
That will change the text for you. The CSS I provided above will hide the View cart button on the modal. |
|
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 |
|
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.
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. |
|
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\ ~ Many thanks Daniel |
|
p.s. here is a screenshot of the plugin in the editor so you can see it exactly as it appears: |
|
Remove both of these – http://take.ms/P8Nxd Does it work then? |
|
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 /* Stop Adding Functions */ |
|
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. |
|
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? |
|
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. |
|
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: Thank you for your help in this. Daniel |
|
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:
(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 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. |
|
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. |
|
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.