I would like to remove order total block on cart and checkout page.
I am not able to find any action or filter to remove order total.
I don't want to use css to hide this column.
Using hooks:
1) Remove cart totals:
// On cart page
add_action( 'woocommerce_cart_collaterals', 'remove_cart_totals', 9 );
function remove_cart_totals(){
// Remove cart totals block
remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 );
// Add back "Proceed to checkout" button (and hooks)
echo '<div class="cart_totals">';
do_action( 'woocommerce_before_cart_totals' );
echo '<div class="wc-proceed-to-checkout">';
do_action( 'woocommerce_proceed_to_checkout' );
echo '</div>';
do_action( 'woocommerce_after_cart_totals' );
echo '</div><br clear="all">';
}
2) Remove checkout totals:
// On checkout page
add_action( 'woocommerce_checkout_order_review', 'remove_checkout_totals', 1 );
function remove_checkout_totals(){
// Remove cart totals block
remove_action( 'woocommerce_checkout_order_review', 'woocommerce_order_review', 10 );
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
If its input field you can remove its value like
$('#div_id').val('');
If its div or span you can do
$("div").empty();
S('#div_id div').html('');
Related
Im trying to hide the add to cart button in woocommerce for all products except a varibale product i have. I have tried the following which leaves the variable select options (which is what i want) but it hides the add to cart button (which i don't want).
add_filter( 'woocommerce_is_purchasable', '__return_false' );
add_action( 'woocommerce_single_product_summary', 'hide_add_to_cart_button_variable_product', 1, 0 );
function hide_add_to_cart_button_variable_product() {
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20);
}
Is there a way to do this?
All my products are simple products except for this single variable products, so maybe there is a function to hide the cart button for all simples except variables?
add_action('woocommerce_single_product_summary', 'wp66176371_remove_product_description_add_cart_button', 1 );
function wp66176371_remove_product_description_add_cart_button() {
global $product;
if ( !empty($product) && $product->is_type( 'simple' ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
}
}
I think you can just edit the simple.php template file in the add-to-cart directory so it wouldn't show the button for simple products.
In WooCommerce I am trying to remove add to cart from product keeping the stock information.
I tried to do it with a plugin but it also remove the stock information.
Is there any way to remove Add to Cart button keeping stock information in single product pages ?
The following code will remove add to cart form from single product on simple product type but will display the stock information:
// Single products (Simple): remove add to cart button and keep stock info
add_action( 'woocommerce_single_product_summary', 'remove_simple_product_add_to_cart_button', 1 );
function remove_simple_product_add_to_cart_button() {
global $product;
// For simple products type
if( $product->is_type( 'simple' ) && $product->is_purchasable() ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'show_stock_info', 30 );
}
}
// Function that stock info
function show_stock_info() {
global $product;
echo wc_get_stock_html( $product );
}
Code goes in function.php file of your active child theme (active theme). tested and works.
In single product pages, I would like to change the location of "additional information" from tabs, under add to cart button using Woocommerce hooks (removing the "additional information" tab).
I have:
add_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
and: woocommerce_after_add_to_cart_button
I'm trying:
remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
add_action( 'woocommerce_after_add_to_cart_button', 'woocommerce_product_additional_information' );
and
remove_action( 'woocommerce_product_additional_information', 'wc_display_product_attributes', 10 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_product_additional_information', 60 );
But it doesn't work.
How can I move properly "additional information" below add to cart button?
The following code will remove additional information tab and add additional information below add to cart:
// Remove additional information tab
add_filter( 'woocommerce_product_tabs', 'remove_additional_information_tab', 100, 1 );
function remove_additional_information_tab( $tabs ) {
unset($tabs['additional_information']);
return $tabs;
}
// Add "additional information" after add to cart
add_action( 'woocommerce_single_product_summary', 'additional_info_under_add_to_cart', 35 );
function additional_info_under_add_to_cart() {
global $product;
if ( $product && ( $product->has_attributes() || apply_filters( 'wc_product_enable_dimensions_display', $product->has_weight() || $product->has_dimensions() ) ) ) {
wc_display_product_attributes( $product );
}
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
When I try to hide the 'Add to cart' button, the variations disappear.
Here is the way to remove add to cart button and quantities in Single product pages for variable products only, keeping the attributes select fields:
add_action( 'woocommerce_single_product_summary', 'hide_add_to_cart_button_variable_product', 1, 0 );
function hide_add_to_cart_button_variable_product() {
// Removing add to cart button and quantities only
remove_action( 'woocommerce_single_variation', 'woocommerce_single_variation_add_to_cart_button', 20 );
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works.
I did this, since I have variable products on separate RETAIL pages that I want to keep the 'Add to cart' button
function remove_add_to_cart(){
if ( has_term( 'wholesale', 'product_tag' ) ) {
remove_action( 'woocommerce_single_variation','woocommerce_single_variation_add_to_cart_button', 20 );
}
}
add_action('woocommerce_single_variation','remove_add_to_cart');
I would like to hide add to cart button and to show a custom text instead of button.
I am trying following hook to remove button:
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
Here is the way that you are looking for (I think).
The first function will replace on shop pages the add-to-cart buttons by normal buttons linked to their single product pages, like below:
The second function will replace the add-to-cart button (and quantities) by your custom text as this:
Here is that code:
// Shop and archives pages: we replace the button add to cart by a link to the product
add_filter( 'woocommerce_loop_add_to_cart_link', 'custom_text_replace_button', 10, 2 );
function custom_text_replace_button( $button, $product ) {
$button_text = __("View product", "woocommerce");
return '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';
}
// replacing add to cart button and quantities by a custom text
add_action( 'woocommerce_single_product_summary', 'replacing_template_single_add_to_cart', 1, 0 );
function replacing_template_single_add_to_cart() {
// Removing add to cart button and quantities
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
// The text replacement
add_action( 'woocommerce_single_product_summary', function(){
// set below your custom text
$text = __("My custom text goes here", "woocommerce");
// Temporary style CSS
$style_css = 'style="border: solid 1px red; padding: 0 6px; text-align: center;"';
// Output your custom text
echo '<p class="custom-text" '.$style_css.'>'.$text.'</a>';
}, 30 );
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
Tested and works
1. In case you want to completely disable Add to cart button, add this code to your theme's functions.php file.
add_filter( 'woocommerce_is_purchasable', false );
2. To add some HTML content after Add to cart button, try this code.
add_action( 'woocommerce_after_add_to_cart_button', 'add_content_after_addtocart_button_func' );
function add_content_after_addtocart_button_func() {
echo '<p>Hi, I'm the text after Add to cart Button.</p>';
}
I was able to do this with a Wordpress plugin, i found later https://wordpress.org/plugins/woo-options/