Hello @rneo83,
You can use the following code to set the default product category:
add_action( 'product_edit_save', 'my_default_product_category' );
function my_default_product_category( $post ) {
if ( 'publish' === $post->post_status ) {
$default_category = 'my-default-category-slug';
$terms = wp_get_post_terms( $post->ID, 'al_product-cat' );
if ( empty( $terms ) ) {
wp_set_object_terms( $post->ID, $default_category, 'al_product-cat' );
}
}
}
You should replace my-default-category-slug with your selected category slug.