Setting WooCommerce SKU programmatically [closed]
You should use save_post hook. Try the code below: function wpse_304031_save_post( $post_id, $post ) { // return if autosave if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE ) { return; } $your_sku = ‘Custom SKU for ‘ . $post->post_title; if( $post->post_type == ‘product’ ) { if( empty( get_post_meta( $post_id, ‘_sku’, true ) ) ) { update_post_meta( … Read more