diff --git a/woocommerce-gateway-dummy.php b/woocommerce-gateway-dummy.php index 344bbf4..f0f236f 100644 --- a/woocommerce-gateway-dummy.php +++ b/woocommerce-gateway-dummy.php @@ -53,8 +53,15 @@ public static function init() { * @param array */ public static function add_gateway( $gateways ) { - $options = get_option( 'woocommerce_dummy_settings', array() ); - $hide_for_non_admin_users = $options['hide_for_non_admin_users']; + + $options = get_option( 'woocommerce_dummy_settings', array() ); + + if ( isset( $options['hide_for_non_admin_users'] ) ) { + $hide_for_non_admin_users = $options['hide_for_non_admin_users']; + } else { + $hide_for_non_admin_users = 'no'; + } + if ( ( 'yes' === $hide_for_non_admin_users && current_user_can( 'manage_options' ) ) || 'no' === $hide_for_non_admin_users ) { $gateways[] = 'WC_Gateway_Dummy'; } @@ -100,7 +107,7 @@ public static function woocommerce_gateway_dummy_woocommerce_block_support() { add_action( 'woocommerce_blocks_payment_method_type_registration', function( Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry $payment_method_registry ) { - $payment_method_registry->register( new WC_Gateway_Dummy_Blocks_Support ); + $payment_method_registry->register( new WC_Gateway_Dummy_Blocks_Support() ); } ); }