I added custom fields to WooCommerce category edit form using add_action('product_cat_edit_form_fields') and on update action add_action('edited_product_cat') The fields display correctly.

On update action, the JSON request data shows correctly in the browser's console but not being saved to the database table _options as set to do and appears that the array key is just not existing in the php $_POST array, as if page edit-tags.php is not being loaded.

NOTE The process works fine when taxonomy is category

the code on update run time

global $pagenow;
if( 'edit-tags.php' === $pagenow || 'admin-ajax.php' === $pagenow ) {

add_action('edited_product_cat', function($term_id) {
  if( array_key_exists('cmse_options',$_POST) ) {
    $field_key = $_POST['cmse_options'];
    $keys = array_keys($field_key);
    foreach($keys as $field_name) {
        if( isset($field_key[$field_name]) ) 
            $keys[$field_name] = $field_key[$field_name];
    // serialize update options
    update_option('woo_cat_config_'.$term_id, $keys);


screen shot of console screenshot console

  • Could you share with us the ajax function that you have implemented? And what about the responses?
    – Baljka Gan
    Oct 23 at 4:11
  • @BaljkaGan There's no additional AJAX process. The screenshot is just to show that the data request is sent on form update action via the core wp_ajax and the process via edit-tags.php runs. There just is no $_POST values being passed to the database.
    – Nadal
    Oct 23 at 8:12


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.