new VPRWC_Adapter_Cray(), 'paystack' => new VPRWC_Adapter_Paystack(), 'flutterwave' => new VPRWC_Adapter_Flutterwave(), 'stripe' => new VPRWC_Adapter_Stripe(), 'dodo' => new VPRWC_Adapter_Dodo(), 'generic' => new VPRWC_Adapter_Generic(), ); $list = apply_filters( 'vprwc_register_adapters', $defaults ); $clean = array(); foreach ( (array) $list as $key => $adapter ) { if ( $adapter instanceof VPRWC_Adapter ) { $clean[ (string) $key ] = $adapter; } } // The generic adapter always runs last so explicit _vprwc_* meta wins. if ( isset( $clean['generic'] ) ) { $generic = $clean['generic']; unset( $clean['generic'] ); $clean['generic'] = $generic; } self::$adapters = $clean; } return self::$adapters; } /** * Forget the cached list (tests, late registration). */ public static function reset() { self::$adapters = null; } /** * Run every adapter that supports the order. * * @param array $data Data. * @param WC_Order $order Order. * @return array */ public static function apply( array $data, $order ) { foreach ( self::all() as $adapter ) { try { if ( $adapter->supports( $order ) ) { $out = $adapter->apply( $data, $order ); $data = is_array( $out ) ? $out : $data; } } catch ( \Throwable $e ) { // A broken adapter must never stop a receipt; core data is still printed. if ( function_exists( 'wc_get_logger' ) ) { wc_get_logger()->warning( 'Receipt adapter ' . $adapter->id() . ' failed: ' . $e->getMessage(), array( 'source' => 'acrislip-order-receipts' ) ); } } } return $data; } }