Advertisement
mbcreation

Google Address: Fill a specific field for the house number

Jul 2nd, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.00 KB | None | 0 0
  1. /* Works with WooCommerce Google Autocomplete since version 1.12 */
  2. /* It assumes that your theme (or a plugin) is adding specific fields for the netherlands/brazilian addresses ; at least one for the street name and one for the house number */
  3.  
  4. /* You just have to paste this code to your functions.php theme file.
  5. You have to change, if different, the names of the fields:
  6. - billing_street_name
  7. - billing_house_number
  8. - billing_house_number_suffix (not mandatory, just to group it with the other fields if you have this field, used for NL addresses)
  9. – billing_bairro (not mandatory, can be used for brazilian addresses)
  10. - shipping_street_name
  11. - shipping_house_number
  12. - shipping_house_number_suffix (not mandatory)
  13. – shipping_bairro (not mandatory)
  14. */
  15.  
  16. add_filter('woogoogad_countries_with_additional_fields', 'my_countries_with_specific_street_number_handeling');
  17.  
  18. function my_countries_with_specific_street_number_handeling()
  19. {
  20.     //country codes for the countries where you want to separate the house number from the route name.
  21.     return array('NL', 'BR');
  22. }
  23.  
  24. add_filter('woogoogad_additional_fields', 'my_additional_fields_with_street_number');
  25. function my_additional_fields_with_street_number()
  26. {
  27.     return array('billing' => array(
  28.             'street_name' => 'billing_street_name', //edit the name or billing_address_1 to use the native field
  29.             'house_number' => 'billing_house_number', //edit the name
  30.             'house_number_suffix' => 'billing_house_number_suffix', //optional, for NL addresses. Edit the name if needed
  31.             'bairro' => 'billing_bairro' //optional, the neighborhood field for BR addresses
  32.         ),
  33.         'shipping' => array(
  34.             'street_name' => 'shipping_street_name', //edit the name or shipping_address_1 to use the native field
  35.             'house_number' => 'shipping_house_number', //edit the name
  36.             'house_number_suffix' => 'shipping_house_number_suffix', //optional, for NL addresses. Edit the name if needed
  37.             'bairro' => 'shipping_bairro' //optional, the neighborhood field for BR addresses
  38.         )
  39.     );
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement