woocommerce getting session variable value direct in billing address 5bphp session 5d

Solutions on MaxInterview for woocommerce getting session variable value direct in billing address 5bphp session 5d by the best coders in the world

showing results for - "woocommerce getting session variable value direct in billing address 5bphp session 5d"
Remco
06 Jul 2017
1/**
2 * Getting Session Variable Value direct in Billing Address..
3 *
4 * PHP SESSION  VARIABLE
5 * 
6 * 
7 */
8
9add_filter( 'woocommerce_checkout_fields' , 'ahmadyani_checkout_field_defaults', 20 );
10function ahmadyani_checkout_field_defaults( $fields ) {
11    // $user = get_user_meta(get_current_user_id());
12    // $first_name = $user ? $user['shipping_first_name'][0] : '';
13    // $last_name = $user ? $user['shipping_last_name'][0] : '';
14    // $company = $user ? $user['shipping_company'][0] : '';
15    // $shipping_address_1 = $user ? $user['shipping_address_1'][0] : '';
16    // $shipping_address_2 = $user ? $user['shipping_address_2'][0] : '';
17    // $shipping_city = $user ? $user['shipping_city'][0] : '';
18    // $shipping_state = $user ? $user['shipping_state'][0] : '';
19    // $shipping_postcode = $user ? $user['shipping_postcode'][0] : '';
20    if($_SESSION['number'] !== 0){
21
22    $fields['billing']['store_location']['default'] = $_SESSION['number'];
23      
24    }
25    // else if($_SESSION['loc2'] !== 0){
26
27    // $fields['billing']['billing_address_2']['default'] = $_SESSION['loc2'];
28     
29    // }
30    return $fields;
31}
32