Plugin Support
John Coy a11n
(@johndcoy)
Automattic Happiness Engineer
Hi @josul
This issue is likely a result of any template overrides applied to the Avada theme. Does this issue still occur when you test another theme?
Thread Starter
josul
(@josul)
Hi, John
yes, as I wrote in my post, I switched from my avada child to another theme but it was the same result (as well as I deactivated the other plugins). I tried to write a price for each variation of one product and it was ok for that product only.
is there any php code (I could put in functions.php in the child theme) to indicate that the stock is always OK ?
Thanks
Plugin Support
John Coy a11n
(@johndcoy)
Automattic Happiness Engineer
Hi @josul
I think the problem here is that something is causing this to break. Rather than applying a temporary fix you may want to try switching back to a default theme, specifically Twenty Seventeen or Storefront. After you have done that, try disabling all plugins except for WooCommerce to see if this resolves the issue. If that helps, then re-enable each one at a time until you find the one that’s causing the conflict.
Let me know what you find.
Thread Starter
josul
(@josul)
Hi, John
I did just as you said : I switched to Twenty Seventeen, then I disabled all the plugins except woocommerce ; this doesn’t resolve the issue. No change at all.
I’m going to write a price for each variation of each product even if it does not satisfy me.
If you have another idea, please, tell me !
Thank you for your help, I appreciate !
Plugin Support
John Coy a11n
(@johndcoy)
Automattic Happiness Engineer
Hi @josul
That’s so odd. Are the prices missing and the products are missing, or are the products just missing?
Thread Starter
josul
(@josul)
hi,
there was no price because of catalog mode
the products are not missing ;
is missing the selector of options which appears because there are variations (of colours)
but actually on the pages I can see the image, the description of the product but I can’t choose the color because the selector of options (choose an option …) is not visible ; it is replaced by the sentence ““this product is currently out of stock and unavailable”
I think the probleme is “out of stock”, probleme resolved if I write a price for each variation ( I tested it for one product ; for another product I wrote the price only for one variation and the sentence disappeared but I saw only one variation, that one ; the variations without prices were not visible)
I hope I managed to explain you clearly.
I marked “no management of stock” but that is not enough ; there are no prices for the variations, so woocommerce thinks there are no products and write the sentence, and doesn’t write the attributes of colours.
(It’s very difficult, it’s not easy to use woocommerce)
thank you
Right, so that is the expected default behavior now. If a variation has not price, it is not selectable so it’s attributes won’t be shown unless another valid variations used them.
Particularly has to do with this change: https://github.com/woocommerce/woocommerce/commit/80c07d530d74f551d6a02a2f4588a91f88428928#diff-9d28960c60468fc038da5e6232cf0d8c
To reverse, you can set the woocommerce_hide_invisible_variations filter to false.
Thread Starter
josul
(@josul)
Hi, Caleb
Thanks for trying to help me !
I thank you for the link with the code.
I copied exactly what I saw :
// Filter ‘woocommerce_hide_invisible_variations’ to optionally hide invisible variations (disabled variations and variations with empty price)
– if ( apply_filters( ‘woocommerce_hide_invisible_variations’, false, $this->get_id(), $variation ) && ! $variation->variation_is_visible() ) {
even if something seemed to me strange, may be wrong : After the { I think something is missing, at least }
So I tried to set the php code in the functions.php file of my children theme but I do not know if I copied what I had to copy – with or without “continue; } after {- because I obtained a completely white page.
Please, excuse my inexperience in php language !
The code that goes into your child theme’s functions.php file will be:
add_filter( 'woocommerce_hide_invisible_variations', '__return_false' );
Thread Starter
josul
(@josul)
Hi, caleb !
Thanks very much to you !!!!
I added the php code and the selector of options is back.
The sentence was still there. So I added css code and it disappeared.
I’m glad.
Only if you have time and if you agree, I would like to ask you some questions (because I like understanding and I would want to progress). Of course, if you agree, answer only the questions you want.
-
This reply was modified 8 years, 3 months ago by
josul.
So the filter comes from here: https://github.com/woocommerce/woocommerce/blob/823332b5dbfdab464ec567c89cf7d0ec341a25e0/includes/class-wc-product-variable.php#L289
When WooCommerce is checking which variations should be shown, it runs through this filter. If it’s set to true (which it is by default), it will skip attributes that have no valid variations. So by setting the filter to false, this remove the “skipping” and they will still show up on the product page.
And then right, the variation is still considered out of stock because there is no price/stock. It’s not purchasable. Your use case seems a bit odd – why have the user make selections for no apparent reason since they can’t add to cart with those selections?
And then lastly, I’m afraid I don’t really know of any good resources for what you are looking for. Here is one that talks about filters/actions though: https://code.tutsplus.com/articles/the-beginners-guide-to-wordpress-actions-and-filters–wp-27373
Thread Starter
josul
(@josul)
Hi, Caleb !
I already said : the website is is catalog mode, for the moment (perhaps it will change later, that is why I chose woocommerce) ; the user makes selections to list the various colors -most of the products have each several colors- and see the corresponding large images, at the same time (that’s not for no apparent reason since they can’t add to cart with those selections).
Thank you very much for these explanations and your help !
Have a good day !
I put your blog in my favorites
(I mark as resolved)