This should be possible with the built-in features of WordPress. In your WooCommerce Settings, in the Inventory tab, enable Stock Management. Then, when you create or edit a product, select the Inventory tab in the Product Data section and enable stock management for that product. You will then be able to set a stock quantity of 1 (and make sure that backorders aren’t allowed).
Once that 1 item has been sold, WooCommerce will automatically change the status to say ‘Out of stock’ and will not allow that product to be sold again.
For a situation like this, you may also want to customise the messages displayed to the user to something other than the default ‘Out of stock”https://wordpress.stackexchange.com/”1 in stock’. To change it to show Sold/Available instead, you can use the woocommerce_stock_html
filter. Just add code like the following to your theme’s functions.php file:
add_filter('woocommerce_stock_html', 'change_stock_message', 10, 2);
function change_stock_message($message, $stock_status) {
if ($stock_status == "Out of stock") {
$message="<p class="stock out-of-stock">Sold</p>";
} else {
$message="<p class="stock in-stock">Available</p>";
}
return $message;
}