Automattic\WooCommerce\Blocks\BlockTypes
Checkout::hydrate_customer_payment_methods()
Get saved customer payment methods for use in checkout.
Метод класса: Checkout{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->hydrate_customer_payment_methods();
Код Checkout::hydrate_customer_payment_methods() Checkout::hydrate customer payment methods WC 8.7.0
protected function hydrate_customer_payment_methods() { if ( ! is_user_logged_in() || $this->asset_data_registry->exists( 'customerPaymentMethods' ) ) { return; } add_filter( 'woocommerce_payment_methods_list_item', [ $this, 'include_token_id_with_payment_methods' ], 10, 2 ); $payment_gateways = $this->get_enabled_payment_gateways(); $payment_methods = wc_get_customer_saved_methods_list( get_current_user_id() ); // Filter out payment methods that are not enabled. foreach ( $payment_methods as $payment_method_group => $saved_payment_methods ) { $payment_methods[ $payment_method_group ] = array_values( array_filter( $saved_payment_methods, function( $saved_payment_method ) use ( $payment_gateways ) { return in_array( $saved_payment_method['method']['gateway'], array_keys( $payment_gateways ), true ); } ) ); } $this->asset_data_registry->add( 'customerPaymentMethods', $payment_methods ); remove_filter( 'woocommerce_payment_methods_list_item', [ $this, 'include_token_id_with_payment_methods' ], 10, 2 ); }