Created
November 19, 2020 23:28
-
-
Save codearachnid/cf91fc4307317ed169ff5aa380d0b577 to your computer and use it in GitHub Desktop.
Needed a quick drop in script for functions.php to add SKU field on the general tab within WooCommerce product editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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