Hammers which all looks the same

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.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

You have to agree to the comment policy.