PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

WOOF Filter not excluding variations

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [noreply@pluginus.net] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

Hi there,

I have scoured the forum and the internet using the solutions provided but nothing seems to fix the functionality for filtering out products whose variation in question is out of stock. I have the paid version of WOOF, installed the in stock checkbox extension, changed the option to search in variations, and added the following lines of code into functions.php:

PHP
1
2
3
4
5
6
add_filter('woof_get_request_data', 'my_woof_get_request_data');
function my_woof_get_request_data($data){
$data['stock']='instock';
return $data;
}

When I add this block of code in particular it cleans out my shop page completely leaving it blank. This also happens when I check the default WooCommerce hide out of stock products. If I use just the out of stock checkbox extension with the option to search in variations, it still brings up the products that have out of stock variations for the attribute being searched.

IMPORTANT: I am combining this plugin with Variation Swatches for WooCommerce. Just to emphasise that the plugins usually work well together and for example when a person is searching for a particular attribute the Variations for that particular attribute normally are loaded by default on the shop page. The problem is simply excluding the parent product from appearing on the shop page when the variation/attribute in question is out of stock. How can I achieve that with the WOOF filter?

Thanks

From what I can see the problem seems to lie in the"in stock" feature which when activated clears my shop page completely. Really can't trace the root of the issue. Is this a common problem?

Hello

Clarify please: you want let always filtered data shows products which are in stock only, right?

"This also happens when I check the default WooCommerce hide out of stock products." - somewhere can be conflict

Lets do next:

  • if site is alive create site clone on test subdomain by Duplicator https://wordpress.org/plugins/duplicator/
  • disable all plugins exept woocmmerce and WOOF
  • check is the issue still persist
  • if yes - enable default theme, for example twentytwelve or another one, and check
  • if issue still persist, in private area (button on the right) share with us please tmp wp-admin access and tmp ftp access

 

Just an update:

Yes. I realised after posting that the Woocommerce Stock management is better disabled as it causes conflict. However, I discovered that the In Stock feature was solely wiping my shop page clean as everything was considered"out of stock" despite many items definitely being assigned as in stock. I had a little look in the index.php of the by_instock extension and found this piece of code:

public function assemble_query_params(&$meta_query, $wp_query = NULL)
{
global $WOOF;
$request = $WOOF->get_request_data();

if (isset($request['stock']))
{
if ($request['stock'] == 'instock')
{
$meta_query[] = array(
'key' => '_stock_status',
'value' => 'outofstock', //instock,outofstock
'compare' => 'NOT IN'
);
}

if ($request['stock'] == 'outofstock')
{
$meta_query[] = array(
array(
'key' => '_stock_status',
'value' => 'outofstock', //instock,outofstock
'compare' => 'IN'
)
);
}
}

I noticed in both cases of the conditional it assigns the value 'outofstock'. Not sure if this is meant to be the case? Anyway, when I changed the 'instock' result of the query to assign value 'instock' it brings up the the available products according to the first attribute filtered. However, it doesn't pick up any of the second attribute if filtered.

For example, now when I filter by colour, it reads the right products as being in stock and shows them on the shop page. However, throwing in an additional filter by size it will again pick up nothing. Not sure yet if I messed up the logic by making this change but would just like to confirm if this block of code is meant to work like this and assign 'outofstock' in both cases?

Thanks

I got down to the root of the issue. I've been importing the products by CSV and I had failed to notice the parent product was not summing up the total stock of the variations which apparently was the reason for not being counted as"instock". I reverted the change I made as mentioned above as well. I tested it without the Swatches plugin installed and it made no difference so I don't think that plugin has any effect.

A new issue came to my attention though that the filter only picks up on products"in stock" when all the variations of the attribute are in stock! As in:

If I have 3 products with the same colour

  1. T-Shirt Red Small - 3 in stock
  2. T-Shirt Red Medium - 2 in stock
  3. T-Shirt Red Large - 0 in stock

It does not appear on the shop page after filter with"in stock" enabled and filtering by"Red". It only brings the products up if all of the above would be in stock. What can I do to fix this?

 

Thank you

Hello

"in stock" when all the variations of the attribute are in stock! - Yes!  This is the correct filter behavior.

In fact, you have an variant  that matches the search query - 0 in stock  AND  Red  - Therefore the filter excludes the parent product

If  you search  - Red AND  Medium - this product will be displayed

Is there an easy fix to alter that behaviour to filter out individual"out of stock" variants in the search by attribute rather than excluding parent product if a single relevant variant is out of stock?

Hello

Product variants are not displayed in the shop template, and this type of product does not appear in the search query.  For this reason, it cannot be changed.