Or expands the search. It should not deselect others.
Thread Starter
JayFry
(@jayfry)
I thought so too! But in my demo here also with “OR” it deselects!
Why these behaviors do not coincide?
Thread Starter
JayFry
(@jayfry)
No, I have already excepted this option.
Are both sites running 2.6.1/2? The behaviour to expand the search as I said is correct. Maybe another plugin is changing how it works.
Thread Starter
JayFry
(@jayfry)
I`ve just translated all attribute names to latin characters and It have worked as you said it should! So the problem was definitely UTF8 chars.
But is there a trick to make this widget work with “OR” attribute as I described above? Maybe edit some lines in widget code? (Not to add attribute to previous ones, but deselect first and select second. I don`t want to use “AND” cause if you select one it only shows selected and not others available).
Only with a custom widget. You cannot change this logic externally.
Or use a dropdown menu. Those can only have 1 option.
Thread Starter
JayFry
(@jayfry)
I`ve found solution to my problem. To achieve single select you should edit code line 414 in the file class-wc-widget-layered-nav.php (located in woocommerce folder)
change
if ( ! in_array( $term->slug, $current_filter ) ) {
$current_filter[] = $term->slug;
}
to
if ( ! in_array( $term->slug, $current_filter ) ) {
$current_filter[0] = $term->slug;
}
Or just create your own custom widget on the base of existing woocommerce widget.
Your best bet is creating your own widget and using the above code if you wish to, as it will be overwritten on the next update.
Also, if it is in a loop, only the last item in the loop will wind up in the list, as the key for the array is specified, so the value will be overwritten with each loop.
It happens whit non-latin attributes. Is anybody find the solution to work with utf8 characters?