• Resolved Anonymous User 9922786

    (@anonymized-9922786)


    Hi all,

    I want to remove the payment method BACS for guests in WooCommerce?
    Is it possible to create an remove action filter? Something like this for the BACS payment method:

    if ( !function_exists('is_user_logged_in') ) :
    remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
    
    endif;

    I don’t know where to start. I found some actions in class-wc-gateway-bacs.php:

    add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
    add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'save_account_details' ) );
    add_action( 'woocommerce_thankyou_bacs', array( $this, 'thankyou_page' ) );

    I hope you’ll help me.

    Many thanks for reading!

    https://www.ads-software.com/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,
    I think this can point you in the direction…
    https://www.ads-software.com/support/topic/free-shipping-rules-based-on-role

    Thread Starter Anonymous User 9922786

    (@anonymized-9922786)

    Thanks for your quick response!

    Thanks for your link!

    This solves my problem:

    /**
     * WooCommerce - Disable BACS
     */
    function payment_gateway_disable_postpay( $available_gateways ) {
    global $woocommerce;
    if(!is_user_logged_in()){
    unset( $available_gateways['bacs'] );
    }
    return $available_gateways;
    }
    add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_postpay' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove payment method for guests’ is closed to new replies.