• Resolved David Borrink

    (@davidborrink)


    On the Cart Widget, I’d like to change the “View Cart” button to “Continue Shopping”, and have the button link to the main shop page. (We don’t see a need to “view cart” on the widget because you’re already viewing the cart at the moment. To continue shopping or check out would seem to be the next two logical choices).

    I didn’t see any hooks available for cart buttons unless I missed one, so I looked for the template.

    I found mini-cart.php inside of “cart” in the templates folder from the core, then put a copy of it a copy of “cart” in my “woocommerce” folder in my child theme. Here are the original button codes below, lines 84-87…

    <p class="buttons">
    		<a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="button wc-forward"><?php _e( 'View Cart', 'woocommerce' ); ?></a>
    		<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
    	</p>

    I decided to change the “View Cart” text to “Continue Shopping”, and on a guess decided to try wc_get_shop_url() to see if I’d get the url of the shop page in there. So it became…

    <p class="buttons">
    		<a href="<?php echo esc_url( wc_get_shop_url() ); ?>" class="button wc-forward"><?php _e( 'Continue Shopping', 'woocommerce' ); ?></a>
    		<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
    	</p>

    I tested to see if I had a change in my widget, and it did not change from “View Cart” to “Continue Shopping”. So it’s time to ask for your help.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    For available hooks/filters that’s being loaded on any given page/section, have a look at the excellent https://hookr.io/plugin.

    As for the text changes, instead of coding changes you could just localise that to your needs. The easiest way to manage localisations would be through https://www.ads-software.com/plugins/loco-translate/

    Thread Starter David Borrink

    (@davidborrink)

    Interesting plug-in. I’ll have to check that out for other situations. It’s in beta, right? I had my widget bars show up larger when I activated it.

    I did find wc_get_page_id( 'shop' ) in the function reference files on the WC site. I see there is no wc_get_shop_url() function.

    Thread Starter David Borrink

    (@davidborrink)

    My code now uses…

    <p class="buttons">
    		<a href="<?php echo esc_url( wc_get_page_id( 'shop' ) ); ?>" class="button wc-forward"><?php _e( 'Continue Shopping', 'woocommerce' ); ?></a>
    		<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
    	</p>

    … in lines 84-87 in mini-cart.php.

    I uploaded my mini-cart.php files to the “cart” folder inside my “woocommerce” folder inside my child theme folder. No change to the cart widget button text or function.

    Thread Starter David Borrink

    (@davidborrink)

    Okay, my cache was not resetting. It was working, but I’m not getting the full url involved here. The button is linked to the page id of the shop page. Just the number so it’s https://18859. That’s going nowhere. The id number is right, but why is that the only thing that gets passed is the id number and not the full url?

    Thread Starter David Borrink

    (@davidborrink)

    Solved it. The correct function was wc_get_page_permalink() with ‘shop’ put in the (), so my final code is this…

    <p class="buttons">
    		<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="button wc-forward"><?php _e( 'Continue Shopping', 'woocommerce' ); ?></a>
    		<a href="<?php echo esc_url( wc_get_checkout_url() ); ?>" class="button checkout wc-forward"><?php _e( 'Checkout', 'woocommerce' ); ?></a>
    	</p>
    • This reply was modified 7 years, 11 months ago by David Borrink.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘WooCommerce Cart Widget: Change “View Cart” to “Continue Shopping”’ is closed to new replies.