$counties_array, 'rate' => $rate, 'shipping' => $shipping, 'compound' => $compound, 'class' => $class, 'label' => woocommerce_clean( $tax_label[ $i ] ) ); } } $update_options[ 'woocommerce_tax_rates' ] = $tax_rates; // Local tax rates saving $local_tax_rates = array(); $tax_classes = isset( $_POST['local_tax_class'] ) ? $_POST['local_tax_class'] : array(); $tax_countries = isset( $_POST['local_tax_country'] ) ? $_POST['local_tax_country'] : array(); $tax_location_type = isset( $_POST['local_tax_location_type'] ) ? $_POST['local_tax_location_type'] : 'postcode'; $tax_location = isset( $_POST['local_tax_location'] ) ? $_POST['local_tax_location'] : array(); $tax_rate = isset( $_POST['local_tax_rate'] ) ? $_POST['local_tax_rate'] : array(); $tax_shipping = isset( $_POST['local_tax_shipping'] ) ? $_POST['local_tax_shipping'] : array(); $tax_postcode = isset( $_POST['local_tax_postcode'] ) ? $_POST['local_tax_postcode'] : array(); $tax_compound = isset( $_POST['local_tax_compound'] ) ? $_POST['local_tax_compound'] : array(); $tax_label = isset( $_POST['local_tax_label'] ) ? $_POST['local_tax_label'] : array(); $tax_classes_count = sizeof( $tax_classes ); for ( $i = 0; $i < $tax_classes_count; $i ++ ) { if ( isset( $tax_classes[ $i ] ) && isset( $tax_countries[ $i ] ) && isset( $tax_rate[ $i ] ) && is_numeric( $tax_rate[ $i ] ) ) { $rate = woocommerce_clean( $tax_rate[ $i ] ); $rate = number_format( $rate, 4, '.', '' ); $class = woocommerce_clean( $tax_classes[ $i ] ); if ( ! empty( $tax_shipping[ $i ] ) ) $shipping = 'yes'; else $shipping = 'no'; if ( ! empty( $tax_compound[ $i ] ) ) $compound = 'yes'; else $compound = 'no'; // Handle country $country = woocommerce_clean( $tax_countries[ $i ] ); $state = '*'; if ( strstr( $country, ':' ) ) { $cr = explode( ':', $country ); $country = current( $cr ); $state = end( $cr ); } // Handle postcodes/cities $location_type = $tax_location_type[ $i ] == 'city' ? 'city' : 'postcode'; $locations = explode( "\n", $tax_location[ $i ] ); $locations = array_filter( array_map( 'woocommerce_clean', $locations ) ); if ( $location_type == 'city' ) { $locations = array_map( 'sanitize_title', $locations ); } $local_tax_rates[] = array( 'country' => $country, 'state' => $state, 'location_type' => $location_type, 'locations' => $locations, 'rate' => $rate, 'shipping' => $shipping, 'compound' => $compound, 'class' => $class, 'label' => woocommerce_clean( $tax_label[ $i ] ) ); } } $update_options[ 'woocommerce_local_tax_rates' ] = $local_tax_rates; break; case "multi_select_countries" : // Get countries array if ( isset( $_POST[ $value['id'] ] ) ) $selected_countries = array_map( 'woocommerce_clean', (array) $_POST[ $value['id'] ] ); else $selected_countries = array(); $option_value = $selected_countries; break; case "image_width" : if ( isset( $_POST[$value['id'] ]['width'] ) ) { $update_options[ $value['id'] ]['width'] = woocommerce_clean( $_POST[$value['id'] ]['width'] ); $update_options[ $value['id'] ]['height'] = woocommerce_clean( $_POST[$value['id'] ]['height'] ); if ( isset( $_POST[ $value['id'] ]['crop'] ) ) $update_options[ $value['id'] ]['crop'] = 1; else $update_options[ $value['id'] ]['crop'] = 0; } else { $update_options[ $value['id'] ]['width'] = $value['default']['width']; $update_options[ $value['id'] ]['height'] = $value['default']['height']; $update_options[ $value['id'] ]['crop'] = $value['default']['crop']; } break; // Custom handling default : do_action( 'woocommerce_update_option_' . $type, $value ); break; } if ( ! is_null( $option_value ) ) { // Check if option is an array if ( strstr( $value['id'], '[' ) ) { parse_str( $value['id'], $option_array ); // Option name is first key $option_name = current( array_keys( $option_array ) ); // Get old option value if ( ! isset( $update_options[ $option_name ] ) ) $update_options[ $option_name ] = get_option( $option_name, array() ); if ( ! is_array( $update_options[ $option_name ] ) ) $update_options[ $option_name ] = array(); // Set keys and value $key = key( $option_array[ $option_name ] ); $update_options[ $option_name ][ $key ] = $option_value; // Single value } else { $update_options[ $value['id'] ] = $option_value; } } // Custom handling do_action( 'woocommerce_update_option', $value ); } // Now save the options foreach( $update_options as $name => $value ) update_option( $name, $value, true ); return true; }