Disable WooCommerce SKU on the product page

I have a WooCommerce store and I do not want to display SKUs on any 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 tried to override it with this line of code, which I posted in a custom plugin:

apply_filters( 'wc_product_sku_enabled', false );

I also tried putting apply_filter in the action function for woocommerce_product_meta_start, which fires right before that, but still displays the SKU on the product page. Any ideas?

+4
source share
4 answers

I think you will try with this:

add_filter( 'wc_product_sku_enabled', '__return_false' );

This will remove sku from all woo, back and front end. You can always hide it only with CSS, if necessary for the administrator.

+10

- CSS:

.sku_wrapper {
    display:none;
}

, woocommerce woocommerce/templates/single-product/meta.php :

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

woocommerce , :

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

+2

All Articles