Comments 1thomas started the conversationMarch 15, 2022 at 1:39pmhi there,could you provide me with a functions.php snippet that sets up the price to 0 whenever i add a new product. that would be very convenient, thanks!thomas 1thomas repliedMarch 18, 2022 at 8:14pmok i go this one, here is the functions.php code for anyone interested: /** * Sets the product default price 0. Only works once, if the price is not specified. */function set_product_default_price( $post_id, $post ) { $product = wc_get_product( $post_id ); $already_set = get_post_meta( $post_id, '_set_default_price', true ); $price = $product->get_price(); if ( 'yes' !== $already_set && empty( $price ) ) { $product->set_regular_price( '0' ); $product->save(); update_post_meta( $post_id, '_set_default_price', 'yes' ); }}add_action( 'woocommerce_process_product_meta', 'set_product_default_price', 999, 2 ); please close this ticketthanks 228Milingona repliedMarch 20, 2022 at 7:07pmThanks for the feedback. Very glad you managed to solve the issue. Milingona Support Follow on Envato Facebook Twitter Sign in to reply ...
hi there,
could you provide me with a functions.php snippet that sets up the price to 0 whenever i add a new product. that would be very convenient, thanks!
thomas
ok i go this one, here is the functions.php code for anyone interested:
please close this ticket
thanks
Thanks for the feedback. Very glad you managed to solve the issue.
Milingona Support
Follow on Envato Facebook Twitter