lisa82
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] Remove stock status field for certain product typeHi Caleb,
yes, I would want to hide the whole paragraph area, I just don’t know how to target the relevant paragraph.
I tried something similiar like they did in the link you provided (https://api.jquery.com/addclass/):
function hide_stock_status_field() { ?> <script> $( "p:last" ).addClass( "hide_if_test_product" ); </script> <?php } add_action('woocommerce_product_options_stock_status', 'hide_stock_status_field');
But the source code now just looks like that:
<p class="form-field _stock_status_field hide_if_variable hide_if_external"> <label for="_stock_status">Lagerstatus</label> <select id="_stock_status" name="_stock_status" class="select short" style="" > <option value="instock" selected='selected'>Vorr?tig</option> <option value="outofstock" >Nicht vorr?tig</option> </select> </p> <script> $( "p:last" ).addClass( "hide_if_test_product" ); </script>
So the code snippet has been added beneath the relevant paragraph, but the script didn’t add the class to the paragraph. Maybe I’m doing it all wrong? ??
Forum: Plugins
In reply to: [WooCommerce] Remove stock status field for certain product typeHi Caleb,
thanks again for your input, but I’m afraid it’s a bit more complicated, because the classes “hide_if_xxx” regarding the fields seem to be classes of the <p>-tag wrapped around the field and not classes of the field itself. Here is the source code:
<p class="form-field _stock_status_field hide_if_variable hide_if_external"> <label for="_stock_status">Lagerstatus</label> <select id="_stock_status" name="_stock_status" class="select short" style="" > <option value="instock" selected='selected'>Vorr?tig</option> <option value="outofstock" >Nicht vorr?tig</option> </select>
I managed to do something probably similar to hide one of the tabs, here is the code for that:
add_filter('woocommerce_product_data_tabs', function($tabs) { array_push($tabs['shipping']['class'], 'hide_if_test_product'); return $tabs; }, 10, 1);
But I have no idea how to do the same for a certain field instead of a tab. ??
Any ideas?
Forum: Plugins
In reply to: [WooCommerce] Remove stock status field for certain product typeHi,
thanks for your response, but unfortunately I’m a bit lost here (I’m no woocommerce/php expert). It’d be fine to just hide the field based on the selected product type, but how exactly do I add this class you mentioned to the stock status field? Do you maybe have a code snippet for me which I can put in my functions.php?
Thanks a lot!