phpwordpresswoocommercewordpress-theming

WordPress delete checkout button from cart widget


I want to delete the checkout button from the cart widget so that a user has to view their cart first and can only checkout from the cart page.

enter image description here

I am sure I have to delete some code somewhere but not sure where.


Solution

  • There are two ways you can achieve this.

    The first method is to remove the button using the Woocommerce Hook. Add the below code in your functions.php file

      function my_woocommerce_widget_shopping_cart_proceed_to_checkout() 
        {
            return;
        }
        add_action( 'woocommerce_widget_shopping_cart_buttons', 
    
    'my_woocommerce_widget_shopping_cart_proceed_to_checkout', 20 );
    

    Another method is by using the CSS to hide that particular button.

    Add display: none to that specific button by identifying its class.

    .woocommerce-mini-cart__buttons .checkout.wc-forward {display: none !important;}