Hello,
I have created some custom fields related to product categories, I have two categories (books and films). When I click on a specific category, the custom fields appear.
The users who can add the products have the categories panel hidden and I only want them to be able to add books.
It is possible that when a new product is added, the books category is selected and the custom fields appear directly.
I have tried with this code that when opening a new product the category is marked but the custom fields do not appear. They only appear if I deactivate and reactivate the category.
// Define the admin_head callback
function action_admin_head() {
global $post, $pagenow;
// Only on new product pages
if( $pagenow != ‘post-new.php’ ) return;
?>
<script>
jQuery(function($){
$( ‘#in-product_cat-15’ ).attr( ‘checked’, true );
});
</script>
<?php
}
add_action( ‘admin_head’, ‘action_admin_head’, 10, 0 );
It’s possible?
thanks