Post by elpidios » Sun Jan 29, 2023 12:37 am

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>

New member

Posts

Joined
Wed Feb 28, 2018 2:26 am

Post by elpidios » Sun Jan 29, 2023 12:55 am

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>

New member

Posts

Joined
Wed Feb 28, 2018 2:26 am
Who is online

Users browsing this forum: No registered users and 106 guests