• Hello,

    I have several WooCommerce products marked with a custom field where, even if the stock is 0, I do not want to display the back in stock form. Is there a hook or function that I can use to unhook to prevent the form from being displayed?

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Good Day!!

    We’re here to assist you.

    Could you please share your specified out-of-stock product URL/link with us? This will help us to see the issue in action and better assist you.

    Thanks.

    Thread Starter Xaifu

    (@xaifu)

    Hello,

    This is a private website that is not open to unregistered users. I am currently using the following code to load conditional CSS:

    // Get the value of the custom field 'stock-letter' for the current product
    $tipo_stock = get_post_meta($product->get_id(), 'stock-letter', true);
    // If tipo_stock is not 'B', add custom CSS to hide the subscription form

    if ($tipo_stock !== 'B') { add_action('wp_head', function() { echo '<style>.cwginstock-subscribe-form {display: none !important}</style>'; }); }

    Can I use something similar to disable the generation of the form using a hook that prevents the form from being generated for these products?

    Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    We suggest using the option ‘Show/Hide Subscribe Form for specific products’.

    Go to Admin Dashboard -> Instock Notifier -> Settings -> Visibility Settings -> Show/Hide Subscribe Form for specific products.

    By using this option, you are able to easily show/hide the form for specific products without needing to delve into code or hooks.

    Thanks.

    Thread Starter Xaifu

    (@xaifu)

    Thank you for your response.

    The problem I have is that it is a website with more than 20,000 products and its stock is updated automatically through WP All Import, so I am looking for a solution that automatically deactivates the form on products with the value B in a custom field.

    That is why I am looking for a hook or some way to do it. If it is not possible, I will continue to use the method of hiding it conditionally by loading a CSS with display:none.

    Plugin Support CodeWooGeek Support

    (@codewoogeeksupport)

    Hello there,

    Thank you for sharing more details about your requirements.

    Here is the link to the sample code, where you need to map your data field name to get_post_meta and compare the value in the if condition.

    Link: https://gist.github.com/codewoogeek/00db9093a4a280cfb3a4fb081836913a

    Thanks.

    Thread Starter Xaifu

    (@xaifu)

    Hello,

    Thank you for the snippet. I haven’t had time to test it on my website until now.

    I’ve noticed that the snippet disables the subscription form but still shows the submit button. When the button is clicked, the form launches in a popup. This is odd since I have the form configured as inline in the plugin options.

    Is there a way to resolve this issue?

    Thank you for your invaluable help.

    peaveyweb

    (@peaveyweb)

    We’re seeing the same, on products where it shouldn’t show up using this filter the inline form is replaced with a button that opens the popup.

    The filter is controlling which variation of the plugin is displayed rather than whether or not it is displayed.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.