WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WC_Checkout::get_posted_data() public WC 3.1.0

Get posted data from the checkout form.

Ищем WP-разработчика! Фулл-тайм, удаленка, хорошая зарплата, соц. пакет. Подробности.
Компания Boosta.

{} Это метод класса: WC_Checkout{}

Возвращает

Массив. of data.

Использование

$WC_Checkout = new WC_Checkout();
$WC_Checkout->get_posted_data();

Список изменений

С версии 3.1.0 Введена.

Код WC_Checkout::get_posted_data() WC 5.9.0

public function get_posted_data() {
	// phpcs:disable WordPress.Security.NonceVerification.Missing
	$data = array(
		'terms'                              => (int) isset( $_POST['terms'] ),
		'createaccount'                      => (int) ( $this->is_registration_enabled() ? ! empty( $_POST['createaccount'] ) : false ),
		'payment_method'                     => isset( $_POST['payment_method'] ) ? wc_clean( wp_unslash( $_POST['payment_method'] ) ) : '',
		'shipping_method'                    => isset( $_POST['shipping_method'] ) ? wc_clean( wp_unslash( $_POST['shipping_method'] ) ) : '',
		'ship_to_different_address'          => ! empty( $_POST['ship_to_different_address'] ) && ! wc_ship_to_billing_address_only(),
		'woocommerce_checkout_update_totals' => isset( $_POST['woocommerce_checkout_update_totals'] ),
	);
	// phpcs:enable WordPress.Security.NonceVerification.Missing

	$skipped = array();
	$form_was_shown = isset( $_POST['woocommerce-process-checkout-nonce'] ); // phpcs:disable WordPress.Security.NonceVerification.Missing

	foreach ( $this->get_checkout_fields() as $fieldset_key => $fieldset ) {
		if ( $this->maybe_skip_fieldset( $fieldset_key, $data ) ) {
			$skipped[] = $fieldset_key;
			continue;
		}

		foreach ( $fieldset as $key => $field ) {
			$type = sanitize_title( isset( $field['type'] ) ? $field['type'] : 'text' );

			if ( isset( $_POST[ $key ] ) && '' !== $_POST[ $key ] ) { // phpcs:disable WordPress.Security.NonceVerification.Missing
				$value = wp_unslash( $_POST[ $key ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
			} elseif ( isset( $field['default'] ) && 'checkbox' !== $type && ! $form_was_shown ) {
				$value = $field['default'];
			} else {
				$value = '';
			}

			if ( '' !== $value ) {
				switch ( $type ) {
					case 'checkbox':
						$value = 1;
						break;
					case 'multiselect':
						$value = implode( ', ', wc_clean( $value ) );
						break;
					case 'textarea':
						$value = wc_sanitize_textarea( $value );
						break;
					case 'password':
						break;
					default:
						$value = wc_clean( $value );
						break;
				}
			}

			$data[ $key ] = apply_filters( 'woocommerce_process_checkout_' . $type . '_field', apply_filters( 'woocommerce_process_checkout_field_' . $key, $value ) );
		}
	}

	if ( in_array( 'shipping', $skipped, true ) && ( WC()->cart->needs_shipping_address() || wc_ship_to_billing_address_only() ) ) {
		foreach ( $this->get_checkout_fields( 'shipping' ) as $key => $field ) {
			$data[ $key ] = isset( $data[ 'billing_' . substr( $key, 9 ) ] ) ? $data[ 'billing_' . substr( $key, 9 ) ] : '';
		}
	}

	// BW compatibility.
	$this->legacy_posted_data = $data;

	return apply_filters( 'woocommerce_checkout_posted_data', $data );
}