Skip to content

Instantly share code, notes, and snippets.

@sirjonathan
Created February 17, 2021 16:10
Show Gist options
  • Save sirjonathan/9963ddc07c09743c13b2dd556df0c4fd to your computer and use it in GitHub Desktop.
Save sirjonathan/9963ddc07c09743c13b2dd556df0c4fd to your computer and use it in GitHub Desktop.
Remove SKU from product page
// Remove the "SKU" field on the product page
function woolive_remove_product_page_skus( $enabled ) {
// Check to make sure we're _not_ on the admin panel and that we _are_ on a product page
if ( ! is_admin() && is_product() ) {
// We're using a filter called wc_product_sku_enabled which, by default, has the SKU field enabled
// By returning false, we're telling it to disable the SKU field
return false;
}
// If our conditional check above fails (for example, when we are in the admin), continue as normal and stay enabled
return $enabled;
}
// Attach our function to the wc_product_sku_enabled filter
add_filter( 'wc_product_sku_enabled', 'woolive_remove_product_page_skus' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment