8manos / wc-city-select

City Select for WooCommerce. Show a dropdown select as the cities input.
https://wordpress.org/plugins/wc-city-select/
33 stars 41 forks source link

how to allowable/adding id (as integer) in array data #10

Closed harry-maulana closed 7 years ago

harry-maulana commented 7 years ago

hi Mantis..

how to allowing id adding id in our array, then we just store the id of value to database (billing_city).. not text value.

like here: var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];

from here:

$cities['XX'] = array( 'YYY' => array( 'City ', 'Another City' ), 'ZZZ' => array( 'City 3', 'City 4' ) );

thanks, best regard

Mantish commented 7 years ago

hi, I don't really understand what you're saying Can you explain what's the problem you're trying to solve?

harry-maulana commented 7 years ago

my case, i want to save the id of value to billing_city, not name of city.. but id of city.. please help me sir

so, not string "City" or "Another City" or "City 3" or "City 4" which we save to database, but id of them.

i has try like this: $cities['XX'] = array( 'YYY' => array( '1' =>'City ', '2' => 'Another City' ), 'ZZZ' => array( '1' => 'City 3', '2' => 'City 4' ) );

or like this:

$cities['XX'] = array( 'YYY' => array( array('id' => '1', 'name' => 'City '), array('id' => '2', 'name' => 'Another City '), ), 'ZZZ' => array( array ('id' => '1', 'name' => 'City 3'), array('id' => '2', 'name' => 'City 4 '), ) );

but not work

harry-maulana commented 7 years ago

i'm sorry for my english..

harry-maulana commented 7 years ago

i fixed this.. thanks Mantis