In WooCommerce, do you know of a way to add a class to a <a> html element (product link) if the product is out of stock?
Basically, I have product links on a page, and each link goes to a particular product. I am trying to add an "oos" class to the product's link, if that product is out of stock. Then I can style those links differently.
More info: https://jsfiddle.net/Garconis/qtvkxkga/
I am creating an SVG map. Each piece/path will link to a particular product. If the product that it's linked to is out of stock, it should then add the "oos" class (so that the piece is no longer visible).
I'm not opposed to using some sort of shortcode, if that will help things. But the shortcode would need to be able to wrap each of the unique SVG paths.
In stock:
<svg>
<a href="https://example.com/?p=332">
<path></path>
</a>
</svg>
Out of stock:
<svg>
<a href="https://example.com/?p=332" class="oos">
<path></path>
</a>
</svg>
Note, in the URL, I can also use the product's ID if that helps PHP find the corresponding item (as opposed to using the usual slug URL).