I'm trying to move the title of my products on top (on top of the image) but i'm not sure how to do it... I want the title to be uptop on the product page not the archive page.
I've spent a long time researching about how to do it but nothing seems to work...
Is there a hook to move it ? Maybe change the layout on the product_page.php ?
For better understanding the product template see the default content-single-product.php - https://gist.github.com/dompascal/7825580 and use this visual map - https://www.businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/
In your functions.php file in your active theme add the following:
Solution #1
//First remove default title
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
//Second add your title in thumbnail section - Keep in mind that title will be below the image bcs of the way this hook works
add_action( 'woocommerce_product_thumbnails', 'woocommerce_template_single_title', 5 );
Solution #2
Another way is to place title above all (depends on your design)
//First remove default title
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
//Second add title
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_template_single_title', 5 );
Solution #3
Override woocommerce templates in your theme. There is alot of examples but this is a good starting point - https://woocommerce.com/document/template-structure/
This solution will provide the best output of your template BUT will require more maintance in future.
If you use theme that override those templates or hooks then you need to work with the theme hooks. But this is specific per theme.
First solution didnt worked but it might be related to my theme.
Second solution worked like a charm even tho i changed the hook :)
To answer my question : How to move the title on top of the product :
//First remove default title
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
//Second add title
add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5 );
Related
Good morning. I need to move the prices contained in the cards above the titles in the main shop pages and consequently the category too. I mean not the single page where you see the product itself, but the /shop page where all the products are listed. i don't really know the hook to use and priority to set. Thank you for your help.
It depends on your theme, but if everything is by default, this is the code you need:
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
Code goes in functions.php file of your active theme/child theme. Tested and works.
I'm building an affiliate site and obviously for every product I use page not post. But pages don't have categories or tags and even if we add them to pages, our pages won't appear on categories' pages and in widget areas of front page.
Woocommerce functionality is perfect but it looks a little bit weird to use it for an affiliate site, not a store. Is it okay to delete e-commerce features (price, add to card and stuff like that) and use the rest of Woocommerce?
It is nothing weird to use Woocommerce without cart stuff.
Sometimes clients want a catalog of goods, but not always need the cart and delivery staff on a site.
In this plugin it is much more comfortable to organize categories and editing of many products. Plus you get interaction with other plugins that build for Woocommerce.
If you make it thru "Custom Post Type", then it is normal if there are about 10.
If they are more, than you will need to create many solutions by yourself and you will have problems with their further maintenance.
Woocommerce is pretty good for e-commerce sites. As you creating affiliate site for that you can hide some functionality of Woocommerce. As you mention you want to hide (price, add to card and stuff like that). You have to use some actions to remove those functionality. Copy following code and place it in your active theme's function.php file.
Note: If you have child theme then you must have to add this code in child theme's function.php file.
add_action('after_setup_theme','activate_filter') ;
function activate_filter(){
add_filter('woocommerce_get_price_html', 'hide_price_cartBtn');
}
function hide_price_cartBtn(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
}
comment if you like to remove more things as you mention stuff like that
I'm using an already purchased wordpress theme. The rating tab is located under "woocommerce_output_product_data_tabs". I already know how to unset it from the output tabs but I don't know how to add it in "woocommerce_after_single_product_summary". Did you do something similar to this?
Firstly, create a Child Theme so that your modifications do not get overridden when any Theme Updates are released.
Head into your functions.php, in your Parent Theme, and locate the function entry for your Ratings Tab. Copy this coding into the functions.php file, within your Child Theme.
Within the add_action entry, you will need to change the code as follows:
add_action('woocommerce_after_single_product_summary', 'THIS_NEEDS_TO_BE_THE_SAME_AS_THE_FUNCTION_NAME');
Hope this helps.
Try This
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10, 2 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
function woocommerce_template_single_rating( $woocommerce_template_single_title, $int ) {
// make action magic happen here...
};
I've hunted everywhere to figure out how to move the Product Short Description from the right side of the picture on a Single Product page of Woocommerce into the tabs. I just can't find it anywhere!
Can someone please help me accomplish that.
Just remove the woocommerce_template_single_excerpt callback from the woocommerce_single_product_summary action:
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
...and add it directly to a custom tabs.php template:
woocommerce_template_single_excerpt();
Read more about overriding templates in the docs.
What needs to be done is that the featured image would only appear in the catalog view, but not in a single product view. So basically if an image is set as a featured image it should not be shown as the main image in product page and in should be excluded from thumbnails as well.
I have been looking ofr solution for a long time and tried different many approaches but nothing seems to help:
I have been adding the following to the functions.php:
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_thumbnails', 20 );
as well as all of the solutions in here: Remove featured image from showing on product display page
Theme is Mr. Tailor
Any help or suggestion is much appreciated.
I was searching for this solution like you, and found that your code is almost functioning. Only had to change the number on the second line from 20 to 3, and it's working.
So the code is:
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_thumbnails', 3 );
This will remove featured image in the product page and replaces it with the first thumbnail.