search not working properly on my custom opencart theme
Probably you have moved your <?php echo $search; ?> outside the <header> tag.
so .... we are going to use the #search id
<div id="search" class="input-group">
<input type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php echo $text_search; ?>" class="form-control input-lg" />
<span class="input-group-btn">
<button type="button" class="btn btn-default btn-lg"><i class="fa fa-search"></i></button>
</span>
</div>
Solution
edit catalog/view/javascript/common.js
and after
add
or just replace
I've just added the if statement so that I can ignore in the future WHY it doesn't work at all and I can move the "small search" in and out the header.
It's the fastest way and I don't want to invest extra time understanding why it works this way.
Probably you have moved your <?php echo $search; ?> outside the <header> tag.
so .... we are going to use the #search id
<div id="search" class="input-group">
<input type="text" name="search" value="<?php echo $search; ?>" placeholder="<?php echo $text_search; ?>" class="form-control input-lg" />
<span class="input-group-btn">
<button type="button" class="btn btn-default btn-lg"><i class="fa fa-search"></i></button>
</span>
</div>
Solution
edit catalog/view/javascript/common.js
and after
var a=$("header input[name='search']").val();
add
if(!a){a=$("#search input[name='search']").val();}
or just replace
var a=$("header input[name='search']").val(); it swith
var a=$("#search input[name='search']").val();
I've just added the if statement so that I can ignore in the future WHY it doesn't work at all and I can move the "small search" in and out the header.
It's the fastest way and I don't want to invest extra time understanding why it works this way.
Thanks for such a great post you have shared here.
ReplyDeleteI am also facing the same issue. After reading the different forum, I tried to edit the common.js file.
ReplyDelete1) replaced header with #search
2) removed both search and header.
Still value appear in the url.
This is the website url. https://www.giftjaipur.com/test
Can you please help
@namar garg
ReplyDeleteThere's no trace of the modified script.
Do the necessary modifications and test.
Try to learn from what you are doing.