• Hello

    I have create this code

    add_filter( 'woocommerce_states', 'custom_woocommerce_states' );
     
    function custom_woocommerce_states( $states ) {
      $states['CU'] = array(
        'Pinar del Rio' => 'Pinar del Rio',
        'Artemisa' => 'Artemisa',
        'Mayabeque' => 'Mayabeque'
        );
     
      return $states;
    }
    function custom_places_cuba($states) {  
    
      global $states;	
    	
      $places['CU']['Pinar del Rio']['PR1'] = 'Consolacion del Sur';
      $places['CU']['Pinar del Rio']['PR2'] = 'Los Palacios';
      $places['CU']['Pinar del Rio']['PR3'] = 'Guane';
      $places['CU']['Pinar del Rio']['PR4'] = 'San Luis';
      $places['CU']['Pinar del Rio']['PR5'] = 'Vinales';
      $places['CU']['Pinar del Rio']['PR6'] = 'Pinar del Rio';
      $places['CU']['Pinar del Rio']['PR7'] = 'San Juan y Martinez';
      $places['CU']['Pinar del Rio']['PR8'] = 'Sandino';
      $places['CU']['Pinar del Rio']['PR9'] = 'La Palma';
      $places['CU']['Pinar del Rio']['PR10'] = 'Minas de Matahambre';
      $places['CU']['Pinar del Rio']['PR11'] = 'Mantua';
      
      $places['CU']['Artemisa']['VE16'] = 'Alquizar';
      $places['CU']['Artemisa']['VE17'] = 'Artemisa';
      $places['CU']['Artemisa']['VE18'] = 'Bahia Honda';
      $places['CU']['Artemisa']['VE19'] = 'Bauta';
      $places['CU']['Artemisa']['VE20'] = 'Caimito';
      $places['CU']['Artemisa']['VE21'] = 'Candelaria';
      $places['CU']['Artemisa']['VE22'] = 'Guanajay';
      $places['CU']['Artemisa']['VE23'] = 'Guira de Melena';
      $places['CU']['Artemisa']['VE24'] = 'Mariel';
      $places['CU']['Artemisa']['VE25'] = 'San Antonio de los Banos';
      $places['CU']['Artemisa']['VE26'] = 'San Cristobal';	
      
      $places['CU']['Mayabeque']['VE27'] = 'Batabano';
      $places['CU']['Mayabeque']['VE28'] = 'Bejucal';
      $places['CU']['Mayabeque']['VE37'] = 'Guines';
      $places['CU']['Mayabeque']['VE29'] = 'Jaruco';
      $places['CU']['Mayabeque']['VE30'] = 'Madruga';
      $places['CU']['Mayabeque']['VE31'] = 'Melena del Sur';
      $places['CU']['Mayabeque']['VE32'] = 'Nueva Paz';
      $places['CU']['Mayabeque']['VE33'] = 'Quivican';
      $places['CU']['Mayabeque']['VE34'] = 'San Jose de las Lajas';
      $places['CU']['Mayabeque']['VE35'] = 'San Nicolas de Bari';
      $places['CU']['Mayabeque']['VE36'] = 'Santa Cruz del Norte'; 
    
      return $places['CU'];
    }
    
    add_filter('scpwoo_custom_places_cu', 'custom_places_cuba' );

    In the checkout form when I try to access the _shipping_state the woocommerce returns the _billing_state

    add_action(‘woocommerce_review_order_before_submit’, ‘add_my_checkout_tickbox’, 9);

    function add_my_checkout_tickbox() {
    $shipping_state = WC()->customer->get_shipping_state();
    echo $shipping_state;
    }

    woocommerce returns the _billing_state instead of one of the state created

    The shipping contry is cuba, the state dropdown and cities dropdown are show correctly, but I can not get the right value by code.

    Thanks

    The page I need help with: [log in to see the link]

  • The topic ‘problem accessing _shipping_state’ is closed to new replies.