WC_Checkout::__get()publicWC 1.0

Gets the legacy public variables for backwards compatibility.

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

Хуки из метода

Возвращает

Массив|Строку.

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

$WC_Checkout = new WC_Checkout();
$WC_Checkout->__get( $key );
$key(строка) (обязательный)
Key.

Код WC_Checkout::__get() WC 8.7.0

public function __get( $key ) {
	if ( in_array( $key, array( 'posted', 'shipping_method', 'payment_method' ), true ) && empty( $this->legacy_posted_data ) ) {
		$this->legacy_posted_data = $this->get_posted_data();
	}

	switch ( $key ) {
		case 'enable_signup':
			return $this->is_registration_enabled();
		case 'enable_guest_checkout':
			return ! $this->is_registration_required();
		case 'must_create_account':
			return $this->is_registration_required() && ! is_user_logged_in();
		case 'checkout_fields':
			return $this->get_checkout_fields();
		case 'posted':
			wc_doing_it_wrong( 'WC_Checkout->posted', 'Use $_POST directly.', '3.0.0' );
			return $this->legacy_posted_data;
		case 'shipping_method':
			return $this->legacy_posted_data['shipping_method'];
		case 'payment_method':
			return $this->legacy_posted_data['payment_method'];
		case 'customer_id':
			/**
			 * Provides an opportunity to modify the customer ID associated with the current checkout process.
			 *
			 * @since 3.0.0 or earlier
			 *
			 * @param int The current user's ID (this may be 0 if no user is logged in).
			 */
			return apply_filters( 'woocommerce_checkout_customer_id', get_current_user_id() );
		case 'shipping_methods':
			return (array) WC()->session->get( 'chosen_shipping_methods' );
	}
}