Hiding shopping details in woocommerce - wordpress

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 );

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.

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.

How to remove add to cart button from shop page in woocommerce

I want to remove add to cart button from the shop page, product category page and home page in woocommerce. But i want to show it on the product page. That meance i want my costumers to open product page to add the product to cart.
To remove add to cart button from product page. you need to override the product page template .
So locate to woocommerce directory find the below path .
wp-content/plugins/woocommerce/templates/content-product.php
and remove the text which says - It will remove the Add To Cart Button for each product in the Shop page, retaining the Button in the Single Product Page.
This worked for me:
add_action( 'woocommerce_after_shop_loop_item', 'remove_add_to_cart_buttons', 1 );
function remove_add_to_cart_buttons() {
if( is_product_category() || is_shop()) {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}
}

Remove Add to Cart Button from MyStile Theme in Woocommerce

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' );
}

Woocommerce customize the product name in the cart and order pages

Actually, I already got hook to customize the price in the cart page and all other page.
This is the hook to customize the product price
add_action( 'woocommerce_before_calculate_totals', 'add_custom_price' );
function add_custom_price( $cart_object ) {
$custom_price = 10; // This will be your custome price
foreach ( $cart_object->cart_contents as $key => $value ) {
$value['data']->price = $custom_price;
}
}
Actually, I am using woocommerce plugin. I want a hook to customize the product name displayed in the cart page and all other pages next to cart page.
I want to customize the Product name , i want to add the some static attributes to product name displayed in the cart page, order page ,order details page and all the pages next to cart page.
Thanks in advance
I wanted to share this as I managed to figure out something for my needs. (I only ever have a single item in the order as I've customised WooCommerce for holiday bookings.)
<?php
add_action( 'woocommerce_product_title', 'add_custom_name' );
function add_custom_name( $title ) {
return 'test name';
}
?>
Hopefully someone can elaborate on this further or take what has been done with the custom price code an properly re-purpose it for product names.

Resources