Checkout minicart link change - by francescodelloro

This topic has 2 replies, 2 voices, and was last updated 4 years, 4 months ago ago by Rose Tyler

  • Avatar: francescodelloro
    francescodelloro
    Participant
    May 4, 2020 at 10:03

    Hello,

    I write for a request. I need to change the checkout button link inside the minicart at the top – the one which opens on hover on the cart icon in the header – changing it from checkout link to cart link.

    I notice that when users click on this button (checkout) they’re redirected to checkout.

    Is there a way to change this via code so that it links to the cart page? We need this because it’s useful for us. Maybe some woocommerce snippet to put in the functions?

    At the moment we hide it via css display:none, we need this change because we put a plugin which opens a popup on the cart (not checkout) page.

    Screenshot: https://ibb.co/vJ0XyrX

    If you could provide me any kind of snippet for it or options in the theme it would be amazing.

    Thanks!

    1 Answer
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    May 4, 2020 at 15:52

    Hello,

    Try to use the next code in functions.php of your child theme:

    add_action('wp', 'etheme_custom_template_hooks', 70);
    
    function etheme_custom_template_hooks() {
    	remove_action( 'woocommerce_widget_shopping_cart_buttons', 'woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
    	add_action( 'woocommerce_widget_shopping_cart_buttons', 'et_woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
    }
    
    function et_woocommerce_widget_shopping_cart_proceed_to_checkout() {
    	echo '<a href="' . esc_url( wc_get_cart_url() ) . '" class="button checkout wc-forward">' . esc_html__( 'Cart', 'woocommerce' ) . '</a>';
    }

    Regards

  • Viewing 2 results - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.