mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://stackoverflow.com/questions/78271585/hiding-cod-if-subtotal-is-under-a-certain-amount-in-woocommerce-subtotal-prop
10 lines
383 B
Text
10 lines
383 B
Text
add_filter( 'woocommerce_available_payment_gateways', 'ts_disable_cod' );
|
|
function ts_disable_cod( $available_gateways ) {
|
|
// Target Checkout to avoid warnings or errors
|
|
if( is_checkout() && ! is_wc_endpoint_url() && WC()->cart ) {
|
|
if ( WC()->cart->subtotal <= 10 ) {
|
|
unset( $available_gateways['cod'] );
|
|
}
|
|
}
|
|
return $available_gateways;
|
|
}
|