How do I change the shopping cart widget?

Hi! I'm setting up my MarketPress shop and I'm just about ready to launch. The last thing I want to change is a really nitpicky thing on the shopping cart widget. Instead of "Browse Products" I'd like it to say "Go Shopping!" And instead of linking to my Products page, I'd like the link to go to my main store welcome page at http://www.shinyhappyworld.com/store.

I've looked through the forums and I've seen other (more complicated) shopping cart modifications, but nothing this simple. Maybe it's not as simple as I think? Or maybe nobody else needs help with something so simple? Either way - if you can help me out I'd appreciate it.

Thanks,
Wendi

  • Tom Eagles
    • Syntax Hero

    @wendigratz

    Hi Wendi :slight_smile:

    First off it is quite easy if you know how, but that the same with everything. Every plugin we have comes with a language file in .po and .mo formats, what you need to do is get a program called poedit from hereIts quite easy to use.

    Then open up the included .po file and change that string to what you want and export it again and upload it to the site.

    The second one requires you to edit the widgets php code and change the url.

    Cheers

  • wendigratz
    • Design Lord, Child of Thor

    Oh boy. That's not as easy as I had hoped.

    I installed poedit, but I have no idea where to find the .po file you mentioned. I went into Filezilla and found a folder called pomo - but it only had .php files in it.

    On the second question - I found the widgets.php file and searched through it for the url and didn't find any. I also searched for the string [mp_products_link] and didn't find that either. Am I looking in the wrong place?

    Also - if I make these changes to my main files, won't they just get overwritten with the next update? So far everyone's been pretty adamant about making changes by adding to the existing code - not changing the code itself.

    Thanks,
    Wendi

  • Aaron
    • CTO

    The widget output is generated by:
    mp_show_cart('widget');

    Which you can find in the template-functions.php file. You could change the text by editing language files or using our ultimate branding plugin text change feature. The link is hardcode there though. You could filter 'mp_products_link' to make it always return mp_store_link(), but that's a bit technical.

    add_filter('mp_products_link', 'change_store_link', 10, 4);
    function change_store_link($link, $echo, $url, $link_text) {
         return mp_store_link(false, $url, $link_text);
    }

    This might work in functions.php of your theme.

  • wendigratz
    • Design Lord, Child of Thor

    OK. I found the language files and figured out how to use poedit. I changed the string "Browse Products »" to "Go shopping!" then saved the file and used Filezilla to load it back up to the site.

    But nothing changed.

    You didn't say which .po file to change, so I did mp-default.po since I assumed I'm working from the default - and I didn't know what the other file names meant.

    Was that the wrong file? Is there something else I need to do to make the "translation" take effect?

  • wendigratz
    • Design Lord, Child of Thor

    Thanks! I installed the new plugin this morning and changed the text very easily. Now I still need to figure out how to change the link that text goes to. Right now it goes to http://www.shinyhappyworld.com/store/products/

    I want it to go to http://www.shinyhappyworld.com/store

    I'd like to try this (quoted from above)

    You could filter 'mp_products_link' to make it always return mp_store_link(), but that's a bit technical.

    add_filter('mp_products_link', 'change_store_link', 10, 4);
    function change_store_link($link, $echo, $url, $link_text) {
    return mp_store_link(false, $url, $link_text);
    }

    This might work in functions.php of your theme.

    But I want to make sure I understand it.

    I'm running a child theme of TwentyTwelve. I went into Filezilla and found the functions.php folder in the parent theme. I downloaded it. Now do I delete everything in it and replace it with the text snippet you provided? Or do I paste that snippet in to the beginning? Or the end of what's already there? Or am I relacing something that's there? And then when I upload it back up with Filezilla I upload it to the child theme instead of the parent theme?

    Sorry to be kind of a dunce. This is all very new to me. I spent years on Blogger where I just needed to open the html, search for what I wanted to replace (text or link) and replace it and be done. What I have now is much more powerful, but it means learning a whle new set of systems.

    Thanks.

  • wendigratz
    • Design Lord, Child of Thor

    That made it angry. I got this message when I tried to visit the site after the change:

    Fatal error: Cannot redeclare twentytwelve_setup() (previously declared in /home/wendigratz/shinyhappyworld.com/wp-content/themes/twentytwelvejo/functions.php:52) in /home/wendigratz/shinyhappyworld.com/wp-content/themes/twentytwelve/functions.php on line 77

    This is what the end of my functions.php file looked like when I uploaded it.

    }
    add_action( 'customize_preview_init', 'twentytwelve_customize_preview_js' );
    add_filter('mp_products_link', 'change_store_link', 10, 4);
    function change_store_link($link, $echo, $url, $link_text) {
         return mp_store_link(false, $url, $link_text);
    }

    I uploaded it to my child theme folder. Was that wrong?

  • wendigratz
    • Design Lord, Child of Thor

    I don't have a functions.php folder in my child theme. I've made hardly any changes to the parent theme so the child theme file is almost empty. I copied function.php, added your code to the end of it, then uploaded it to the child theme.

    After I got your message I tried adding your code to the end of the regular functions.php and uploaded that - but that got me a different fatal error.

    I also tried adding the code to an otherwise empty functions.php file in my child folder. That just put the text of the code at the top of the home page.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.