Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #733055

    Could you let me know how to add the Woocommerce SKU to the standard Enfold search please? It searches product titles OK so if there’s a way to configure it to have this functionality as well that would be great. There doesn’t seem to be a definitive answer on this forum or elsewhere.
    Thanks in advance for your assistance.



    Please try adding following code to Functions.php file in Appearance > Editor

    function get_product_by_sku( $sku ) {
      global $wpdb;
      $product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );
      if ( $product_id ) return new WC_Product( $product_id );
      return null;

    Best regards,


    Hi Yigit
    Thanks for the code which I added to my child theme functions file – but it doesn’t work for me :(
    The search works fine for product title or description though. Have you any further thoughts?
    Thanks again for your help.



    I am not sure if this plugin would work but you can try one similar to this one – https://wordpress.org/plugins/search-by-sku-for-woocommerce/
    Also, please feel free to contact WooCommerce team :)

    Best regards,


    Hey Yigit

    Thanks – I had already tried that plugin. I will head over to the Woocommerce team to see if they can assist any further.

    Again, your support is much appreciated.



    Not at all!
    I am marking this thread as resolved for now. Let us know if you have any other questions or issues :)


Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add woocommerce SKU to search’ is closed to new replies.