WooCommerce price position - variable product - php

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()?

Related

sale_flash badge cannot be removed from woocommerce product loop hook/action

I am trying to remove or edit the "sale!" badge is in woocommrce loop
In the content-product.php,
the comment block says the woocommerce_show_product_loop_sale_flash is hooked with woocommerce_before_shop_loop_item.
However it actually works with woocommerce_after_shop_loop_item_title.
I tried to remove everything from the hook, still, the sales badge still appears:
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating' );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price' );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );
The following is also not working:
remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash' );
So I really have no idea where the sales badge function is being called from?
I'm not sure why it's not working for you, because all you have to do is use remove_action, the parameters are the hook location being used and the action name. In this case:
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 );
This works, I checked. I was looking for the same thing. Just add it to your functions.php file. It removes the action called woocommerce_show_product_loop_sale_flash from being hooked into the woocommerce_before_shop_loop_item_title hook location.
Perhaps there is a plugin putting it there as well?
In my case, I did not want the sale flash to be inside of the link so I moved it up to be a direct child of the li instead. I did this by first removing the action via the above, and then adding a new action with a new hook location. The new hook location is the same as the one used to open the link, so I had to modify the priority number to make sure it was executed before the link action sharing the hook.
add_action( 'woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash', 5 );

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

Remove action fails to remove default WooCommerce hooked function

I am trying to move the product tabs from woocommerce_after_single_product_summary to woocommerce_before_single_product_summary. Essentially, I want to replace the image of the product on the single product with a tab that has the image gallery, but all the other tabs show up in that same container. I have issues trying to get the container around the tabs to act like the container around the image, but what's got me stumped is how to remove the tabs from the woocommerce_after_single_product_summary section. I can remove "related products" no problem, from the same section, but nothing I've done has budged the tabs.
This works fine to remove the image:
remove_action ('woocommerce_before_single_product_summary',
'woocommerce_show_product_images',20);
This works fine to add the tabs in its place (Other than the container issue):
add_action( 'woocommerce_before_single_product_summary',
'woocommerce_output_product_data_tabs', 20 );
But this never seems to get rid of the tabs:
remove_action( 'woocommerce_after_single_product_summary',
'woocommerce_output_product_data_tabs', 10 );
I've checked that 10 is the correct number (which I found does make a difference) but it IS correct. I traced the add_action to
woocommerce/includes/wc-template-hooks.php:
/**
* After Single Products Summary Div.
*
* #see woocommerce_output_product_data_tabs()
* #see woocommerce_upsell_display()
* #see woocommerce_output_related_products()
*/
add_action( 'woocommerce_after_single_product_summary',
'woocommerce_output_product_data_tabs', 10 );
add_action( 'woocommerce_after_single_product_summary',
'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary',
'woocommerce_output_related_products', 20 );
I can remove related products with:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
I've tried the suggestion (in another topic) that the hook might need a "template redirect" but that didn't work either. What I tried was:
// Trying template redirect
function esb_product_category_filter_changes()
{remove_action('woocommerce_after_single_product_summary',
'woocommerce_output_product_data_tabs', 10);
}
do_action('template_redirect','esb_product_category_filter_changes');
Any ideas? I've searched all the possibly relevant plugins, turned a bunch off, and still the same behavior. I can put the tabs anywhere I want, but I can't get rid of them.
I have tested on Storefront theme:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
And it works. So your issue can be due to your theme or some plugins that are making some customizations on this.
How to check it: With the following hooked function you will get the raw data output for woocommerce_after_single_product_summary hook (all callbacks, with priorities and arguments). This way you will be able to see if woocommerce_output_related_products is hooked in it and what is the priority.
This testing function will output the data for admins only in archives and product pages:
add_action( 'woocommerce_before_main_content', function(){
// Only for admin user role
if( ! current_user_can('edit_products')) return;
global $wp_filter;
echo '<pre>';
print_r( $wp_filter['woocommerce_after_single_product_summary'] );
echo '</pre>';
}, 50 );
Code goes in function.php file of the active child theme (or active theme).
Now you can get the correct priority to set in the remove_action() (and remove this testing code).
You could also try the following code (without any guaranty):
add_action( 'woocommerce_after_single_product_summary', 'removing_product_tabs', 2 );
function removing_product_tabs(){
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
}
Code goes in function.php file of the active child theme (or active theme).

Move Woocommerce Single Products Title

I was trying to move the product title at Woocommerce single product page to different location. The accepted location is just under itemscope itemtype="http://schema.org/Product" and i was trying to remove first the title from current location which is remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 50); but not removed the title from current location.
Another problem is I can't add product title to new location which I have used do_action( 'woocommerce_moved_product_title_position' ); and then add_action('woocommerce_moved_product_title_position', 'woocommerce_template_single_title', 60);
I am using Woocommerce 2.4.13 and WordPress 4.4.1
Please help me to solve this. It'll be great for me.
Weirdly, you must call remove_action from inside a function.
function so_34845641_move_title(){
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 50);
add_action('woocommerce_moved_product_title_position', 'woocommerce_template_single_title', 60);
}
add_action( 'woocommerce_before_single_product', 'so_34845641_move_title' );
Just a suggestion that there are probably enough hooks without needing to add a custom do_action() in the templates.
Run the remove_action inside a function doesn't change anything , but change the priority work for me.
I give you an example:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20);
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 15 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 10 );
Pay attention and try with differents priorities.

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

Categories