I downloaded the BeRocket AJAX Filter plugin and it has changed the way my url query strings are formatted and now my function for getting product images won't work.
This is how I was getting the query string;
<php $filter_colour = $_GET['filter_colour']; ?>
This worked fine when my query string was like so;
www.website.co.uk/?filter_color=blue&filter_type_of_light=something
But now I can only have my query strings like the following by altering the settings in the plugin;
www.website.co.uk/?filters=type-of-light[550]|colour[569]
www.website.co.uk/?filters=type-of-light[ceiling-lights]|colour[pink]
www.website.co.uk/filters/type-of-light=ceiling-lights&colour=green
How can I still use $_GET to get the value of colour in the url with these links?
There are also these settings in the permalinks tab in wordpress, that I can use to alter the query string;
These are my options in the plugin for the query strings;
Here is the function where I am using $_GET to get the colour value, I use this function to set the images on the products;
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'set_product_image', 10);
function set_product_image() {
global $product;
if( $product->is_type('variable') ){
// color of first variation
$default_image = '';
foreach ( $product->get_visible_children() as $variation_id ){
$variation = wc_get_product( $variation_id );
$product_colour = strtolower( $variation->get_attribute('colour') );
// get first variation
if( $default_image == '' ){
$default_image = $variation->get_image( array(300, 300) );
}
$filter_colour = $_GET['colour'];
if( $product_colour == $filter_colour){
// if filter applied, echo and return
echo $variation->get_image( array(300, 300) );
return;
}
}
// filter not applied, return default image
echo $default_image ;
}
else if( $product->is_type('simple') ){
if ( has_post_thumbnail() ) {
echo $product->get_image( array(300, 300) );
}else{
echo '<img src="https://website.co.uk/wp-content/themes/dist/images/placeholder.png">';
}
}
}




colourpart alone?