• Sven de Bie

    (@debiesven)


    I currently have the following code:

    add_action('update_post_meta','dbp_wc_price_update_meta',10,4);
    function dbp_wc_price_update_meta($meta_id, $post_id, $meta_key, $meta_value){
    	if( in_array($meta_key,array('_price','_price_var') ) ){
    		$meta_value	= str_replace(',','.',$meta_value);
    	}
    return $meta_value;
    }

    I want to make sure that there are no commas in the meta_value before it is saved. But with the hook and function above it is just saved as it is.

    When I save 5,95 it still is saved as 5,95, but I want it to be saved as 5.95.

Viewing 1 replies (of 1 total)
  • Could it be your if statement is evaluating false, so the function just returns the same $meta_value passed to it, unchanged.

Viewing 1 replies (of 1 total)
  • The topic ‘Overrule update_post_meta’ is closed to new replies.