Home Woocommerce Woocommerce Custom Search With Select Query

Woocommerce Custom Search With Select Query

by therichpost
0 comment

Hello to all, welcome to therichpost.com. In this post, I will tell you, Woocommerce Custom Search  With Select Query.

Wordpress is the best CMS and Woocommerce is the best Ecommerce Plugin.

Woocommerce Custom Search  With Select Query, this is very basic thing but sometime, it is difficult to develop easy things so I am sharing this code on my blog.


Here is the working and tested code and you can this into your any wordpress theme’s template file:


<form method="get" id="productS">
<input type="text" name="searchtxt" class="" />
<button type="search"><i class="icon-search searcBtn"></i></button>
    global $wpdb;
    $result = $wpdb->get_results("SELECT * FROM `wp_posts` WHERE `post_title` like '%".$_GET['searchtxt']
    ."%' and post_type = 'product'");
    foreach ($result as $product) {
      $_product = wc_get_product( $product->ID );

      $attachment_ids[0] = get_post_thumbnail_id($product->ID);
      $attachment = wp_get_attachment_image_src($attachment_ids[0], 'thumbnail' );
      <li><img src="<?php echo $attachment[0] ?>" /></li>
      <li><?php echo $product->post_title ?></li>  
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
  jQuery(document).ready(function($) {
    $(".searcBtn").click(function(event) {

If you have any query related to this post, then do comment below or ask questions.

Thank you,




You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.