mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-05-04 12:22:24 +08:00
https://github.com/strangerstudios/pmpro-snippets-library/blob/dev/checkout/autofill-billing-fields-from-woocommerce.php
30 lines
1.3 KiB
Text
30 lines
1.3 KiB
Text
function mypmpro_autofill_pmpro_fields() {
|
|
|
|
global $current_user, $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone;
|
|
|
|
// Personal details from billing details WooCommerce.
|
|
$company = get_user_meta( $current_user->ID, 'billing_company', true );
|
|
$fname = get_user_meta( $current_user->ID, 'billing_first_name', true );
|
|
$lname = get_user_meta( $current_user->ID, 'billing_last_name', true );
|
|
$phone = get_user_meta( $current_user->ID, 'billing_phone', true );
|
|
|
|
// Address details from billing details WooCommerce.
|
|
$address_1 = get_user_meta( $current_user->ID, 'billing_address_1', true );
|
|
$address_2 = get_user_meta( $current_user->ID, 'billing_address_2', true );
|
|
$city = get_user_meta( $current_user->ID, 'billing_city', true );
|
|
$state = get_user_meta( $current_user->ID, 'billing_state', true );
|
|
$postcode = get_user_meta( $current_user->ID, 'billing_postcode', true );
|
|
$country = get_user_meta( $current_user->ID, 'billing_country', true );
|
|
|
|
$bfirstname = $fname;
|
|
$blastname = $lname;
|
|
$baddress1 = $address_1;
|
|
$baddress2 = $address_2;
|
|
$bcity = $city;
|
|
$bstate = $state;
|
|
$bzipcode = $postcode;
|
|
$bcountry = $country;
|
|
$bphone = $phone;
|
|
|
|
}
|
|
add_action( 'wp', 'mypmpro_autofill_pmpro_fields' );
|