Получение биллинга и детали доставки:
Вы можете получить платежную информацию и информацию о доставке, как указано ниже.
//whole customer details
print_r(WC()->customer);
//billing details
$billing = WC()->customer->get_billing();
$billing_first_name = WC()->customer->get_billing_first_name();
$billing_last_name = WC()->customer->get_billing_last_name();
$billing_company = WC()->customer->get_billing_company();
$billing_address = WC()->customer->get_billing_address();
$billing_address_1 = WC()->customer->get_billing_address_1();
$billing_address_2 = WC()->customer->get_billing_address_2();
$billing_city = WC()->customer->get_billing_city();
$billing_state = WC()->customer->get_billing_state();
$billing_postcode = WC()->customer->get_billing_postcode();
$billing_country = WC()->customer->get_billing_country();
//shipping details
$shipping = WC()->customer->get_shipping();
$shipping_first_name = WC()->customer->get_shipping_first_name();
$shipping_last_name = WC()->customer->get_shipping_last_name();
$shipping_company = WC()->customer->get_shipping_company();
$shipping_address = WC()->customer->get_shipping_address();
$shipping_address_1 = WC()->customer->get_shipping_address_1();
$shipping_address_2 = WC()->customer->get_shipping_address_2();
$shipping_city = WC()->customer->get_shipping_city();
$shipping_state = WC()->customer->get_shipping_state();
$shipping_postcode = WC()->customer->get_shipping_postcode();
$shipping_country = WC()->customer->get_shipping_country();
Настройка параметров оплаты и доставки:
Вы можете установить параметры оплаты и доставки, как указано ниже.
//billing details
$billing_first_name = $_POST['billing_first_name'];
$billing_last_name = $_POST['billing_last_name'];
$billing_company = $_POST['billing_company'];
$billing_address_1 = $_POST['billing_address_1'];
$billing_address_2 = $_POST['billing_address_2'];
$billing_city = $_POST['billing_city'];
$billing_state = $_POST['billing_state'];
$billing_postcode = $_POST['billing_postcode'];
$billing_country = $_POST['billing_country'];
WC()->customer->set_billing_first_name(wc_clean( $billing_first_name ));
WC()->customer->set_billing_last_name(wc_clean( $billing_last_name ));
WC()->customer->set_billing_company(wc_clean( $billing_company ));
WC()->customer->set_billing_address_1(wc_clean( $billing_address_1 ));
WC()->customer->set_billing_address_2(wc_clean( $billing_address_2 ));
WC()->customer->set_billing_city(wc_clean( $billing_city ));
WC()->customer->set_billing_state(wc_clean( $billing_state ));
WC()->customer->set_billing_postcode(wc_clean( $billing_postcode ));
WC()->customer->set_billing_country(wc_clean( $billing_country ));
//shipping details
$shipping_first_name = $_POST['shipping_first_name'];
$shipping_last_name = $_POST['shipping_last_name'];
$shipping_company = $_POST['shipping_company'];
$shipping_address_1 = $_POST['shipping_address_1'];
$shipping_address_2 = $_POST['shipping_address_2'];
$shipping_city = $_POST['shipping_city'];
$shipping_state = $_POST['shipping_state'];
$shipping_postcode = $_POST['shipping_postcode'];
$shipping_country = $_POST['shipping_country'];
WC()->customer->set_shipping_first_name(wc_clean( $shipping_first_name ));
WC()->customer->set_shipping_last_name(wc_clean( $shipping_last_name ));
WC()->customer->set_shipping_company(wc_clean( $shipping_company ));
WC()->customer->set_shipping_address_1(wc_clean( $shipping_address_1 ));
WC()->customer->set_shipping_address_2(wc_clean( $shipping_address_2 ));
WC()->customer->set_shipping_city(wc_clean( $shipping_city ));
WC()->customer->set_shipping_state(wc_clean( $shipping_state ));
WC()->customer->set_shipping_postcode(wc_clean( $shipping_postcode ));
WC()->customer->set_shipping_country(wc_clean( $shipping_country ));
Создание нового клиента и установка реквизитов для выставления счета и доставки:
Вы можете создать нового клиента, установить параметры оплаты и доставки, как указано ниже.
//create new customer
$email = $_POST['email'];
$username = $_POST['username'];
$password = $_POST['password'];
$user_id = wc_create_new_customer( $email, $username, $password );
//billing details
$billing_first_name = $_POST['billing_first_name'];
$billing_last_name = $_POST['billing_last_name'];
$billing_company = $_POST['billing_company'];
$billing_address_1 = $_POST['billing_address_1'];
$billing_address_2 = $_POST['billing_address_2'];
$billing_city = $_POST['billing_city'];
$billing_state = $_POST['billing_state'];
$billing_postcode = $_POST['billing_postcode'];
$billing_country = $_POST['billing_country'];
update_user_meta( $user_id, "billing_first_name", $billing_first_name );
update_user_meta( $user_id, "billing_last_name", $billing_last_name );
update_user_meta( $user_id, "billing_company", $billing_company );
update_user_meta( $user_id, "billing_address_1", $billing_address_1 );
update_user_meta( $user_id, "billing_address_2", $billing_address_2 );
update_user_meta( $user_id, "billing_city", $billing_city );
update_user_meta( $user_id, "billing_state", $billing_state );
update_user_meta( $user_id, "billing_postcode", $billing_postcode );
update_user_meta( $user_id, "billing_country", $billing_country );
//shipping details
$shipping_first_name = $_POST['shipping_first_name'];
$shipping_last_name = $_POST['shipping_last_name'];
$shipping_company = $_POST['shipping_company'];
$shipping_address_1 = $_POST['shipping_address_1'];
$shipping_address_2 = $_POST['shipping_address_2'];
$shipping_city = $_POST['shipping_city'];
$shipping_state = $_POST['shipping_state'];
$shipping_postcode = $_POST['shipping_postcode'];
$shipping_country = $_POST['shipping_country'];
update_user_meta( $user_id, "shipping_first_name", $shipping_first_name );
update_user_meta( $user_id, "shipping_last_name", $shipping_last_name );
update_user_meta( $user_id, "shipping_company", $shipping_company );
update_user_meta( $user_id, "shipping_address_1", $shipping_address_1 );
update_user_meta( $user_id, "shipping_address_2", $shipping_address_2 );
update_user_meta( $user_id, "shipping_city", $shipping_city );
update_user_meta( $user_id, "shipping_state", $shipping_state );
update_user_meta( $user_id, "shipping_postcode", $shipping_postcode );
update_user_meta( $user_id, "shipping_country", $shipping_country );
Надеюсь, это поможет.