Lightspeed: Search
Lightspeed
Search
Usa in IA Apri in ChatGPT
Fai domande su questa pagina
Apri in Claude
Fai domande su questa pagina
Apri in Perplexity
Fai domande su questa pagina
Copia pagina
Copia pagina come markdown per LLM
Visualizza come Markdown
Vedi questa pagina in testo semplice Aggiungi una potente funzionalità di ricerca al tuo webshop Lightspeed.
Clerk.io offre tre soluzioni di Search distinte che possono essere utilizzate insieme o separatamente:
Questo articolo spiega come iniziare con Search su Lightspeed.
Generale
# Per incorporare il tuo embed code sia per Live Search che per Search Page, dovrai accedere ai file del tuo tema. Per farlo, clicca su “Design” nel menu a sinistra, poi clicca su “Code bewerken” nel menu a tendina Geavanceerd
Per aggiungere i dettagli di sincronizzazione o avviare una sincronizzazione, vai su my.clerk.io > Data > Configuration .
Instant Search
# Instant Search fornisce risultati di ricerca in tempo reale mentre i clienti digitano, visualizzati in un menu a discesa sotto il campo di input della ricerca.
Crea Design
# Puoi utilizzare il
Design Editor per configurarlo visivamente, o utilizzare
code designs .
Design Editor
# Vai su Search > Designs e clicca su New Design. Scegli Other designs > Instant Search. Dalla lista dei template design, scegli con quale vuoi iniziare. Dagli un nome e clicca su Create design. Apporta eventuali modifiche al design. Code Design
# Vai su Search > Designs e clicca su New Design. Scegli Other designs > Blank > With code. Dagli un nome e clicca su Save. Crea un design con codice da zero usando
Liquid code . Se vuoi un design di partenza, consulta il
template Instant Search più in basso.
Crea Element
# Contiene tutte le impostazioni utilizzate per mostrare il menu a discesa Instant Search, rendendolo integrabile nel tuo sito web.
Vai su Search > Elements. Clicca su New Element. Nominalo “Live Search”. In Element type , seleziona Live-search dal menu a discesa. In Design seleziona il design che hai creato. Clicca su Save in alto nella schermata. Aggiungi al Sito Web
# Nel tuo file di layout principale (probabilmente fixed.rain oppure custom.rain ), inserisci il codice embed di Live Search appena prima del tag di chiusura
.
Aggiorna il placeholder all’interno di “data-instant-search” per includere la classe o l’ID della query utilizzato nel tuo webshop (in questo esempio, “#searchInput”). <span
class = "clerk"
data-template = "@live-search"
data-instant-search-suggestions = "6"
data-instant-search-categories = "6"
data-instant-search-pages = "6"
data-instant-search = "#searchInput"
data-instant-search-positioning = "left" >
</span >
Search Page
#
La Search Page offre un’esperienza di ricerca a pagina intera con opzioni di filtro avanzate. Viene utilizzata per mostrare tutte le corrispondenze per una query di ricerca del cliente.
Crea Design
# Puoi utilizzare il
Design Editor per configurarlo visivamente, o utilizzare
code designs .
Design Editor
# Vai su Search > Designs e clicca su New Design. Scegli Other designs > Search Page. Dalla lista dei template design, scegli con quale vuoi iniziare. Dagli un nome e clicca su Create design. Apporta eventuali modifiche al design. Code Design
# Vai su Search > Designs e clicca su New Design. Scegli Other designs > Blank > With code. Dagli un nome e clicca su Save. Crea un design con codice da zero usando
Liquid code . Se vuoi un design di partenza, consulta il
template Search Page più in basso.
Crea Element
# Contiene tutte le impostazioni utilizzate per mostrare la Search Page e renderla integrabile nella tua pagina di ricerca preesistente.
Vai su Search > Elements. Clicca su New Element. Nominalo “Search Page”. In Element type , seleziona Search page dal menu a discesa. In Design seleziona il design che hai creato. Clicca su Save in alto nella schermata. Aggiungi al Sito Web
# In Lightspeed, la Search Page si trova all’interno del file Categories (collection.rain ).
Dopo aver creato il tuo Search Page Element e Design su my.clerk.io, inserisci il codice embed Search Page ovunque desideri che appaia la pagina nel codice collection.rain.
Assicurati di aggiornare data-query per fare riferimento correttamente alla query di ricerca; in Lightspeed, è {{page.search}}.
Aggiungi un’istruzione “if” per fare riferimento correttamente alla pagina di ricerca e tornare al codice della categoria quando non è una Search Page: {% if page.search %}
<div class = "page-width clerk-page-width" >
<span
id = "clerk-search"
class = "clerk"
data-template = "@search-page"
data-target = "#clerk-search-results"
data-query = "{{ page.search }}"
data-facets-attributes = '["price","categories","vendor"]'
data-facets-titles = '{"price":"Price","categories":"Categories","vendor":"Brand"}'
data-facets-target = "#clerk-search-filters"
data-facets-price-prepend = "€"
data-facets-in-url = "false"
data-facets-view-more-text = "View More"
data-facets-searchbox-text = "Search for " >
</span >
<div id = "clerk-show-facets" onclick = "toggleFacets()" >Filtri</div >
<div class = "clerk_flex_wrap" >
<div id = "clerk-facets-container" >
<div id = "clerk-search-filters" ></div >
</div >
<div id = "clerk-search-results" ></div >
</div >
<script >
function toggleFacets (){
el = document.getElementById ('clerk-facets-container' );
el .classList .toggle ('active' );
}
</script >
<style >
#clerk-show-facets { width : 70 % ; height : 40 px ; margin : 20 px auto ; background-color : #333 ; color : white ; text-align : center ; border-radius : 2 px ; line-height : 40 px ; cursor : pointer ; }
.clerk-page-width { display : flow - root; }
#clerk-search-results { width : 80 % ; }
#clerk-show-facets { display : none ; }
.clerk_flex_wrap { display : flex ; flex-direction : row ; }
.active { display : block !important ; }
@media only screen and ( max-width : 800px ) {
#clerk-search-filters { width : 100 % !important ; }
#clerk-facets-container { display : none ; }
#clerk-show-facets { display : block ; }
.clerk_flex_wrap { flex-direction : column ; }
#clerk-search-results { display : block ; width : 100 % ; }
}
</style >
</div >
{% else %}
<!--CATEGORY_CODE_HERE-->
{% endif %}
Se hai preparato uno snippet per la tua pagina di ricerca (qualcosa come snippets/search.rain ), assicurati di commentare l’intero snippet per evitare che questa pagina venga popolata nel tuo webshop.
Assicurati anche che il tuo codice categoria sia posizionato dove è scritto CATEGORY_CODE_HERE nell’esempio sopra.
Omnisearch
# Omnisearch combina Instant Search e Search Page in un unico overlay che si apre quando l’utente pone il focus sul campo di input della ricerca.
Crea Design
# Omnisearch utilizza un design con codice.
Vai su Search > Designs e clicca su New Design. Scegli Omni-search. Scegli un template, dagli un nome e clicca su Save. Modifica il design secondo necessità. Consulta la
guida Omnisearch per i dettagli. Crea Element
# Vai su Search > Elements. Clicca su New Element. Nominalo “Omni-Search”. In Element type , seleziona Omni-search . In Design seleziona il tuo design Omnisearch. Clicca su Save . Aggiungi al Sito Web
# Puoi inserire Omnisearch usando
injection o
embedded code .
Se utilizzi embedded code, imposta un selettore CSS per l’input di ricerca usando data-trigger-element.
Esempio di codice embed:
<span class = "clerk"
data-template = "@omni-search"
data-api = "search/omni"
data-trigger-element = "#search" >
</span >
Template di Partenza
# Se vuoi usare code designs, questi template possono aiutarti a iniziare. Contengono gli elementi base dell’interfaccia per Instant Search e Search Page, che potrai poi modificare secondo le tue esigenze.
Codice Instant Search
# Contiene le parti HTML e CSS per visualizzare un menu a discesa Instant Search. Aggiungile a un code design in my.clerk.io.
HTML
# <div class = "clerk-instant-search" >
{% if hits.length == 0 %}
<div class = "clerk-instant-search-no-results" >
Nessun risultato per: <b >{{ query }}</b >... prova a cercare in modo più semplice!
</div >
{% endif %}
{% if content.query != response.query %}
<div class = "clerk-instant-search-alternate-query" >
<i class = "fas fa-search clerk-icon" aria-hidden = "true" ></i > Mostro risultati per: <b >{{ query }}</b >
</div >
{% endif %}
<div class = "clerk-instant-search-grid" >
{% if products.length > 0 %}
<div class = "clerk-instant-search-col clerk-col-1" >
<div class = "clerk-instant-search-products" >
<div class = "clerk-instant-search-title" >Prodotti</div >
{% for product in products %}
<a href = "{{ product.url }}" >
<div class = "clerk-instant-search-product clerk-instant-search-key-selectable" >
<div class = "clerk-instant-search-product-image" style = "background-image: url('{{ product.image }}');" ></div >
<div >
<div class = "clerk-instant-search-product-name" >{{ product.name | highlight query }}</div >
{% if product.price < product.list_price %}
< div class = "clerk-instant-search-product-list-price" >{{ product.list_price | money }}</div >
{% endif %}
<div class = "clerk-instant-search-product-price" >{{ product.price | money }}</div >
</div >
<div >
<div class = "clerk-instant-search-product-button" >Acquista ora</div >
</div >
</div >
</a >
{% endfor %}
{% if hits > products.length %}
<div class = "clerk-desktop-button clerk-instant-search-more-results clerk-instant-search-key-selectable" >
<a class = "clerk-view-more-results-button" href = "/search?q={{ query }}" >
<u >Vedi <b >{{ hits }}</b > altri risultati per "<i >{{ query }}</i >"</u >
</a >
</div >
{% endif %}
</div >
</div >
{% endif %}
{% if (suggestions.length + categories.length + pages.length) > 0 %}
<div class = "clerk-instant-search-col clerk-col-2" >
{% if suggestions.length > 1 %}
<div class = "clerk-instant-search-suggestions" >
<div class = "clerk-instant-search-title" >Suggerimenti di ricerca</div >
{% for suggestion in suggestions %}
{% if suggestion != query %}
<div class = "clerk-instant-search-suggestion clerk-instant-search-key-selectable" >
<a href = "/search?q={{ suggestion highlight query 'bold' true }}" >
<i class = "fas fa-search clerk-icon" aria-hidden = "true" ></i >{{ suggestion }}
</a >
</div >
{% endif %}
{% endfor %}
</div >
{% endif %}
{% if categories.length > 0 %}
<div class = "clerk-instant-search-categories" >
<div class = "clerk-instant-search-title" >Categorie</div >
{% for category in categories %}
<div class = "clerk-instant-search-category clerk-instant-search-key-selectable" >
<a href = "{{ category.url }}" >
{{ category.name | highlight query }}
</a >
</div >
{% endfor %}
</div >
{% endif %}
{% if pages.length > 0 %}
<div class = "clerk-instant-search-pages" >
<div class = "clerk-instant-search-title" >Contenuti correlati</div >
{% for page in pages %}
<div class = "clerk-instant-search-category clerk-instant-search-key-selectable" >
<a href = "{{ page.url }}" >
<div class = "name" >{{ page.title | highlight query 'bold' true }}</div >
</a >
</div >
{% endfor %}
</div >
{% endif %}
</div >
{% endif %}
{% if hits > products.length %}
<div class = "clerk-mobile-button clerk-instant-search-more-results clerk-instant-search-key-selectable" >
<a href = "/search?q={{ query }}" >
Vedi <b >{{ hits }}</b > altri risultati per "<i >{{ query }}</i >"
</a >
</div >
{% endif %}
</div >
</div >
CSS
# .clerk-instant-search { padding : 20 px ; }
.clerk-instant-search-container a { color : black !important ; text-decoration : none !important ; }
.clerk-instant-search-container a :hover { color : #b6c254 !important ; }
.clerk-instant-search { overflow : hidden ; width : 100 % ; min-width : 650 px ; max-width : 1000 px ; margin : .2 em auto ; background-color : white ; border : 1 px solid #eee ; border-top : 0 px ; border-radius : 5 px 5 px 10 px 10 px ; box-shadow : 0 1 em 2 em 1 em rgba(0 ,0 ,0 ,.2 ); }
.clerk-instant-search-no-results { padding : 1 em ; font-style : italic ; text-align : center ; }
.clerk-instant-search-alternate-query { margin : 0 0 5 px 0 ; }
.clerk-instant-search-more-results { padding : 1 em ; font-size : 1.2 em ; text-align : center ; }
.clerk-instant-search-title { color : #b6c254 ; margin : 20 px 0 5 px ; padding : 0 0 10 px ; text-transform : uppercase ; font-size : 1 em ; border-bottom : 1 px solid #000 ; }
.clerk-instant-search-products { padding-right : 2 em ; }
.clerk-instant-search-product { display : flex ; padding : .2 em ; color : gray ; }
.clerk-instant-search-product :hover { background-color : rgba(46 , 204 , 113 , .1 ); }
.clerk-instant-search-product :hover .clerk-instant-search-product-button { transform : scale(1.05 ); }
.clerk-instant-search-product > * { flex : 1 1 auto ; }
.clerk-instant-search-product > * :first-child , .clerk-instant-search-product > * :last-child { flex : 0 0 auto ; }
.clerk-instant-search-product-image { display : inline-block ; width : 3 em ; height : 3 em ; margin-right : 1 em ; background-position : center center ; background-repeat : no-repeat ; background-size : contain ; }
.clerk-instant-search-product-name { overflow : hidden ; height : 1.2 em ; margin-bottom : .2 em ; }
.clerk-instant-search-product-list-price { display : inline-block ; margin-right : .5 em ; opacity : .8 ; font-weight : normal ; text-decoration : line-through ; color : gray ; }
.clerk-instant-search-product-price { display : inline-block ; font-weight : bold ; }
.clerk-icon { color : lightgray ; margin-right : .5 em ; }
.clerk-instant-search-suggestions { margin-bottom : 1 em ; }
.clerk-instant-search-suggestion { padding : .1 em ; }
.clerk-instant-search-categories { margin-bottom : 1 em ; }
.clerk-instant-search-category { padding : 5 px ; margin : 5 px ; width : auto ; display : inline-block ; border : 1 px solid black ; border-radius : 2 px ; }
.clerk-instant-search-pages { margin-bottom : 1 em ; }
.clerk-instant-search-page { padding : .1 em ; }
@media screen and ( min-width : 1200px ) { .clerk-instant-search-container { width : 50 % ; } .clerk-instant-search-grid { display : flex ; } .clerk-col-1 { flex : 2 ; } .clerk-col-2 { flex : 1 ; } .clerk-mobile-button { display : none ; } }
@media screen and ( min-width : 768px ) and ( max-width : 1200px ) { .clerk-instant-search-container { right : 0 !important ; left : 0 !important ; } .clerk-mobile-button { display : none ; } }
@media screen and ( max-width : 767px ) { .clerk-instant-search-container { right : 0 !important ; } .clerk-desktop-button { display : none ; } }
@media screen and ( min-width : 376px ) and ( max-width : 800px ) { .clerk-instant-search { min-width : 0 !important ; } }
@media screen and ( max-width : 375px ) { .clerk-instant-search { min-width : 200 px !important ; } .clerk-instant-search-col { margin : 0 0 20 px 0 ; } .clerk-instant-search-product-name { height : 3 em !important ; } }
Codice Search Page
# Contiene le parti HTML e CSS per visualizzare una Search Page. Aggiungile a un code design in my.clerk.io.
HTML
# <div class = "clerk-search-result" >
<div class = "clerk-search-result-headline" >{{ headline }}</div >
<div class = "clerk-grid" >
{% for product in products %}
<div class = "clerk-grid-item" >
<div class = "clerk-grid-product" >
<a href = "{{ product.url }}" >
{% if product.price < product.list_price %}
< div class = "clerk-grid-badge" >In Offerta</div >
{% endif %}
<div class = "clerk-grid-image" style = "background-image: url('{{ product.image }}');" ></div >
<div class = "clerk-grid-brand" >{{ product.brand }}</div >
<div class = "clerk-grid-name" >{{ product.name }}</div >
<div class = "clerk-grid-pricing" >
{% if product.price < product.retail_price %}
< div class = "clerk-grid-list-price" >£{{ product.retail_price | money }}</div >
{% endif %}
<div class = "clerk-grid-price" >£{{ product.price | money }}</div >
</div >
</a >
{% if product.stock == 1 %}
<a class = "clerk-not-in-stock" href = "{{ product.url }}" data-event-type = "product-click" >
<div class = "clerk-grid-button-not-in-stock" >Non disponibile</div >
</a >
{% else %}
<a class = "clerk-add-to-cart" href = "/cart.php?action=add&product_id={{ product.id }}" data-event-type = "product-click" >
<div class = "clerk-grid-button" >Aggiungi al Carrello</div >
</a >
{% endif %}
</div >
</div >
{% endfor %}
</div >
{% if count > products.length %}
<div class = "clerk-load-more-button" onclick = "Clerk('content', '#{{ content.id }}', 'more', 40);" >Mostra altri risultati</div >
{% endif %}
</div >
CSS
# #clerk-search-results { margin : 0 ; }
.clerk-search-result { margin : 1 em 0 ; }
.clerk-search-result-headline { font-weight : bold ; font-size : 2 em ; text-align : center ; }
.clerk-grid { display : flex ; flex-flow : row wrap ; }
.clerk-grid-item { margin : auto ; }
.clerk-grid-product { position : relative ; overflow : hidden ; margin : 1 em ; padding : 1 em ; background-color : white ; border : 1 px solid #eee ; border-radius : 1 em ; box-shadow : 0 .1 em .2 em 0 rgba(0 ,0 ,0 ,.08 ); text-align : center ; }
.clerk-grid-badge { position : absolute ; top : 5 px ; right : -35 px ; display : inline-block ; width : 120 px ; margin : 10 px auto ; padding : 5 px 0 ; border-radius : 3 px ; background-color : #fbc531 ; font-size : 10 px ; color : white ; text-align : center ; letter-spacing : 1 px ; transform : rotate(45 deg ); }
.clerk-grid-tags { position : absolute ; top : .8 em ; left : .8 em ; }
.clerk-grid-tag { display : inline-block ; padding : .2 em .8 em ; border-radius : .3 em ; background-color : gray ; font-size : 10 px ; color : white ; letter-spacing : 1 px ; }
.clerk-grid-image { width : 100 % ; height : 8 em ; margin-bottom : 1 em ; background-position : center center ; background-repeat : no-repeat ; background-size : contain ; }
.clerk-grid-brand { font-size : 0.9 em ; color : #757575 ; }
.clerk-grid-name { height : 3 em ; overflow : hidden ; color : #4a3b40 ; font-weight :bold ; font-size : 15 px ; margin-bottom : 1 em ; }
.clerk-grid-pricing { display : flex ; margin-bottom : 1 em ; }
.clerk-grid-price { flex : 1 ; color : #757575 ; font-weight : bold ; }
.clerk-grid-list-price { flex : 1 ; opacity : .8 ; font-weight : normal ; text-decoration : line-through ; color : gray ; }
.clerk-add-to-cart , .clerk-add-to-cart :hover { color : white ; }
.clerk-not-in-stock , .clerk-not-in-stock :hover { color : #4a3b40 ; }
.clerk-grid-button-not-in-stock { display : block ; margin : 0 auto ; padding : .6 em 2 em ; border : none ; border-radius : .5 em ; background-color : white ; color : #4a3b40 ; text-transform : uppercase ; text-align : center ; white-space : nowrap ; font-weight : bold ; cursor : pointer ; }
.clerk-grid-button { display : block ; margin : 0 auto ; padding : .6 em 2 em ; border : none ; border-radius : .5 em ; background-color : #b6c254 ; color : white ; text-transform : uppercase ; text-align : center ; white-space : nowrap ; font-weight : bold ; cursor : pointer ; }
.clerk-load-more-button { display : block ; width : 20 em ; margin : 1 em auto ; padding : .6 em 2 em ; border : none ; border-radius : .5 em ; background-color : #b6c254 ; color : white ; text-transform : uppercase ; text-align : center ; white-space : nowrap ; font-weight : bold ; font-size : 1.2 em ; cursor : pointer ; }
@media screen and ( min-width : 1025px ) { .clerk-grid-item { flex : 0 0 25 % ; margin : auto ; } }
@media screen and ( min-width : 500px ) and ( max-width : 1024px ) { .clerk-grid-item { flex : 0 0 33 % ; margin : auto ; } }
@media screen and ( max-width : 499px ) { .clerk-grid-item { flex : 0 0 100 % ; margin : auto ; } }
Questa pagina è stata tradotta da un'utile intelligenza artificiale, quindi potrebbero esserci errori linguistici. Grazie per la comprensione.