Woocommerce Filtering

I have created a filter box which pulls my WooCommerce attributes for the size and colour of the product but when choosing them in the dropdown it does not filter. how does this functionality work? here is my code hopefully someone can shed a light on it.

<div class=”filters”>
<h4>Filter by</h4>
<form id=”filter-by”>
<div class=”form-group”>
<?php $colours = $product->get_attribute( ‘colour’ ); $colours = explode(“, “,$colours); ?>
<?php if($colours[0]!=”){ // if product sizes are defined ?>
<select class=”form-control input-lg ” data-style=”btn-lg btn-default”>
<option>Any Colour</option>
<?php foreach($colours as $colour){ ?>
<option><?php echo $colour; ?></option>
<?php } ?>
</select>
<?php } ?>

<div class=”form-group”>
</div>
<?php $sizes = $product->get_attribute( ‘size’ ); $sizes = explode(“, “,$sizes); ?>
<?php if($sizes[1]!=”){ // if product sizes are defined ?>
<select class=”form-control input-lg” data-style=”btn-lg btn-default”>
<option>Any Size</option>
<?php foreach($sizes as $size){ ?>

<option><?php echo $size; ?></option>
<?php } ?>
</select>
<?php } ?>
</div>
</form>
</div>

Read more here:: Woocommerce Filtering

Leave a Reply

Your email address will not be published. Required fields are marked *