I have added the following code to the bottom of my functions.php file and they are not removing the functions from my product page. I copied the priority numbers directly from the content-single-product.php page and still no luck!
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price',10 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_excerpt',20 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart',30 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_meta',40 );
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_sharing' ,50);
remove_action('woocommerce_single_product_summary', 'WC_Structured_Data::generate_product_data()',60 );e
Try to include them in a custom function hooked in woocommerce_single_product_summary action hook with a smaller priority this way:
add_action('woocommerce_single_product_summary', 'customizing_single_product_summary_hooks', 2 );
function customizing_single_product_summary_hooks(){
remove_action('woocommerce_single_product_summary','woocommerce_template_single_title', 5 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_rating', 10 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_price',10 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_excerpt',20 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_add_to_cart',30 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40 );
remove_action('woocommerce_single_product_summary','woocommerce_template_single_sharing' ,50);
remove_action('woocommerce_single_product_summary','WC_Structured_Data::generate_product_data()',60 );
}
Code goes in function.php file of your active child theme (or active theme).
This way it should work
Related
I'm currently trying to remove all messages from the WooCommerce account with the following code line:
remove_action( 'woocommerce_account_content', 'woocommerce_output_all_notices', 10 );
Sadly, the wrapper for messages is still there:
<div class="woocommerce-notices-wrapper">lol</div>
I've added a lol to the function that displays the wrapper and it's the correct function I'm trying to remove. No idea why it's not working...
If your active theme uses the default woocommerce templates and hooks for myaccount pages, then add the follows code snippet to achieve the above -
function modify_wc_hooks() {
// remove all wc my account's notices wrapper
remove_action( 'woocommerce_account_content', 'woocommerce_output_all_notices', 5 );
remove_action( 'woocommerce_before_customer_login_form', 'woocommerce_output_all_notices', 10 );
remove_action( 'woocommerce_before_lost_password_form', 'woocommerce_output_all_notices', 10 );
remove_action( 'before_woocommerce_pay', 'woocommerce_output_all_notices', 10 );
remove_action( 'woocommerce_before_reset_password_form', 'woocommerce_output_all_notices', 10 );
}
add_action( 'init', 'modify_wc_hooks', 99 );
Codes goes to your active theme's functions.php
Up until a recent update (for Woocommerce, and also the Storefront theme), I was able to remove breadcrumbs using the following code in the child theme functions.php
add_action( 'init', 'z_remove_storefront_breadcrumb' );
function z_remove_storefront_breadcrumb() {
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
That solution is described here.
Since the update (and I am not sure if it was the WC or SF update that did it) this no longer works.
I also tried the other method suggested in the above-mentioned post. And a few other methods, all listed here:
add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
and
add_action( 'init', 'jk_remove_storefront_breadcrumb' );
function jk_remove_storefront_breadcrumb() {
remove_action( 'storefront_content_top', 'woocommerce_breadcrumb', 10 );
}
also
add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
also
add_filter( ‘woocommerce_get_breadcrumb’, ‘__return_false’ );
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
also
add_filter( 'woocommerce_before_main_content', 'remove_breadcrumbs');
function remove_breadcrumbs() {
remove_action( 'woocommerce_before_main_content','woocommerce_breadcrumb', 20, 0);
}
Can anyone suggest what the current way to remove breadcrumbs from the Storefront theme is?
Okay, so I finally find the answer. The following code will remove the Storefront theme breadcrumbs:
add_action( 'init', 'wc_remove_storefront_breadcrumbs');
function wc_remove_storefront_breadcrumbs() {
remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
}
How can i change order of Up-sell & Related products sections on single product. It need to show first related products and then up-sell
Try the following that will move upsells after related products:
1) For Most themes:
add_action( 'init', 'move_upsells_after_related' );
function move_upsells_after_related( ) {
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 25 );
}
Now in some themes like Storefront, a custom hook is used.
2) For Storefront theme only you will use instead:
add_action( 'init', 'move_upsells_after_related' );
function move_upsells_after_related() {
remove_action( 'woocommerce_after_single_product_summary', 'storefront_upsell_display', 15 );
add_action( 'woocommerce_after_single_product_summary', 'storefront_upsell_display', 25 );
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
I have a client who wants to pull the information that defaults into tabs on single product pages in WooCommerce into a different location on the page and remove the tabs entirely.
There are three default product tabs:
product Description,
Additional Information
and Reviews.
Removing the tabs and setting up the Description to display was easy enough to set up in
/wp-content/plugins/woocommerce/includes/wc-template-hooks.php:
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
function woocommerce_template_product_description() {
woocommerce_get_template( 'single-product/tabs/description.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_description', 10 );
That works fine.
I tried to repeat the process by building out new functions that access the template files for Additional Info and Reviews like so:
function woocommerce_template_product_addinfo() {
woocommerce_get_template( 'single-product/tabs/additional-information.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_addinfo', 20 );
function woocommerce_template_product_reviews() {
woocommerce_get_template( 'single-product/review-rating.php' );
}
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_product_reviews', 30 );
But neither is displaying. What am I doing wrong here?
First woocommerce_get_template() is deprecated and replaced by wc_get_template() instead. After some searching and testing (mainly to get the reviews displayed), I have found the way:
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 );
add_action( 'woocommerce_after_single_product_summary', 'get_product_tab_templates_displayed', 10 );
}
function get_product_tab_templates_displayed() {
wc_get_template( 'single-product/tabs/description.php' );
wc_get_template( 'single-product/tabs/additional-information.php' );
comments_template();
}
Code goes in function.php file of your active child theme (or theme). Tested and work (WC 3+).
I have two templates, one for Panorama & Multi-Panel photographs, the other for Normal ones.
I'm trying to code a conditional statement that checks the product tag in order to select the relevant template to be displayed.
Panorama photos have the product tag 'panorama' or 'multi-panel'.
If the 'panorama' or 'multi-panel' tag is true >> perform some remove_action and add_action functionality on the Panorama product page...
...otherwise do nothing to the Normal product page...
This is what I have been dappling with to no affect!!
function robhemphill_panorama_layout () {
if ( has_tag( array( 'panorama', 'multi-panel'))) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_excerpt', 10 );
} else {
// Do nothing
}
}
add_action( 'woocommerce_single_product_summary', 'robhemphill_panorama_layout' );
Any thoughts or ideas would be great, can't find anything online!
As you are targeting Woocommerce product tags (but not WordPress tags) try this instead:
add_action( 'woocommerce_single_product_summary', 'robhemphill_panorama_layout', 1 );
function robhemphill_panorama_layout () {
global $product;
if ( has_term( array( 'panorama', 'multi-panel' ), 'product_tag', $product->get_id() ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_title', 5 );
add_action( 'woocommerce_after_single_product_summary', 'woocommerce_template_single_excerpt', 10 );
}
}
Code goes in function.php file of your active child theme (or theme).
Tested and works.