• Resolved tarantinobcn

    (@tarantinobcn)


    Hello!

    I have checked the option “Hide out of stock items in the catalogue”, and therefore, the products out of stock do not appear in the searches of your plugin.

    I need that also appear in the search results, the products out of stock.

    Is it possible to show also the products out of stock, having this box checked?
    Thank you!

    https://ibb.co/DKcyFmd

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    Try this code snippet:

    // Force value of "Exclude "out of stock" products" option as "on"
    add_filter( 'dgwt/wcas/settings/load_value/key=exclude_out_of_stock', function ( $value ) {
    	if ( isset( $_REQUEST['wc-ajax'] ) && 'dgwt_wcas_ajax_search' === $_REQUEST['wc-ajax'] ) {
    		$value = 'off';
    	}
    
    	return $value;
    }, PHP_INT_MAX - 10 );
    

    You have two ways to add this code to your theme:

    1. Open the functions.php in your child theme and add the code at the end.
    2. or install the Code Snippets plugin and apply this code as a snippet.

    Regards,
    Kris

    Thread Starter tarantinobcn

    (@tarantinobcn)

    Hello!
    Thank you very much for the reply, but unfortunately the code generates the website breakage.

    I have tried pasting it using both methods, but both create an error on the website.

    Is it possible that there is something wrong with the code?
    I look forward to your comments, thank you very much.

    Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    Snippet doesn’t contain any syntax errors. To check what causes the error follow these steps:

    1. Add the following constants to your wp-config.php file, right before the /* That's all, stop editing! Happy publishing. */ line:
      define( 'WP_DEBUG', true );
      define( 'WP_DEBUG_LOG', true );
    2. Trigger the error, so that it gets logged.
    3. Open the file with logs: wp-content/debug.log.
    4. Check the logs for errors.
    5. After checking, remove the constant added in point 1 and remove the wp-content/debug.log file.

    Regards,
    Kris

    Thread Starter tarantinobcn

    (@tarantinobcn)

    Hello!
    I have followed the steps you have told me about, and here I attach some images with the errors that appear.
    I don’t know if I’m doing something wrong, but when I add the code, the website breaks and I have to delete the code.

    Do you know where the problem could be?
    Thank you very much!

    https://ibb.co/B61yjkh
    https://ibb.co/GQb6PFN
    https://ibb.co/84YkQ9Q

    Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    Error is here:?https://prnt.sc/bazbKsdO-YNa
    You need to change?&#091?into?[
    Probably an error occurred while copying and pasting the code.

    Regards,
    Kris

    • This reply was modified 1 year, 8 months ago by Kris.
    Thread Starter tarantinobcn

    (@tarantinobcn)

    Hi Kris!

    I have now been able to copy the code and the website is no longer broken, but I have tried the search bar and it does not search for out-of-stock products.

    The only way to see the out of stock products in the search bar is by unchecking the box I show in the attached image. The problem is that I need to have that box checked in my shop.

    https://prnt.sc/330b0Q5sZaD-

    https://prnt.sc/ehPihdV0G8H-

    Could it be that I’m missing one more step?

    Thank you very much for your help, Kris!

    • This reply was modified 1 year, 8 months ago by tarantinobcn.
    • This reply was modified 1 year, 8 months ago by tarantinobcn.
    Plugin Support Kris

    (@c0nst)

    Hi @tarantinobcn

    Try with higher priority. Replace the current code with this:

    add_filter( 'dgwt/wcas/settings/load_value/key=exclude_out_of_stock', function ( $value ) {
    	if ( isset( $_REQUEST['wc-ajax'] ) && 'dgwt_wcas_ajax_search' === $_REQUEST['wc-ajax'] ) {
    		$value = 'off';
    	}
    
    	return $value;
    }, PHP_INT_MAX - 5 );

    Regards,
    Kris

    Thread Starter tarantinobcn

    (@tarantinobcn)

    Thank you so much Kris! ??
    It works perfectly now.

    Best regards!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Show products out of stock’ is closed to new replies.