Skip to content

Instantly share code, notes, and snippets.

@Jany-M
Last active June 6, 2021 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Jany-M/b218455d130c9a91897ef477a538c29d to your computer and use it in GitHub Desktop.
Save Jany-M/b218455d130c9a91897ef477a538c29d to your computer and use it in GitHub Desktop.
[WP][WooCommerce] Add SKU next to Variation ID in Admin Metabox
<?php
// Add SKU next to variation ID
function display_sku_next_to_var_ids() {
?>
<script type="text/javascript">
jQuery(function($) {
"use strict";
$(document).on('woocommerce_variations_loaded', function(event) {
var id = -1;
$('.woocommerce_variation.wc-metabox').each( function(index, elem) {
id++;
var var_id = $(elem).find('#variable_sku'+id).val();
$('h3 strong', this).after('<p style="display:inline;"> - SKU: <strong>'+var_id+'</strong></p>');
});
});
});
</script>
<?php
}
add_action( 'admin_print_scripts', 'display_sku_next_to_var_ids', 999);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment