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.
Leave a Reply
You must be logged in to post a comment.
Theres a filter called woocommerce_available_payment_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.
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.
This seems to do the trick to preserve the value, and add conditional logic even after the payment area reloads.