问题
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:
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.
Remove/hide the "View Cart" button. This is the most important...I don't want people leaving this checkout page.
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.
回答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;
}
来源:https://stackoverflow.com/questions/22927419/woocommerce-checkout-page-remove-view-cart-button-other-messages