Remove Add to Cart Button from MyStile Theme in Woocommerce - wordpress

I have difficulty doing this even after following instructions of how to do it. I don't know if the structure of woocommerce have changed since the below snippet was given.
Below is the code I tried using to remove the Add to cart button in the Homeapage and Shop page.
Mind you, this was pasted in the Theme Functions (functions.php) and I use MyStile Theme.
I was able to remove the Add to Cart button from the single page but not the homepage and shop page.
Code
function remove_loop_button(){
remove_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
}
add_action('init', 'remove_loop_button');
Thanks for your help in advance.

You can use following code. Put it in your functions.php:
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', 30 );
To Remove “Add to Cart” button all you need to do is paste the following lines of code in your functions.php file located inside your theme’s directory.
//remove "Add to Cart" button on product listing page in WooCommerce
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}

Related

Woocommerce: Add to cart on category page not adding when filter is applied

I put this code on my website to be able to add products directly from the product list instead of the single product page and everything works well when I add them from the category page:
add_action( 'woocommerce_before_shop_loop', 'handsome_bearded_guy_select_variations' );
function handsome_bearded_guy_select_variations() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_single_add_to_cart', 30 );
}
Except when I use filters, apparently, is not getting the variable product information once I have a filter active, and there is a message saying that I need to add the product from the single product page. Can someone help me figure out how to make it work with filters?
Demo: https://802cabinetry.com/style/stowe-light-gray/
enter image description here
Thanks.

How to change position of Add to Cart Button on Single Product

I would like to change position of Add to Cart Button on Single Product. I've tried to used code below:
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 9);
Unfortunately it doesn't work with My Theme. The result is that Add to Cart Button is double. The screenshot below:
Add cart button displaying twice with My Theme
When I change the Theme to different one (Twenty Nineteen), every thing seems to be okey. The screenshot below:
Add car button displaying once with Twenty Nienteen Theme
My website is www.applefix.pl. Please help me with that.
Maybe you could try to "delay" the actions after the parent theme is loaded:
function wc_move_single_product_button() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 9);
};
add_action( 'after_setup_theme', 'wc_move_single_product_button', 20 );
Update: another possibility is that your theme uses another function to hook the button. I would try to use the WordPress default theme just to check if that’s the case. If it is, you can search the function and unhook it properly!
Let me know if it does the trick!

Move "Add to Cart" form below product description

I want to move only add to cart form below products description. To explain better:
Found this function, but it moves this at top of product under description. So some part of function is not right. Can someone to help me?
add_action( 'woocommerce_single_product_summary',
'customizing_variable_products', 1 );
function customizing_variable_products() {
global $product;
if( ! $product->is_type( 'variable' ) ) return;
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 15 );
}
You have to copy / paste all the woocommerce templates into your current template folder.
This way, the woocommerce theming isn't gonna take it's own templating but will take the one you pasted instead.
Then, you'll just have to find, where, in the template files where is printed the options, and where is printed the add to cart button. You'll be then able to switch the code sa that it makes what you need.
here is the doc about how overriding templates files.

Remove breadcrumbs from WooCommerce Storefront theme

In order to remove breadcrumbs from the Storefront theme, the documentation states to add the following in functions.php:
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20 );
I tried this in a child theme of Storefront and it doesn't work. Tracing back the woocommerce_breadcrumb, it seems to be added in storefront_content_top action (in the file <storefront_dir>/inc/woocommerce/storefront-woocommerce-template-hooks.php. I commented out the corresponding line and indeed the breadcrumbs are hidden.
However, to do this the right way, I try to disable it from the child theme using
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
but it doesn't work. I should clarify that I test this in a fresh child theme with no other code.
How would one disable the breadcrumbs from a child theme?
Copy and paste the following snippet into your functions.php file.
add_action( 'init', 'z_remove_wc_breadcrumbs');
function z_remove_wc_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10);
}
since Storefront 2.3.1 try this
add_action('init', 'dp_remove_wc_breadcrumbs');
function dp_remove_wc_breadcrumbs(){
remove_action('storefront_before_content', 'woocommerce_breadcrumb', 10);
};
Try this:
add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
.breadcrumb{
display: none;
}

Hiding shopping details in woocommerce

How to hide shopping details like, add to cart, quantity etc
I know for plugin YITH wordpress catalog mode, but it's not free
CSS is not correct way to hide that elements I think, what do you think about that?
Can you please confirm from wihch page you exatctlye you want remove shopping related item. Product list page or product details page.
So, to remove add to cart button from product detail page and shop page i.e. product listing page all we need to do is to add these two hooks.
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', 30 );
To remove quantity box from all places
function remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually',
'remove_all_quantity_fields', 10, 2 );

Resources