This snippet will replace the existing post ID displayed in the WooCommerce product edit screen with the variation’s SKU if one exists. Often times the variation SKU is far more useful to an admin than the internal WordPress post ID so having it displayed on the edit screen makes the administration process much easier.

woocommerce-sku-snippet

 

jQuery( document ).ready( function() {
	jQuery( '#woocommerce-product-data' ).on( 'woocommerce_variations_loaded', function() {
		var $panels = jQuery( this ).find( '.woocommerce_variation' );

		$panels.each( function() {
			var sku = jQuery( this ).find( '.sku input' ).val();
			if ( sku ) {
				jQuery( this ).find( 'h3 > strong' ).text( 'SKU: ' + sku );
			}
		} );
	} );
} );

 

Comments are closed.