Last active
February 9, 2019 23:21
-
-
Save yanknudtskov/5c1fae79c00e5422932e to your computer and use it in GitHub Desktop.
Remove payment gateways based on the totalt amount in the WooCommerce cart. #woocommerce #cart #gateways
This file contains hidden or 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 | |
add_filter('woocommerce_available_payment_gateways', 'va_filter_gateways', 1); | |
function va_filter_gateways($gateways) { | |
global $woocommerce; | |
// This line should be changed to reflect the name of the payment gateway you want to remove | |
$payment_method_name = 'paypal'; // Could be bacs, cheque, paypal, epay_dk, etc. | |
// The limit for the cart before we remove the specified gateway | |
$cart_total_limit = 5000; | |
if($woocommerce->cart->total > $cart_total_limit) | |
{ | |
unset($gateways[$payment_method_name]); | |
} | |
return $gateways; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment