Post by Goinea92 » Sun Mar 22, 2015 2:15 am

Hello!

I need some help with the OpenCart filtering option. If I want to apply a filter for the products I have to check the needed option and then click a button to apply the filter.

What I would like to do is whenever I check an option on the filter the page would refresh automatically.

Here's the code for the filter:

Code: Select all

<div class="panel panel-default">
<div class="panel-heading"><?php echo $heading_title; ?></div>
<div class="list-group">
<?php foreach ($filter_groups as $filter_group) { ?>
<a class="list-group-item"><?php echo $filter_group['name']; ?></a>
<div class="list-group-item">
  <div id="filter-group<?php echo $filter_group['filter_group_id']; ?>">
    <?php foreach ($filter_group['filter'] as $filter) { ?>
    <?php if (in_array($filter['filter_id'], $filter_category)) { ?>
    <label class="checkbox">
      <input name="filter[]" type="checkbox" value="<?php echo      $filter['filter_id']; ?>" checked="checked" />
      <?php echo $filter['name']; ?></label>
    <?php } else { ?>
    <label class="checkbox">
      <input name="filter[]" type="checkbox" value="<?php echo $filter['filter_id']; ?>" />
      <?php echo $filter['name']; ?></label>
    <?php } ?>
    <?php } ?>
    </div>
  </div>
  <?php } ?>
 </div>
 <div class="panel-footer text-right">
<button type="button" id="button-filter" class="btn btn-primary"><?php echo $button_filter; ?></button>
</div>
</div>
<script type="text/javascript"><!--
$('#button-filter').on('click', function() {
filter = [];

$('input[name^=\'filter\']:checked').each(function(element) {
    filter.push(this.value);
});

location = '<?php echo $action; ?>&filter=' + filter.join(',');
});
//--></script> 
Thanks in advance!

Newbie

Posts

Joined
Mon Mar 16, 2015 4:56 am
Who is online

Users browsing this forum: No registered users and 52 guests