Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @alf131!

    Use this code snippet:

    add_filter( 'dgwt/wcas/search_query/args', function( $args ) {
      $args['meta_query'][] = array(
        'key'     => '_sale_price',
        'compare' => 'NOT EXISTS',
      );
    
      return $args;
    } );

    You have two ways to add this code to your theme:
    Open the functions.php in your child theme and add the code at the end.
    or install the Code Snippets plugin and apply this code as a snippet.

    Regards,
    Kris

    Thread Starter alf131

    (@alf131)

    Thanks for the help. Yousure this is the right code for discontinued?

    @alf131

    Yes, you’re right. I confused the word with discounted.

    You probably use a plugin that creates its meta key. Are you able to check this key in the database in the _postmeta table?

    I think it will be _discontinued, but we should make sure.

    Thread Starter alf131

    (@alf131)

    I am sorry but I am not sure where I can check this. What plugin do you mean?

    Hi @alf131

    Please try this code snippet it should work. I assumed that the Discontinued stock status value is discontinued

    add_filter( 'dgwt/wcas/search_query/args', function( $args ) {
      $args['meta_query'][] = array(
        'key'     => '_stock_status',
        'value'   => 'discontinued',
        'compare' => 'NOT IN'
      );
    
      return $args;
    } );

    Regards,
    Kris

    Thread Starter alf131

    (@alf131)

    Thank you for help again. Can I paste this code in the Integration>add code to the body
    in the Divi builder?

    Hi @alf131

    This is a PHP code, so you have two ways to add this code to your theme:

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How can I exclude discontinued products’ is closed to new replies.