0

if i unset a payment gateway it works in the view page that the payment methods which i unset will hide. but when i proceed to checkout with other payment methods,it shows error "Invalid payment methods".

public function get_available_payment_gateways() {
        $_available_gateways = array();

    foreach ( $this->payment_gateways as $gateway ) {
        if ( $gateway->is_available() ) {
            if ( ! is_add_payment_method_page() ) {
                $_available_gateways[ $gateway->id ] = $gateway;
            } else if( $gateway->supports( 'add_payment_method' ) ) {
                $_available_gateways[ $gateway->id ] = $gateway;
            } else if ( $gateway->supports( 'tokenization' ) ) {
                $_available_gateways[ $gateway->id ] = $gateway;
            }
        }
    }
    *if(!isset($_SESSION["freetrialis"])){
        unset($_available_gateways['cod']); 
    }else{
        unset($_available_gateways['authnet']);
        unset($_available_gateways['paypal']);
        unset($_SESSION["freetrialis"]);
    }*
    return apply_filters( 'woocommerce_available_payment_gateways', $_available_gateways );
}
0

im sorry i got the answer its because of unset($_SESSION["freetrialis"]). because get_available_payment_gateways() is used after this call in class-wc-checkout(), and at that time it mismatches because of the session :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.