WordPress Custom Functions For WooCommerce Product Detail Page

WordPress Functions

There are so many functions that affect WooCommerce Product Detail pages to customize it to meet the needs of your web site.. This page is a collection of various ones I’ve used on projects. Most of them can simply be dropped-in to your functions.php file, but a few do require your to make small changes depending on your exact needs. For more information on using your theme’s function.php file, read this article first.

Remove SKU's on WooCommerce Product Detail Pages

Many shops use SKU’s internally, but don’t want them displayed on the site pages for customers to view. Removing them is simple, by adding this code to your theme’s functions.php file.


// Remove SKU's
add_filter( 'wc_product_sku_enabled', '__return_false' );

Remove Product Review Tabs

If you aren’t using reviews in your WooCommerce eCommerce store, you can remove them using the following function.


// Remove Product Review Tabs
add_filter( 'woocommerce_product_tabs', 'wcs_woo_remove_reviews_tab', 98 );

function wcs_woo_remove_reviews_tab($tabs) {
	unset($tabs['reviews']);
	return $tabs;
}

Hide or Change "Free!" Price Label for $0 Products

When you set a regular price for a product to $0.00, it will be displayed as “Free!”. You can remove that using the following code.


// Hide or Change "Free!" Price Label for $0 Products
add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price' );
function hide_free_price($price){
	return '';
}

Or, if you prefer to change the word to something else, you can add your verbiage in the return value like this. Simply replace the words “Here’s My New Label” in the example below to whatever you would like it it to read.


// Hide or Change "Free!" Price Label for $0 Products
add_filter( 'woocommerce_variable_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_free_price_html', 'hide_free_price' );
add_filter( 'woocommerce_variation_free_price_html', 'hide_free_price' );
function hide_free_price($price){
	return 'Here's My New Label';
}

Remove Breadcrumbs From WooCommerce

Breadcrumbs typically help add to a good user experience; however, there are instances where you may not want or need them on your WooCommerce pages. Simply drop-in the following function to remove them from your eCommerce pages.


// Remove Breadcrumbs From WooCommerce
add_action( 'init', 'jk_remove_wc_breadcrumbs' );
function jk_remove_wc_breadcrumbs() {
    remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
, , ,
Previous Post
WordPress Custom Functions For WooCommerce Taxes
Next Post
WordPress Custom Functions For WooCommerce Product Category Page

Related Posts

You must be logged in to post a comment.
Menu