How to get rid of "SKU" field in the Product Detail section of the Create New Product page

Our products don't have SKU's nor do we have a need for the Personalize field in the Product Detail section when adding a new product. How can we delete these fields and just have Price and Inventory fields?

  • Ash

    Hello @Alex

    I hope you are well today.

    Please try the following code:

    add_action( 'admin_head', 'hide_mp_form' );
    function hide_mp_form() {
    	$screen = get_current_screen() ;
    	if ( 'product' == $screen->post_type ) {
    	?>
    	<style>
    	.mp_sku_col, .mp_custom_field_col{
    		display: none;
    	}
    	</style>
    	<?php
    	}
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have.

    Cheers
    Ash

  • Luís

    Hi val ,

    Hope you're doing well today!

    Firstly, sorry for the late reply and all the problems it may have caused.

    It's possible that you didn't opened a php tag in the begining of the file. I tested this code in my install and we need to make some changes to work with the new version of MarketPress (3.1.2), because the CSS classes were changed. Can you please try this code:

    <?php
    
    add_action( 'admin_head', 'hide_mp_form' );
    function hide_mp_form() {
    	$screen = get_current_screen() ;
    	if ( 'product' == $screen->post_type ) {
    	?>
    	<style>
    	#mp-product-price-inventory-variants-metabox .wpmudev-fields > div:first-of-type {
    		display: none;
    	}
    	</style>
    	<?php
    	}
    }

    This is the "Add New Page" without the SKU option:

    Also, I attached the file used in my install, so, if you are interested:

    1) Download the .zip file attached and unzip it;

    2) Upload "remove-sku.php" to "wp-content/mu-plugins" folder.

    Cheers, Luís

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.