1. Home
  2. Knowledge Base
  3. WooCommerce Product Add Ons Ultimate
  4. Filter field parameters before saving
  1. Home
  2. Knowledge Base
  3. Advanced
  4. Filter field parameters before saving

Filter field parameters before saving

You can filter your field parameters before they’re saved if you wish. In the example below, we’re setting a calculation field to be flat rate:

<?php
/**
* Filter our field params before they're saved
* In this case, set a calculation field with the ID 4991 to be flat rate
* @requires 3.4.3 and greater
*/
function prefix_before_update_field_all_params( $all_params, $field_id ) {
if( $field_id == 4991 ) {
$all_params['field_flatrate'] = 1;
}
return $all_params;
}
add_filter( 'pewc_before_update_field_all_params', 'prefix_before_update_field_all_params', 10, 2 );

Was this article helpful?

Related Articles