Last active
March 12, 2018 19:57
-
-
Save maxkostinevich/19175b6a1ff40aabf667b5d1a54a72a9 to your computer and use it in GitHub Desktop.
WooCommerce - How to change available payment methods depending on cart total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Change available payment methods depending on cart total | |
function payment_gateway_disable_payment_method( $available_gateways ) { | |
$cart_total = WC()->cart->total; | |
$condition_price = 1000.00; | |
if ( isset($available_gateways['cod']) && ($cart_total > $condition_price) ) { | |
unset( $available_gateways['cod'] ); // Disable "Cash on Delivery" payment method | |
} | |
return $available_gateways; | |
} | |
add_filter( 'woocommerce_available_payment_gateways', 'payment_gateway_disable_payment_method' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment