Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable WooCommerce SKU on Product Page

I have a WooCommerce store and I don't want to display the SKU on any single product page. Looking at their code, I found this filter:

/**
 * Returns whether or not SKUS are enabled.
 * @return bool
 */
function wc_product_sku_enabled() {
    return apply_filters( 'wc_product_sku_enabled', true );
}

and I attempted to override it with this line of code I placed in a custom plugin:

apply_filters( 'wc_product_sku_enabled', false );

I also tried placing the apply_filter inside an action function for woocommerce_product_meta_start which fires right before but it still renders the SKU on the product page. Any ideas?

like image 572
Adam Avatar asked Sep 07 '14 02:09

Adam


People also ask

Can you hide SKU in WooCommerce?

To do this, go to WooCommerce > Settings > Products > SKU and select the Hidden option. This will hide the SKU from all products on your store. If you only want to hide the SKU for certain products, you can do this by editing the product in question and selecting the Hide SKU option under the Inventory tab.

How do I hide SKU and category in WooCommerce?

There are a few ways that you can go about hiding SKU and category information in WooCommerce. One way is to simply not display this information on the product page. You can do this by going to the product page in the back end, and unchecking the “Display SKU” and “Display Categories” options under the “Inventory” tab.

How do I hide tags from a single product page in WooCommerce?

Another way to hide tags on WooCommerce product pages is by editing the code of your theme. If you're comfortable editing code, you can add a bit of code to your theme's functions. php file that will hide all tags from being displayed on your product pages.

How do I hide the tags on a WordPress product page?

To do this, go to the Products tab in your WordPress dashboard and click on Tags. Then, click on the Edit link next to the tag that you want to hide. In the Visibility section, select Hidden. Once you save your changes, the tag will be hidden from all products that have it applied.


2 Answers

I think you shoul try with this:

add_filter( 'wc_product_sku_enabled', '__return_false' );

That will remove sku from all woo, back and front end. You can always hide it just by CSS if need it on admin.

like image 76
rgdesign Avatar answered Nov 05 '22 10:11

rgdesign


The easiest way is with CSS:

.sku_wrapper {
    display:none;
}

A more robust approach is to recreate the woocommerce template woocommerce/templates/single-product/meta.php in your own theme and simply comment out the line:

<span class="sku_wrapper"><?php _e( 'SKU:', 'woocommerce' ); ?> <span class="sku" itemprop="sku"><?php echo ( $sku = $product->get_sku() ) ? $sku : __( 'N/A', 'woocommerce' ); ?></span>.</span>

To recreate a woocommerce template in your own theme, see:

http://docs.woothemes.com/document/template-structure/

like image 24
Pat Gilmour Avatar answered Nov 05 '22 10:11

Pat Gilmour