Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Needed a quick drop in script for functions.php to add SKU field on the general tab within WooCommerce product editor
<?php
// add sku on woocommerce product editor >> general tab
add_action( 'woocommerce_product_options_general_product_data', 'add_the_sku_to_general_product_field' );
function add_the_sku_to_general_product_field() {
global $post;
$product_sku = get_post_meta( $post->ID, '_sku', true );
?>
<div class="options_group">
<p class="form-field _sku_field ">
<label for="_sku">
<abbr title="Stock Keeping Unit">SKU</abbr>
</label>
<!--<span class="woocommerce-help-tip"></span>-->
<input type="text" class="short" style="" name="_sku" id="_sku_alias" value="<?php echo $product_sku; ?>" placeholder=""
onchange="(function(){
jQuery('input#_sku').val(jQuery('input#_sku_alias').val());
})();" >
</p>
</div>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment