When you create a new product, by default WooCommerce leaves the price empty, and if you don't set one, the product will be considered free.
There might be cases where you do not want to manually set a price, but still do not leave it empty. Setting a default value would be the solution.
How can you do it with WooCommerce?
With custom code, of course!
Open your favourite code editor and edit the file functions.php in wp-content/themes/your-child-theme-name/ adding this code at the end:
This script will set the product price to 10. It only runs once, if the product does not have the meta
_set_default_price set to
yes, and if a product price has not been specified already.
Be careful with products created before this snippet has been added to your site. If they don't have a price set the default price will be applied.
Leave a Reply