WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
[resolved] Remove payment method for guests (3 posts)

  1. Winnetou
    Member
    Posted 2 months ago #

    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://wordpress.org/plugins/woocommerce/

  2. vark
    Member
    Posted 2 months ago #

    Hi,
    I think this can point you in the direction...
    http://wordpress.org/support/topic/free-shipping-rules-based-on-role

  3. Winnetou
    Member
    Posted 2 months ago #

    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' );

Reply

You must log in to post.

About this Plugin

About this Topic