Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
279 views
in Technique[技术] by (71.8m points)

php - Can I hide the WooCommerce product variations menu when the product is sold out?

My site sells paintings, with the option of being framed or unframed. The obvious way to do that seemed to be as product variations. But it's an unusual case, because of course the painting is unique and when either variation is sold the product should be out of stock.

I have the basics of that working now; the product will become unavailable once either variation is sold. But unfortunately the option dropdown still displays, only showing "Out of Stock" after the visitor selects one or other variation. Which seems likely to annoy them.

So what I'm trying to do is hide this options menu and replace it with the standard "Out of Stock" message when the product [or either of its two variations] has been sold. But to my surprise I can't find anyone else who has had this problem, and writing such a function is beyond my own knowledge of PHP and WordPress.

question from:https://stackoverflow.com/questions/65853343/can-i-hide-the-woocommerce-product-variations-menu-when-the-product-is-sold-out

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Similar question was asked here: Add a custom class to variation options displaying "Out Of Stock" in Woocommerce

You can use the answer from that thread to add a css class or append extra text to out of stock variations.
By using the added class you can also hide the items using css.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...