Automatically set _wcpv_product_commission
-
Hi,
I’m trying to automatize the product creation with a frontend form.
My aim is to initialize the field “Commission (Fixed):” with a fixed amount.
So I wrote this function:
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_role = 'administrator'; // Getting the current user object $user = wp_get_current_user(); // getting the roles of current user $user_roles = $user->roles; if (in_array($targeted_user_role, $user_roles)) { ## JQUERY SCRIPT ## // Here we set as selected the 'virtual' and 'downloadable' checkboxes ?> <script> (function($) { $(document).ready(function() { $('input[name=_downloadable]').prop('checked', true); $('#_wcpv_product_commission').val("75"); }); })(jQuery); </script> <?php } }
It works, but after I added the line
$(document).ready(function() { $('#_wcpv_product_commission').val("75"); });
I can’t see anymore the downloadable_files table, If I remove the document.ready the table riappears but I cannot grab anymore #_wcpv_product_commission.
What should I do ?
Thanks for your help
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Automatically set _wcpv_product_commission’ is closed to new replies.