Edting buttons in WooCommerce Mini-Cart in Pro

Hi, I’m using Pro, and I’m attempting to edit the buttons in the off canvas mini cart. Since it isn’t an option in the Header editor, I’m hoping someone can tell me how I can go about editing the actual text of the buttons.

Currently the buttons say “View Cart” and “Checkout”.

I need them to say “View Cart” and “Submit Order”.

I was able to change the “Checkout” button in other areas of the site (e.g. cart & checkout pages), so it’s just the mini cart that’s posing an issue.

Thanks in advance.

Hi There,

Please try adding this custom code on your child theme functions.php file:

remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );


function my_woocommerce_widget_shopping_cart_proceed_to_checkout() {
    echo '<a href="' . esc_url( wc_get_checkout_url() ) . '" class="wc-forward x-anchor"><span class="x-anchor-content" style="-webkit-justify-content: center; justify-content: center; -webkit-align-items: center; align-items: center;"><span class="x-anchor-text"><span class="x-anchor-text-primary">'. esc_html__( 'Submit Order', 'woocommerce' ) .'</span></span></span></a>';
}

add_action( 'woocommerce_widget_shopping_cart_buttons', 'my_woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );

Hope this helps.

1 Like

That worked perfectly.

I know I said that the first button should remain “View Cart”, but I was wondering if there was a similar code to change that to “View Order”.

Hi,

To change it, you can add the code below in your child theme’s functinos.php file.

/*View Cart*/
function sm_text_view_cart_strings( $translated_text, $text, $domain ) {
    switch ( $translated_text ) {
        case 'View Cart' :
            $translated_text = __( 'View Order', '__x__' );
            break;
    }
    return $translated_text;
}
add_filter( 'gettext', 'sm_text_view_cart_strings', 20, 3 );

Hope that helps.

Unfortunately, the translation method did not work. For some reason, the mini-cart seems to pull the label differently than the rest of the Woocommerce pages.

Is there a method similar to the one posted previously by @Lely? I’m not sure what Woocommerce uses to represent the “View Cart” button.

“woocommerce_widget_shopping_cart_proceed_to_checkout” this was the action used for the “Checkout” button within the minicart. Do you know what the action for the “View Cart” button is called?

Its woocommerce_widget_shopping_cart_button_view_cart. See https://github.com/woocommerce/woocommerce/search?utf8=✓&q=woocommerce_widget_shopping_cart_buttons

So in addition to the code given above, you’ll need to add this.

remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_button_view_cart', 10 );

function my_woocommerce_widget_shopping_cart_view_cart() {
    echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="wc-forward x-anchor" target="_blank"><span class="x-anchor-content" style="-webkit-justify-content: center; justify-content: center; -webkit-align-items: center; align-items: center;"><span class="x-anchor-text"><span class="x-anchor-text-primary">'. esc_html__( 'View Order', 'woocommerce' ) .'</span></span></span></a>';
}

add_action( 'woocommerce_widget_shopping_cart_buttons', 'my_woocommerce_widget_shopping_cart_view_cart', 10 );

Further custom development from here would be getting outside the scope of our support. Also, issues arising from the use of custom code and additional enhancements would be outside the scope as well.

We do have an in-house custom development team that offer paid services, who may be able to assist if you have addition customization question. They can be contacted at pinnacle@theme.co if this is of interest to you.

Thank you for your understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.