Title: How to insert database value into function
Last modified: August 31, 2016

---

# How to insert database value into function

 *  [1krom](https://wordpress.org/support/users/1krom/)
 * (@1krom)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-insert-database-value-into-function/)
 * Hi,
 * I want to change the function for calculate shipping fee for woocommerce. Now
   the function calculate shipping from server location, But I want to change the
   function so it can calculate from seller location in database, not server location.
   
   This is the function
 *     ```
       public function init_form_fields() {
       		global $woocommerce;
       		global $myongkir;
   
       		global $wpdb;
   
       		$mylink = $wpdb->get_row( "SELECT * FROM wp_usermeta WHERE user_id='1' AND meta_key= 'billing_city'", ARRAY_A );
   
       		if ( $this->isset_rajaongkir_api() ) {
       		    $this->form_fields = array(
       		    	'enabled' => array(
       				    'title'   => 'Enable/Disable',
       				    'type'    => 'checkbox',
       				    'default' => 'no',
       				    'label'   => 'Enable this shipping method',
       					),
       				'base_city' => array(
       			        'title'       => __( 'Your Base City', 'woocommerce' ),
       			        'type'        => 'select',
       			        'id'          => 'woocommerce_myongkir_base_city',
       			        'class'       => 'chosen_select',
       			        'description' => __( 'This is your store location, used for origin package. Require api key is setted, before showing available city.', 'woocommerce' ),
       			        'options'     => $myongkir->get_cities($mylink->meta_value)
       			    	),
       				'courier' => array(
       				    'title'       => __( 'Your couriers', 'woocommerce' ),
       				    'type'        => 'select',
       				    'id'          => 'woocommerce_myongkir_couriers',
       				    'class'       => 'chosen_select',
       				    'description' => __('This is the avaibility of yours couriers', 'woocommerce' ),
       				    'options' => array(
       				    	'all' => 'All',
       				    	'aaa' => 'aaa',
       				    	'bbb' => 'bbb',
       				    	'ccc'=> 'ccc',
       				    ),
       				),
       		    );
       		}
       	}
       ```
   
 * I’ve found seller location in wp_usermeta table, but when I change the function
   base_city value to database value, the function didn’t work correctly. Do you
   know how I can change base_city value to database value ?
 * Thank you

The topic ‘How to insert database value into function’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [1krom](https://wordpress.org/support/users/1krom/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/how-to-insert-database-value-into-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
