I've tried to follow along this thread, and adapt this hook to my own needs, but struggeling to make it work. Essentially, customers can have one of two currencies on my website. If EUR (currency 1), I'd like to limit the drop down on invoices to PayPal. If ZAR (currency 2), I'd like to limit the dropdown to PayFast.
This is the hook I modified from the above:
<?php
# ViewInvoice Gateway Hook
# Written by brian!
function hook_view_invoice_gateway($vars) {
$client = $vars['clientsdetails'];
$currency = $client['currency'];
if ($vars['status'] == 'Unpaid' && $currency == '1') {
$gatewaydropdown = $vars['gatewaydropdown'];
$paypalcheckout = '<option value="paypalcheckout">PayPal</option>';
$gd2 = str_replace($paypalcheckout, '', $gatewaydropdown) ;
return array("gatewaydropdown" => $gd2);
}
elseif ($vars['status'] == 'Unpaid' && $currency == '2') {
$gatewaydropdown = $vars['gatewaydropdown'];
$payfast = '<option value="payfast">PayFast</option>';
$gd2 = str_replace($payfast, '', $gatewaydropdown) ;
return array("gatewaydropdown" => $gd2);
}
}
add_hook('ClientAreaPageViewInvoice', 1, 'hook_view_invoice_gateway');
?>
Can someone please help me figure out where I'm going wrong?