I want to auto check on Downloadable and Virtual checkbox on Dokan plugin, this my code:
add_action( 'woocommerce_product_options_general_product_data', 'hiding_and_set_product_settings' );
function hiding_and_set_product_settings(){
## ==> Set HERE your targeted user role:
$targeted_user_roles = array( 'administrator', 'shop_manager', 'vendor', 'vendors' );
// Getting the current user object
$user = wp_get_current_user();
// getting the roles of current user
$user_roles = $user->roles;
if ( array_intersect( $targeted_user_roles, $user_roles ) ){
## CSS RULES ## (change the opacity to 0 after testing)
// HERE Goes OUR CSS To hide 'virtual' and 'downloadable' checkboxes
?>
<style>
label[for="_virtual"], label[for="_downloadable"]{ opacity: 0.2 !important; /* opacity: 0; */ }
</style>
<?php
## JQUERY SCRIPT ##
// Here we set as selected the 'virtual' and 'downloadable' checkboxes
?>
<script>
(function($){
$('input[name=_virtual]').prop('checked', true);
$('input[name=_downloadable]').prop('checked', true);
})(jQuery);
</script>
<?php
}
}
This in my function, child theme. I found this code from: https://stackoverflow.com/a/42177288/6574214
. But this code only work for backend only, i want on dokan frontend upload form. Anyone know the code? I want comment on https://stackoverflow.com/a/42177288/6574214
but i not have reputation for that... :(