Hi
I need to autocomplete the filters on Opencart 3.
I am 100% sure that i need to change that code on the file filter.twig of my template
I found some code for opencart 2 but not working for 3
HERE THE ORIGINAL OPENCART 3 CODE
<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
filter = [];
$('input[name^=\'filter\']:checked').each(function(element) {
filter.push(this.value);
});
location = '{{ action }}&filter=' + filter.join(',');
});
//--></script>
THIS IS THE OPENCART 2 WHICH IS NOT WORKING FOR OPENCART 3
<script type="text/javascript">
$(document).ready(function() {
$('#button-filter').hide();
$('input[name^=\'filter\']').on('change', function() {
filter = [];
$('input[name^=\'filter\']:checked').each(function(element) {
filter.push(this.value);
});
location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
});
</script>
I found and i wrote a code and is working. Because is not existing on Opencart 3 i will share it with you. Need to change this, on that directory
catalog/view/theme/ YOUR THEME /template/extension/module/filter.twig
<script type="text/javascript">
$(document).ready(function() {
$('#button-filter').hide();
$('input[name^=\'filter\']').on('change', function() {
filter = [];
$('input[name^=\'filter\']:checked').each(function(element) {
filter.push(this.value);
});
location = '{{ action }}&filter=' + filter.join(',');
});
});
</script>
catalog/view/theme/ YOUR THEME /template/extension/module/filter.twig
<script type="text/javascript">
$(document).ready(function() {
$('#button-filter').hide();
$('input[name^=\'filter\']').on('change', function() {
filter = [];
$('input[name^=\'filter\']:checked').each(function(element) {
filter.push(this.value);
});
location = '{{ action }}&filter=' + filter.join(',');
});
});
</script>
Who is online
Users browsing this forum: adycobra2003, nonnedelectari, Semrush [Bot] and 140 guests