Tagged: ,

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

    Hi
    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.

    #734141

    Hey!

    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,
    Yigit

    #734283

    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.

    #734762

    Hi,

    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,
    Yigit

    #734765

    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.

    #734768

    Hi!

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

    Cheers!
    Yigit

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