I am trying to programmatically manipulate the selection of Payment Method between BACS and a No Payment required option. My client wants the ability to Request for Quote only, so I've extended woocommerce actions and filters, and provided a method to request quote through the cart system. If the user has requested a quote only, on the checkout page I am trying to auto select the Cash on Delivery option, which I've renamed to "Request for Quote Only - No payment required". Any advice would be helpful.


Theres a filter called woocommerce_available_payment_gateways:

function filter_gateways($gateways){
    global $woocommerce;        
    //Remove a specific payment option
    return $gateways

I'm not sure where and how you get / store the Request for Quote option, but you can access the value inside the filter_gateways function and you can remove a specific gateway with a conditional logic.

  • I've been using this filter, yes, and it works great without my conditional logic. I think the problem is that the value that indicates that it's a Quote Request, is being passed through query vars. What happens is, at first it will output my query var value within the filter function, but then the payment options are reloaded dynamically by the looks of things, possibly due to shipping options, and then it loses my query var. At least I think I'm on the right track, but getting my conditional logic into this filter seems to be a bit of a nightmare – PipIWYG Mar 20 '14 at 11:21

My problem here was with using query vars to store a value to indicate that the request is for quote only. The payment area is dynamically refreshed based on changes within the checkout areas, and on load, payment methods is reloaded, and query var values are lost. I managed to overcome this issue by making use of the WC()->session->set and WC()->session->get functions. I've added the following two actions to manipulate layout based on the session value.

add_action("woocommerce_before_checkout_form", "custom_before_checkout_action");
function custom_before_checkout_action() {
    if (isset($_GET["quote"]) && $_GET["quote"] == "1") {
        echo '<h2>Request for Quote</h2>';
    else {
        echo '<h2>Buy Sample</h2>';

function filter_gateways($gateways){
    if (WC()->session->get("quote") == "true")

    return $gateways;

This seems to do the trick to preserve the value, and add conditional logic even after the payment area reloads.

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.