/**
  * Loads Cart User Billing Details Template
  * 
  * Handles to load user billing details
  * template
  * 
  * @package Social Deals Engine
  * @since 1.0.0
  */
 function wps_deals_cart_user_billing_details()
 {
     global $current_user, $wps_deals_options;
     //check billing is enable from settings page
     if (isset($wps_deals_options['enable_billing']) && !empty($wps_deals_options['enable_billing'])) {
         $prefix = WPS_DEALS_META_PREFIX;
         //get user billing data saved
         $userbillingdata = get_user_meta($current_user->ID, $prefix . 'billing_details', true);
         //get user country from saved
         $usercountry = isset($userbillingdata['country']) ? $userbillingdata['country'] : '';
         //get user company name
         $usercompany = isset($userbillingdata['company']) ? $userbillingdata['company'] : '';
         //get user address1
         $useraddress1 = isset($userbillingdata['address1']) ? $userbillingdata['address1'] : '';
         //get user address2
         $useraddress2 = isset($userbillingdata['address2']) ? $userbillingdata['address2'] : '';
         //get user city or town
         $usercity = isset($userbillingdata['city']) ? $userbillingdata['city'] : '';
         //get user state or county
         $userstate = isset($userbillingdata['state']) ? $userbillingdata['state'] : '';
         //get user post code
         $userpostcode = isset($userbillingdata['postcode']) ? $userbillingdata['postcode'] : '';
         //get user phone
         $userphone = isset($userbillingdata['phone']) ? $userbillingdata['phone'] : '';
         //get statelist from country
         $statesfrom = wps_deals_get_states_from_country($usercountry);
         $states = !empty($statesfrom) ? $statesfrom : '';
         //data pased to template
         $billingargs = array('countries' => wps_deals_get_country_list(), 'usercountry' => $usercountry, 'usercompany' => $usercompany, 'useraddress1' => $useraddress1, 'useraddress2' => $useraddress2, 'usercity' => $usercity, 'userstate' => $userstate, 'userpostcode' => $userpostcode, 'userphone' => $userphone, 'statelist' => $states);
         //billing details template
         wps_deals_get_template('checkout/footer/billing-details.php', $billingargs);
     }
     //end if to check enable billing or not
 }
/**
 * Get State From State Key 
 * 
 * Handles to return state value from state key
 * 
 * @package Social Deals Engine
 * @since 1.0.0
 **/
function wps_deals_get_country_name($country)
{
    $countries = wps_deals_get_country_list();
    $resultcountry = '';
    if (!empty($countries)) {
        foreach ($countries as $key => $rescountry) {
            if ($rescountry['country_code'] == $country) {
                $resultcountry = $rescountry['country_name'];
                break;
            }
            //end if
        }
        //end forloop
    }
    $resultcountry = !empty($resultcountry) ? $resultcountry : $country;
    return $resultcountry;
}