Saving Custom Field Data in WooCommerce — a practical guide to save WooCommerce custom fields with clear examples you can reuse in real projects.
WooCommerce Plugin Development Series (21/101). Prefer one article? Read the complete WooCommerce plugin development tutorial.
Short description
Save product fields on `woocommerce_process_product_meta`, checkout fields on order create hooks, and registration fields on customer create.
Save product meta
add_action('woocommerce_process_product_meta', function ($post_id) {
$subtitle = isset($_POST['_acme_subtitle'])
? sanitize_text_field(wp_unslash($_POST['_acme_subtitle']))
: '';
update_post_meta($post_id, '_acme_subtitle', $subtitle);
});