How to disable the "place an order" button ONLY for the "Cheque" gateway. I don't want my users to place an order for this gateway because they need to make a contact through the given info before making any payments.
I found Remove Woocommerce "place order" button for a specific shipping class which is what I want to do, but for "cheque" payment method instead.
I tried to replace the ID 332 with the "Cheque" ID but it completely removed the button for all gateways. its ID on the backend is cheque
and the ID and class on the checkout page payment_method_cheque
.
add_filter('woocommerce_order_button_html', 'remove_order_button_html' );
function remove_order_button_html( $button ) {
// HERE define your targeted shipping class
$targeted_payment_method = 'payment_method_cheque';
$found = false;
// Loop through cart items
foreach( WC()->cart->get_cart() as $cart_item ) {
if( $cart_item['data']->get_shipping_class_id() == $targeted_shipping_class ) {
$found = true; // The targeted shipping class is found
break; // We stop the loop
}
}
// If found we remove the button
if( $found )
$button = '';
return $button;
}
But it doesn't work. Any advice?