WC_Gateway_Paypal_Request::get_phone_number_args() protected WC 1.0
Get phone number args for paypal request.
{} Это метод класса: WC_Gateway_Paypal_Request{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_phone_number_args( $order );
- $order(WC_Order) (обязательный)
- Order object.
Код WC_Gateway_Paypal_Request::get_phone_number_args() WC Gateway Paypal Request::get phone number args WC 5.0.0
protected function get_phone_number_args( $order ) {
$phone_number = wc_sanitize_phone_number( $order->get_billing_phone() );
if ( in_array( $order->get_billing_country(), array( 'US', 'CA' ), true ) ) {
$phone_number = ltrim( $phone_number, '+1' );
$phone_args = array(
'night_phone_a' => substr( $phone_number, 0, 3 ),
'night_phone_b' => substr( $phone_number, 3, 3 ),
'night_phone_c' => substr( $phone_number, 6, 4 ),
);
} else {
$calling_code = WC()->countries->get_country_calling_code( $order->get_billing_country() );
$calling_code = is_array( $calling_code ) ? $calling_code[0] : $calling_code;
if ( $calling_code ) {
$phone_number = str_replace( $calling_code, '', preg_replace( '/^0/', '', $order->get_billing_phone() ) );
}
$phone_args = array(
'night_phone_a' => $calling_code,
'night_phone_b' => $phone_number,
);
}
return $phone_args;
}