Archived topic
Remove Proceed To Checkout Bottom Woocommerce
11 replies · Started by Michael on May 5, 2020
Hi,
I'm using the basic Generate Press theme and and have recently added a Woocommerce shopping page to our website. We are using Paypal to directly checkout rather than proceeding to a checkout page.
My Question is. How can I remove the "Proceed To Check Out" button on the shopping cart page. Some say, add some CSS code, others say edit the PHP Page. Not sure which would be the best way to go and what code to remove/add.
Thanks in advance.
Hi there,
you can add this PHP snippet to your site:
remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
Thanks David,
At risk of sounding like a dummy. When you say "place the code on your site", on what page/line exactly.
Thanks again.
The code can be added using one of these methods:
https://docs.generatepress.com/article/adding-php/
Legend!
Glad we could be of help
Instead of removing the checkout button completely, is it possible to stop its function and put the overlay?
So its no longer a button its just a label or something ?
Exactly
Ok, so best thing is:
1. remove the current button using the above snipept:
remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
2. Hook in your own label with this snippet:
add_action( 'woocommerce_proceed_to_checkout', function(){
<?php
<div class="checkout-button">
<?php esc_html_e( 'Proceed to checkout', 'woocommerce' ); ?>
</div>
?>
}, 20);
Or you can instead of using code to hook in a label.
You can use a GP Block Element - Hook:
https://docs.generatepress.com/article/block-element-hook/
In the sidebar set the Hook to Custom hook and in the field provided add: woocommerce_proceed_to_checkout
In the priority field add 20
Set the Display Rules to the Entire Site
Then add whatever you require in the block editor.
This is my code:
/**
* Set a minimum order amount for checkout before add shipping rates and taxes, and remove checkout button from cart
*/
add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
add_action( 'woocommerce_before_checkout_form', 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 30;
//remove checkout button from cart
if ( WC()->cart->subtotal < $minimum ) {
remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
}
//add error messages
if ( WC()->cart->subtotal < $minimum ) {
if( is_cart() ) {
wc_print_notice(
sprintf( 'Devi effettuare un acquisto minimo di %s per completare un ordine, attualmente il tuo ordine è di %s.' ,
wc_price( $minimum ),
wc_price( WC()->cart->subtotal )
), 'error'
);
}
}
}
I try to insert your:
add_action( 'woocommerce_proceed_to_checkout', function(){
<?php
?>
}, 20);
After:
//remove checkout button from cart
if ( WC()->cart->subtotal < $minimum ) {
remove_action( 'woocommerce_proceed_to_checkout','woocommerce_button_proceed_to_checkout', 20);
But doesn't work...
Can you try the element method to hook in your alternative content ?