Order approval plugin using payment gateway feature for achieving desired functionality.You can unset payment gateway based on stock status. following sample code may hep you
add_filter('woocommerce_available_payment_gateways','conditional_payment_gateways', 10, 1);
function conditional_payment_gateways( $available_gateways ) {
// Not in backend (admin)
if( is_admin() )
return $available_gateways;
foreach (WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
// Get the WC_Product object
$product = wc_get_product($cart_item['product_id']);
// Get the stock
$stock = $product->get_stock_quantity();
// Your Logic goes here
}
// Based on condition
unset($available_gateways['woa_gateway']); // unset 'order approval'
return $available_gateways;
}
-
This reply was modified 4 years, 1 month ago by
Sarankumar.