name = $id; } /** * Load settings. */ public function initialize() { $this->settings = get_option( 'woocommerce_' . $this->name . '_settings', array() ); $gateways = WC()->payment_gateways() ? WC()->payment_gateways()->payment_gateways() : array(); $this->gateway = isset( $gateways[ $this->name ] ) ? $gateways[ $this->name ] : null; } /** * Whether the method can be used. * * @return bool */ public function is_active() { return $this->gateway && $this->gateway->is_available(); } /** * Script handles. * * @return string[] */ public function get_payment_method_script_handles() { $handle = 'memomatch-blocks'; if ( ! wp_script_is( $handle, 'registered' ) ) { wp_register_script( $handle, MEMOMATCH_URL . 'assets/js/blocks.js', array( 'wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities' ), MEMOMATCH_VERSION, true ); } return array( $handle ); } /** * Data passed to the script. * * @return array */ public function get_payment_method_data() { return array( 'title' => $this->gateway ? $this->gateway->title : '', 'description' => $this->gateway ? $this->gateway->description : '', 'supports' => array( 'products' ), ); } }