OPencart 1.4.9.6 - however, I suspect this question would apply the same to the 1.5.x versions.
When on the Products page in the Admin area, you can type a value in any field, and press enter to trigger the Filter function. However, this functionality does not carry across to many of the other pages where it would be highly desireable, such as when you are wanting to filter your orders on the Orders page. How can this be corrected - my assumption is that there's a way to instruct the page to treat pressing Enter the same as clicking on the Filter button, but I'm not sure how to fix it on the pages where it doesn't work.
When on the Products page in the Admin area, you can type a value in any field, and press enter to trigger the Filter function. However, this functionality does not carry across to many of the other pages where it would be highly desireable, such as when you are wanting to filter your orders on the Orders page. How can this be corrected - my assumption is that there's a way to instruct the page to treat pressing Enter the same as clicking on the Filter button, but I'm not sure how to fix it on the pages where it doesn't work.
It is done via javascript:
In your common.js file here is an example of the search bar using it on the customer side:
In your common.js file here is an example of the search bar using it on the customer side:
Code: Select all
$('#header input[name=\'filter_name\']').bind('keydown', function(e) {
if (e.keyCode == 13) {
url = $('base').attr('href') + 'index.php?route=product/search';
var filter_name = $('input[name=\'filter_name\']').attr('value');
if (filter_name) {
url += '&filter_name=' + encodeURIComponent(filter_name);
}
location = url;
}
});
Thank you avvici. Solved my problem in search bar.
- OpenCart 1.5.3.1
- Default theme
- OpenCart 1.5.3.1
- Default theme
outoftheordinary
Finally getting a chance to come back to this...I don't see a common.js file on the catalog side, or the admin side. But to be frank, I wouldn't know what to do with it if I did. I would have though this would be coded into the template for each page?avvici wrote:It is done via javascript:
In your common.js file here is an example of the search bar using it on the customer side: (snipped)
there was no common.js file in v1.4x, avvici used example of 1.5.x opencart.Sidecutter wrote:I don't see a common.js file on the catalog side, or the admin side. ... I would have though this would be coded into the template for each page?
it don't have to be coded in all template page, just use the id's or classes from templates and write the corresponding java-script code in common.js. just a create common.js file in catalog/admin/view/javascript folder and add its link in catalog/admin/view/common/header.tpl like
Code: Select all
<script type="text/javascript" src="catalog/view/javascript/common.js"></script>
Yeah, that's a bit above what I'm comfortable with, and I know literally zero about what a JS file would need to contain. I'd be much more comfortable adding to or altering the specific button code on the necessary pages, if it's possible to do so.
OK, failing that...you hit enter on the Products page and it searches...where's the piece of code that makes it work on that page, but is missing from the others? If I know where that is I figure I have good odds of being able to replicate or modify it.
its located at the bottom of product_list.tplSidecutter wrote:where's the piece of code that makes it work on that page, but is missing from the others? .
Code: Select all
<script type="text/javascript"><!--
$('#form input').keydown(function(e) {
if (e.keyCode == 13) {
filter();
}
});
//--></script>
*EDIT* added the code to customer_list and sales_list, and it works with anything that isn't a flyout or dropdown selection, so anything you would normally enter text on, which is exactly what I needed. Finding orders to update them was a huge pain because of having to shift so often between keyboard and mouse.ChetanCx wrote:its located at the bottom of product_list.tplSidecutter wrote:where's the piece of code that makes it work on that page, but is missing from the others? .here 13 is the ASCII code of enter or returnCode: Select all
<script type="text/javascript"><!-- $('#form input').keydown(function(e) { if (e.keyCode == 13) { filter(); } }); //--></script>
For opencart 2.0.3.1 you can paste this code:
just above
in admin/view/template/catalog/product_list.tpl
Code: Select all
$(document).keypress(function(e) {
if(e.which == 13) {
$("#button-filter").click();
}
});
Code: Select all
$('#button-filter').on('click', function() {
On version 2.1.0.1 is not working!Nonsense wrote: ↑Thu Sep 08, 2016 3:53 pmFor opencart 2.0.3.1 you can paste this code:
just aboveCode: Select all
$(document).keypress(function(e) { if(e.which == 13) { $("#button-filter").click(); } });
in admin/view/template/catalog/product_list.tplCode: Select all
$('#button-filter').on('click', function() {
This worked for me on OC 2.3.0.2Nonsense wrote: ↑Thu Sep 08, 2016 3:53 pmFor opencart 2.0.3.1 you can paste this code:
just aboveCode: Select all
$(document).keypress(function(e) { if(e.which == 13) { $("#button-filter").click(); } });
in admin/view/template/catalog/product_list.tplCode: Select all
$('#button-filter').on('click', function() {
Just wanted to note, my OpenCart Admin Improvements extension adds this functionality, as well as a bunch of other admin panel improvements. If you can't get the code snippets in this topic working for your particular OpenCart version, it might be an easier option.
I just wrote it for 3.0.2.0
Add in file admin/view/template/catalog/product_list.twig at the end, below last
Code: Select all
//--></script>
Code: Select all
</div>
{{ footer }}
Code: Select all
<script type="text/javascript"><!--
const buttonFilter = document.getElementById('button-filter');
document.getElementById('input-name').addEventListener('keypress', function (e) {
if (e.keyCode === 13)
buttonFilter.click();
});
document.getElementById('input-model').addEventListener('keypress', function (e) {
if (e.keyCode === 13)
buttonFilter.click();
});
document.getElementById('input-price').addEventListener('keypress', function (e) {
if (e.keyCode === 13)
buttonFilter.click();
});
document.getElementById('input-quantity').addEventListener('keypress', function (e) {
if (e.keyCode === 13)
buttonFilter.click();
});
document.getElementById('input-status').addEventListener('keypress', function (e) {
if (e.keyCode === 13)
buttonFilter.click();
});
//--></script>
Who is online
Users browsing this forum: No registered users and 209 guests