Answer the question
In order to leave comments, you need to log in
How to implement search for opencart 3.0?
I'm redoing the default theme of opencarat 3, but I'm stuck with the search, it doesn't work for some reason. I
tend to the script, tell me how to fix it so that it works, I return everything to the default data.
<div id="search" class="col-8 col-md-8 col-lg-5 col-xl-7">
<div class="search-input">
<input type="text" name="search" value="{{ search }}" placeholder="{{ text_search }}" class="no-round-input no-border" />
</div>
</div>
<div class="col-4 col-md-4 col-lg-3 col-xl-2">
<button type="button" class="no-round-btn">{{ text_search }}</button>
</div>
$('#search input[name=\'search\']').parent().find('button').on('click', function() {
var url = $('base').attr('href') + 'index.php?route=product/search';
var value = $('header #search input[name=\'search\']').val();
if (value) {
url += '&search=' + encodeURIComponent(value);
}
location = url;
});
$('#search input[name=\'search\']').on('keydown', function(e) {
if (e.keyCode == 13) {
$('#search input[name=\'search\']').parent().find('button').trigger('click');
}
});
Answer the question
In order to leave comments, you need to log in
There was a similar question
$('.button-search').bind('click', function() {
url = $('base').attr('href') + 'index.php?route=product/search';
var search = $('input[name=\'search\']').attr('value');
if (search) {
url += '&search=' + encodeURIComponent(search);
}
location = url;
});
$('#header input[name=\'search\']').bind('keydown', function(e) {
if (e.keyCode == 13) {
url = $('base').attr('href') + 'index.php?route=product/search';
var search = $('input[name=\'search\']').attr('value');
if (search) {
url += '&search=' + encodeURIComponent(search);
}
location = url;
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question