Woocommerce checkout page: remove view cart button & other messages

First, I’m a bit of a noob. I’m not a web developer/programmer. But I’m also not an idiot and have played with functions.php (just a little bit).

here is the page:

Read More

https://tefl-online-course.com/checkout-lp/?add-to-cart=228

When users click on a link on my Landing Page it adds the product to the cart automatically and takes them to the checkout page.

Now, I would like to do the following.

  1. Remove/hide the “View Cart” button. This is the most important…I don’t want people leaving this checkout page.

  2. I wouldn’t mind removing all of the messages: a. successfully added to cart. b. returning customer & c. have a coupon but not hugely important.

Related posts

Leave a Reply

4 comments

  1. For the add to cart message :

    add_action( 'woocommerce_init', 'remove_message_after_add_to_cart', 99);
    
    function remove_message_after_add_to_cart(){
        if( isset( $_GET['add-to-cart'] ) ){
            wc_clear_notices();
        }
    }
    

    For coupon and return customer , just disabled them on woocommerce options page

    EDIT : Fix for lastest version (2.4.6)

  2. In latest version of woocommerce there is two ways:

    You can hide from css or inside the woocommerce/include/wc-template-functions

    function remove_loop_button(){
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
    }
    add_action('init','remove_loop_button');
    

    From product page and single page both buttons will be remove immediately.

    Thanks,
    Tripathi

  3. Another way to hide the “View Cart” button is to add a “display:none” in the style.css of your child theme

    Try the following :

    .added_to_cart .wc-forward{
        display: none !important;
    }
    

    or

    a.added_to_cart{
        display: none !important;
    }
    
  4. Add this CSS in your wp-admin -> appearance -> customize -> custom css :

    p.woocommerce-mini-cart__buttons.buttons a.button.wc-forward:first-child {display:none;}