WC_Payment_Gateways::set_current_gateway()
Set the current, active gateway.
Method of the class: WC_Payment_Gateways{}
No Hooks.
Return
null
. Nothing (null).
Usage
$WC_Payment_Gateways = new WC_Payment_Gateways(); $WC_Payment_Gateways->set_current_gateway( $gateways );
- $gateways(array) (required)
- Available payment gateways.
WC_Payment_Gateways::set_current_gateway() WC Payment Gateways::set current gateway code WC 8.7.0
public function set_current_gateway( $gateways ) { // Be on the defensive. if ( ! is_array( $gateways ) || empty( $gateways ) ) { return; } $current_gateway = false; if ( WC()->session ) { $current = WC()->session->get( 'chosen_payment_method' ); if ( $current && isset( $gateways[ $current ] ) ) { $current_gateway = $gateways[ $current ]; } } if ( ! $current_gateway ) { $current_gateway = current( $gateways ); } // Ensure we can make a call to set_current() without triggering an error. if ( $current_gateway && is_callable( array( $current_gateway, 'set_current' ) ) ) { $current_gateway->set_current(); } }