Automattic\WooCommerce\Blocks\BlockTypes
Checkout::hydrate_customer_payment_methods()
Get saved customer payment methods for use in checkout.
Method of the class: Checkout{}
No Hooks.
Return
null
. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->hydrate_customer_payment_methods();
Checkout::hydrate_customer_payment_methods() Checkout::hydrate customer payment methods code WC 9.6.1
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 ); }