edd_ajax_get_states_field

Retrieve a states drop down.

Description

edd_ajax_get_states_field(); 

Usage

  1. if ( !function_exists( 'edd_ajax_get_states_field' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'easy-digital-downloads/includes/ajax-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = edd_ajax_get_states_field(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/ajax-functions.php  
  1. function edd_ajax_get_states_field() { 
  2. if( empty( $_POST['country'] ) ) { 
  3. $_POST['country'] = edd_get_shop_country(); 
  4. $states = edd_get_shop_states( $_POST['country'] ); 
  5.  
  6. if( ! empty( $states ) ) { 
  7.  
  8. $args = array( 
  9. 'name' => $_POST['field_name'],  
  10. 'id' => $_POST['field_name'],  
  11. 'class' => $_POST['field_name'] . ' edd-select',  
  12. 'options' => $states,  
  13. 'show_option_all' => false,  
  14. 'show_option_none' => false 
  15. ); 
  16.  
  17. $response = EDD()->html->select( $args ); 
  18.  
  19. } else { 
  20.  
  21. $response = 'nostates'; 
  22.  
  23. echo $response; 
  24.  
  25. edd_die();