WC_Checkout::__get()
Gets the legacy public variables for backwards compatibility.
Method of the class: WC_Checkout{}
Hooks from the method
Return
Array|String
.
Usage
$WC_Checkout = new WC_Checkout(); $WC_Checkout->__get( $key );
- $key(string) (required)
- Key.
WC_Checkout::__get() WC Checkout:: get code WC 9.8.2
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' ); } }