For example, you setup rule is that if  users pay with paypal or credit card  -  they get -5%.

A customer tried to pay with card, it wasn't successful and after that he paid with cash on delivery, 

but he get the discount still.


WooCommerce allows to change payment for existing (and unpaid) order .

Use following PHP code to disable this feature.


add_action('before_woocommerce_pay', function() {
    $order_key = isset( $_GET['key'] ) ? $_GET['key'] : null;
    if ( ! $order_key ) {
        return;
    }
    $order_id  = wc_get_order_id_by_order_key( $order_key );
    $order_id = absint( $order_id );
    $order = wc_get_order($order_id);
    if ( ! $order ) {
        return;
    }
    $payment_method = $order->get_payment_method();
    add_filter( 'woocommerce_available_payment_gateways', function ( $gateways ) use ( $payment_method ) {
        return isset( $gateways[ $payment_method ] ) ? array( $payment_method => $gateways[ $payment_method ] ) : array();
    }, 10, 1 );
});