Removing woocommerce short description field - php

I'm creating a theme designed specifically for usage with woocommerce. This theme's design does not utilize the "Product Short Description". Removing that description from displaying on the page was easy enough using:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
However, I cannot seem to find any way to remove the field/panel itself from showing to the admin on the product editing pages. If anyone knows how to do that, it would be greatly appreciated. To be clear this is the newer woocommerce 2.0. Thanks!

You can remove the Short Description field from the WooCommerce admin area via PHP:
function remove_short_description() {
remove_meta_box( 'postexcerpt', 'product', 'normal');
}
add_action('add_meta_boxes', 'remove_short_description', 999);

As answered in different treads:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
function woocommerce_template_single_excerpt() {
return;
}

This is also what I am looking for. For me, to target the product description's css, use .single-product .entry-content.
Until now, I think Woocommerce doesn't provide any hook for product description only.

Related

Woocommerce - disable add_to_cart button when product is on backorder

I want to disable button "Add to cart" when product is available on backorder.
I tried something like this, but doesn't work at all:
function remove_add_to_cart ($product){
if($product->is_on_backorder){
add_filter( 'woocommerce_is_purchasable', '__return_false');}}
any suggestion please?
One solution (depending on what you actually want to do) could be to remove the add_to_cart form entirely if the product is on backorder. There could be other solutions as well, but your question is a little vague. This is specifically for the product single page. You didn't specify in the question.
add_action('woocommerce_single_product_summary', 'check_if_backordered', 1 );
function check_if_backordered(){
global $product;
if ($product->is_on_backorder()){
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
// Here you can insert whatever you want in its place
}
}

Move related product to the sidebar on Woocommerce single products

In woocommerce product page, i would like remove the related product on the product bottom page and put it on sidebar.
I can remove it (on the bottom) with:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
and add it in sidebar a widget [related_products]. But if I do it like this, I remove all related product.
Have you got an idea, how I could do it?
It just change the location of the related products… Here are the steps:
1) add the following code in your active child theme function.php file (only):
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products',20);
2) In backend settings "Appearance" > Widgets:
Add a Text widget to your product sidebar
Edit and paste inside the text editor the shortcode [related_products per_page="3" columns="1"]
Save.
Then you will get something like:
I think it may help you.
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
First of all, you will remove the "woocommerce_after_single_product_summary" and overwrite like below.
add_action( 'woocommerce_before_single_product_summary', 'your_function', 25);
function your_function(){
...
...
}
Note: If you alter/modify the above hook it will affect in product single page.
After call related products in widgets via shortcode

How can i hide basic price in product details page - woocommerce plugin?

i have tried many way but can not figure out. I want to hide basic price (top price) of product details page and want to replace with bottom price (total price). Something like THIS. Could anyone tell me how i do that? is there any hook in woocommerce for do this?
I have tried with this hook:
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price',10);
But it does't work. Thanks me advance.
Two big points here.
Your code is referencing the shop loop, while your screen shot is the single product page. Since your code is targeting the wrong page, you aren't likely to see any change.
remove_action() always needs to be called from inside a function and not directly from your theme's functions.php. See the codex.
So, taking those points into consideration, something like the following ought to remove the price from the single product page.
function so_46304892_remove_price() {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
}
add_action( 'woocommerce_before_single_product', 'so_46304892_remove_price' );
You can use this hook woocommerce_get_price_html and check whether it is a single product page or not
For eg.
add_filter('woocommerce_get_price_html','your_func_name',10,2);
function your_func_name($price, $product_data) {
if(is_product()) {
$price = '';
}
return $price;
}

Remove Woocommerce Product Short Description

I'm trying to remove the Product Short Description showed on a Single Product Page in Woocommerce. By default it's placed right underneath the price, I want it totally gone.
I tried to use this code: remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20); and placed in functions.php of my Child theme folder but it doesn't change anything.
If I try woocommerce_template_single_add_to_cart or woocommerce_template_single_meta to see if the piece of code actually works it removes the add to cart button and product meta but for some reason the excerpt isn't affected.
Any other solutions to remove it?
Thanks!!
Joost
The right snippet is posted here:
How to remove wordpress Short description tab in single product page in wordpress?
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
function woocommerce_template_single_excerpt() {
return;
}
Get the code snippet plugin and run
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] );
return $tabs;
}

WooCommerce price position - variable product

I am trying to move position of pice in wordpress in plugin WooCommerce. In normal product its without problems as you can see here: http://beta.gaumaya.sk/?product=produkts but in variable product its almost imposiible i am trying to do it for hours right now. Here is how it looks http://beta.gaumaya.sk/?product=produkt I really need to move that price next to title. My functions.php file: add_action( 'woocommerce_single_product_summary_geril', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_single_product_summary_geril', 'woocommerce_template_single_price', 5 );
add_action( 'woocommerce_single_product_summary_geril', 'woocommerce_output_product_data_tabs', 20 );
add_action( 'woocommerce_single_product_summary_geril', 'woocommerce_template_single_add_to_cart', 30 );
content-single-product.php : http://pastebin.com/2DZPnnfP . How can this little thing be changed?
I would suggest removing your content-product.php from your theme and reverting back to WooCommerce's default templates. The price is pretty near the title by default.
There is no need to create your own action hook do_action( 'woocommerce_single_product_summary_geril' );? when you can simply unhook the functions you don't want from the existing hook using remove_action()?

Categories