为什么我不能在shopify中搜索空格我该怎么办?

时间:2015-12-31 00:19:11

标签: shopify liquid

更新

好的,我知道问题是什么,但不知道如何解决问题 供应商:牛角或标题:牛角不起作用
标题:牛角或供应商:牛角确实。

空格导致额外的前缀在我的搜索结果中“OR”无法正常工作时中断 供应商:牛或冠名:牛作品
但是当我在搜索中放置一个空格时,标题将不会被搜索。

我有一个搜索栏,我将其设置为搜索商品标签,供应商&称号。
问题是这段代码阻止我在搜索词中使用空格,如果我追加“*”,我就无法使用&符号。这是代码。

<form method="get" action="/search" id="search-home">
   <button type="submit" value="search"></button>
   <input type="hidden" name="type" value="product" />
   <input type="hidden" name="q" class="searchtext" />
   <input type="text" name="original" placeholder="Search"/>
</form>

<script>
$(document).on('submit','#search-home',function(){
var searchtext = $('input[name="original"]').val();
$('.searchtext').val("vendor:"+searchtext+" OR tag:"+searchtext+" OR title:"+searchtext);
});
</script>

如果你需要在这里看到search.liquid。

<div id="impact-grid-header" class="collections-page">
   <h1 id="regular-title">Search Results for: "{{ search.terms[1] | replace: 'vendor:', ''  | replace: 'tag:', '' | replace: 'title:', '' | replace: '*', '' | strip  | escape}}"</h1>
</div>
<div id="product-content" class="full-bleed">
<div class="content">
   {% paginate search.results by 20 %}
   <!-- Begin collection info -->
   <div class="row">
      <!-- End sort collection -->
      <div class="column inventory-items">
         {% include 'search-bar' %}
         <div id="inventory" class="span12 content-grid">
            <!-- Begin no products -->
            {% if search.results.size == 0 %}
            <div class="row">
               <div class="span12 expanded-message">
                  <p>That's a great idea but unfortunately we don't have that item.<br/>Try again?</p>
               </div>
            </div>
            {% endif %}
            <div class="row products">
               {% for item in search.results limit: settings.pagination_limit %}
               {% if item.variants.first.inventory_quantity >= 0 %}
               <div class="item product" data-tags="{% for tag in item.tags %}{{ tag | downcase }}, {% endfor %}">
                  <a href="{{ item.url }}">
                     <div class="product-pic">
                        <div class="inner-pic">
                           <img src="{{ item.featured_image | product_img_url: 'large' }}" alt="{{ item.title | escape  }}"/>
                        </div>
                        <!-- Box that appears upon hover -->
                        <div class="view-product bg-black">
                           <i class="icon-search"></i>
                           <span>View</span>
                        </div>
                     </div>
                  </a>
                  <div class="description">
                     <a href="{{ item.url }}"><span class="product-name">{{ item.title }}</span></a>
                     <span class="brand">{{ item.vendor }}</span>
                     <span class="price">
                     {% if item.available %}
                     {% if item.compare_at_price_max > item.price %}
                     <del>{{ item.compare_at_price | money }}</del>
                     {% endif %}
                     {% if item.price_varies %}
                     <em>from</em>
                     {% endif %}
                     <span>{{ item.price | money }}</span>
                     {% else %}
                     <span>
                     {{ item.price | money }} Sold Out
                     </span>
                     {% endif %}
                     </span>
                     <span class="shopify-product-reviews-badge" data-id="{{ product.id }}"></span>
                  </div>
               </div>
               {% endif %}
               {% endfor %}
            </div>
            {% include 'pagination' %}
            {% endpaginate %}
            <!-- End no products -->
         </div>
      </div>
   </div>
</div>

0 个答案:

没有答案