Hiding payment gateway based on currency.
-
Hello,
First off, thank you for your great and comprehensive plugin!
My website allows Canadian Dollar (CAD) and Iranian Toman (IRT) checkout via PaypPal and Zarinpal gateways respectively.
On checkout, I would like to disable/hide Zarinpal gateway when CAD currency is selected. I have found the code below which was written for WooCommerce Currency Switcher and hides paypal when Euro or GBP are selected.
I would greatly appreciate if you help me tailor this code for your plugin and so Zarinpal gateway becomes hidden when CAD is selected.
Thank you,
RobCoded:
add_filter(‘woocommerce_available_payment_gateways’, ‘woocs_filter_gateways’, 1);
function woocs_filter_gateways($gateway_list)
{
global $WOOCS;
$exclude = array(
‘paypal’ => array(‘EUR’, ‘GBP’), //do not show paypal gate if current currency is EUR or GBP
//***
foreach ($exclude as $gateway_key => $currencies)
{
if (isset($gateway_list[$gateway_key]) AND in_array($WOOCS->current_currency, $currencies))
{
unset($gateway_list[$gateway_key]);
}
}
return $gateway_list;
}The page I need help with: [log in to see the link]
- The topic ‘Hiding payment gateway based on currency.’ is closed to new replies.