add_action('save_post_product', 'force_save_product_price_if_missing', 15, 1);
function force_save_product_price_if_missing($post_id) {
// Abort if this is an autosave or wrong context
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if (!current_user_can('edit_post', $post_id)) return;
// Ensure this is a valid product
$product = wc_get_product($post_id);
if (!$product) return;
// Check if form submitted a price
if (isset($_POST['regular_price'])) {
$price = wc_clean($_POST['regular_price']);
// Forcefully save both Woo price metas
update_post_meta($post_id, '_regular_price', $price);
update_post_meta($post_id, '_price', $price); // Important: Woo reads this one
}
}
Cart - Maker-Mall