Code-Storm Posted November 28, 2018 Share Posted November 28, 2018 Hi There Here is what i need: The user could select the currency on the shopping cart while they ordering something from cart page. After click on the checkout button, only the payment gateways set to that currency should be available. Example, if an user select currency USD it will show / Marked Paypal Gateway, other Payment Gateway goes hidden , if user select GBP,CAD it will show Stripe and Paypal goes hidden same things for the invoices. and user can only see the selected payment gateway on their invoice for duepayment. Does anyone know, how can i accomplish this. i am using WHMCS 7.5.2 Thanks in Advance!! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 28, 2018 Share Posted November 28, 2018 On 28/11/2018 at 07:46, Code-Storm said: Does anyone know, how can i accomplish this. i am using WHMCS 7.5.2 possibly a question better suited to posting in Service Offers & Requests, but basically it's going to be two hooks... can't think of an existing addon that does this, and a hook solution would work in v7.5.2 and later because there have not been any significant changes to that page since that release. On 28/11/2018 at 07:46, Code-Storm said: The user could select the currency on the shopping cart while they ordering something from cart page. After click on the checkout button, only the payment gateways set to that currency should be available. that would require a clientareapagecart hook - it wouldn't be a million miles away from the one I posted below to change the payment options when the cart balance is zero... On 28/11/2018 at 07:46, Code-Storm said: same things for the invoices. and user can only see the selected payment gateway on their invoice for duepayment again, that's going to be another hook (clientareapageviewinvoice this time) - you know the client is going to be logged in, so it should just be a case of getting their currency from the template and modifying the dropdown array accordingly.. i've posted CAPVI hooks before, but the one you need wouldn't be too far from the above hook method wise, e.g the hook will determine the valid gateway(s) and remove the others from the dropdown. 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 28, 2018 Author Share Posted November 28, 2018 1 hour ago, brian! said: possibly a question better suited to posting in Service Offers & Requests, but basically it's going to be two hooks... can't think of an existing addon that does this, and a hook solution would work in v7.5.2 and later because there have not been any significant changes to that page since that release. that would require a clientareapagecart hook - it wouldn't be a million miles away from the one I posted below to change the payment options when the cart balance is zero... so you'd have to modify it to make two checks - one to get the current currency if the user isn't logged in (e.g they've chosen it from a dropdown etc) and one if they are logged in (where they will be locked into using the same currency forever). again, that's going to be another hook (clientareapageviewinvoice this time) - you know the client is going to be logged in, so it should just be a case of getting their currency from the template and modifying the dropdown array accordingly.. i've posted CAPVI hooks before, but the one you need wouldn't be too far from the above hook method wise, e.g the hook will determine the valid gateway(s) and remove the others from the dropdown. Hello Brian, Thanks for your suggestion, But i saw some previous thread about same option: here one Payment Gateway selection by Currency i want the same work ! like if my client choose USD/CAD/AUD/GBP it will pre select "Paypal, if he/she choose BDT it will mark another. i have done some work but nothing comes up! Will you please help me with those code & in viewcart.tpl & checkout.tpl where i exactly put those codes! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2018 Share Posted November 29, 2018 19 hours ago, Code-Storm said: Thanks for your suggestion, But i saw some previous thread about same option: here one Payment Gateway selection by Currency but that thread is two and a half years old, written for the "Modern" template and edits a template - as we're virtually in 2019, you shouldn't be editing templates if/when there is a better solution (e.g an action hook) - not least because a) it removes the need to edit the template after every WHMCS release, and b) in this instance, the hook should work on both cart templates options (e.g Modern and Standard_cart). 19 hours ago, Code-Storm said: i want the same work ! like if my client choose USD/CAD/AUD/GBP it will pre select "Paypal, if he/she choose BDT it will mark another. i have done some work but nothing comes up! then do it as a hook and get it to remove the gateways that you don't want by modifying the previous linked hook - although what it won't do (neither would a template edit) is pre-select PayPal or Stripe (as written each would be the only option available) - with PayPal, I think you could pre-select it in the hook without issue; but for Stripe, it's the pressing of the Stripe radio option that triggers the slide event to allow for card entry submission - which if already pre-selected, you can't do... you'd then have to use JS/Jquery in the hook to trigger that slide to occur automatically. 19 hours ago, Code-Storm said: Will you please help me with those code & in viewcart.tpl & checkout.tpl where i exactly put those codes! it would take me longer to write/test this in the template than it would to write a hook - especially as you haven't said which orderform template you're using.... and unless there's something glaringly obvious that i'm missing, I don't really see any advantage to editing the template for this issue. besides, after i've done that, you'll then want the same on the invoices page! 🙄 for trivial navbar/sidebar hooks, I don't mind posting code... but when you're into the realms of customisation that likely needs testing time, then you should be thinking about paying a developer... it's not good for the WHMCS developer community, if i'm sat here posting solutions to issues that developers should be paid to solve... i've already told you how to accomplish this (as per your original question) - short of writing the hooks for you, there's not much more I can do. 0 Quote Link to comment Share on other sites More sharing options...
bear Posted November 29, 2018 Share Posted November 29, 2018 29 minutes ago, brian! said: you shouldn't be editing templates if/when there is a better solution (e.g an action hook) - not least because a) it removes the need to edit the template after every WHMCS release Well, until WHMCS changes how (and if) they work, that is. 😉 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2018 Share Posted November 29, 2018 29 minutes ago, bear said: Well, until WHMCS changes how (and if) they work, that is. 😉 true, but if you try to use two hooks with the same name, you're asking for trouble! 🙂 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 29, 2018 Author Share Posted November 29, 2018 1 hour ago, brian! said: but that thread is two and a half years old, written for the "Modern" template and edits a template - as we're virtually in 2019, you shouldn't be editing templates if/when there is a better solution (e.g an action hook) - not least because a) it removes the need to edit the template after every WHMCS release, and b) in this instance, the hook should work on both cart templates options (e.g Modern and Standard_cart). then do it as a hook and get it to remove the gateways that you don't want by modifying the previous linked hook - although what it won't do (neither would a template edit) is pre-select PayPal or Stripe (as written each would be the only option available) - with PayPal, I think you could pre-select it in the hook without issue; but for Stripe, it's the pressing of the Stripe radio option that triggers the slide event to allow for card entry submission - which if already pre-selected, you can't do... you'd then have to use JS/Jquery in the hook to trigger that slide to occur automatically. it would take me longer to write/test this in the template than it would to write a hook - especially as you haven't said which orderform template you're using.... and unless there's something glaringly obvious that i'm missing, I don't really see any advantage to editing the template for this issue. besides, after i've done that, you'll then want the same on the invoices page! 🙄 for trivial navbar/sidebar hooks, I don't mind posting code... but when you're into the realms of customisation that likely needs testing time, then you should be thinking about paying a developer... it's not good for the WHMCS developer community, if i'm sat here posting solutions to issues that developers should be paid to solve... i've already told you how to accomplish this (as per your original question) - short of writing the hooks for you, there's not much more I can do. Hello Brian, Thanks for the hook! to be honest, I don't need the same things for Invoice too!. it's pretty much enough for me, if i get this only for cart pages!. currently i am using 4 templates for 4 different product category. Standard, modern, pure comparison, universal slider 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2018 Share Posted November 29, 2018 3 minutes ago, Code-Storm said: Thanks for the hook! i'm glad you liked it - don't think i'll be making a habit of it though! 4 minutes ago, Code-Storm said: to be honest, I don't need the same things for Invoice too!. it's pretty much enough for me, if i get this only for cart pages!. currently i am using 4 templates for 4 different product category. Standard, modern, pure comparison, universal slider forget about slider and comparison, by the time you get to checkout, you'll be using modern or sc. 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 29, 2018 Author Share Posted November 29, 2018 8 minutes ago, brian! said: i'm glad you liked it - don't think i'll be making a habit of it though! forget about slider and comparison, by the time you get to checkout, you'll be using modern or sc. Well then it's only possible for specific templates! so is it possible to get those codes Brian as an example?? Thanks is Advance 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2018 Share Posted November 29, 2018 4 minutes ago, Code-Storm said: Well then it's only possible for specific templates! so is it possible to get those codes Brian as an example?? that hook works in both Modern and Standard_cart... if you're using Pure Comparison or Universal Slider, after the opening products page, you are using Standard_cart anyway, so the hook will work with them too. 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 29, 2018 Author Share Posted November 29, 2018 2 minutes ago, brian! said: that hook works in both Modern and Standard_cart... if you're using Pure Comparison or Universal Slider, after the opening products page, you are using Standard_cart anyway, so the hook will work with them too. where i need to put the hooks then??? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 29, 2018 Share Posted November 29, 2018 Just now, Code-Storm said: where i need to put the hooks then??? /includes/hooks 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 30, 2018 Author Share Posted November 30, 2018 (edited) 18 hours ago, Code-Storm said: then Hello Brian, For USD,AUD,CAD,GBP paypal pre select perfectly but for local currency which is BDT it's not showing the Local Payment Method which is Cash Payment and on checkoutpage http://prntscr.com/lovr4z Edited November 30, 2018 by Code-Storm Wrong info 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted November 30, 2018 Share Posted November 30, 2018 2 hours ago, Code-Storm said: For USD,AUD,CAD,GBP paypal pre select perfectly but for local currency which is BDT it's not showing the Local Payment Method which is Cash Payment and on checkoutpage have you updated the hook to account for this change? I coded it to use Stripe for BDT as per your question... elseif (in_array($currency['code'],array('BDT'))) { $allowed = ['stripe']; } you'd need to change that to the internal name used for your Cash Payment gateway - if it's "Mail In Payment", it would be 'mailin'... if it's something else, and you don't know what it is, you'll need to disable the hook (e.g remove the above lines) and view the source of the checkout page in the browser and that will tell you the name... then put those lines back in, change stripe to whatever this gateway name is and then save the hook. 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted November 30, 2018 Author Share Posted November 30, 2018 1 hour ago, brian! said: have you updated the hook to account for this change? I coded it to use Stripe for BDT as per your question... elseif (in_array($currency['code'],array('BDT'))) { $allowed = ['stripe']; } you'd need to change that to the internal name used for your Cash Payment gateway - if it's "Mail In Payment", it would be 'mailin'... if it's something else, and you don't know what it is, you'll need to disable the hook (e.g remove the above lines) and view the source of the checkout page in the browser and that will tell you the name... then put those lines back in, change stripe to whatever this gateway name is and then save the hook. Hello Brian, I apologize for the mistakes! i just wrote "Stripe" as an example for BDT payment. i am really sorry I understand! i just need to replace my getaway name instead Stripe! what about if i want to keep an option like. For USD/AUD/CAD/GBP/ paypal is pre-selected besides there will be an option like Bank Transfer or Payza 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 1, 2018 Share Posted December 1, 2018 17 hours ago, Code-Storm said: what about if i want to keep an option like. For USD/AUD/CAD/GBP/ paypal is pre-selected besides there will be an option like Bank Transfer or Payza then you add the gateways that you want to show for a currency as a list in the hook... if (in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { $allowed = ['paypal','banktransfer','payza']; } ... so for AUD/CAD/GBP/USD, the only gateway options shown will be PayPal, Bank Transfer and Payza... all other gateways will be removed. 1 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted December 1, 2018 Author Share Posted December 1, 2018 4 hours ago, brian! said: then you add the gateways that you want to show for a currency as a list in the hook... if (in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { $allowed = ['paypal','banktransfer','payza']; } ... so for AUD/CAD/GBP/USD, the only gateway options shown will be PayPal, Bank Transfer and Payza... all other gateways will be removed. Hello Brian, Hat's off to you! and also grateful to you! 0 Quote Link to comment Share on other sites More sharing options...
Code-Storm Posted January 31, 2019 Author Share Posted January 31, 2019 On 12/1/2018 at 6:35 PM, brian! said: then you add the gateways that you want to show for a currency as a list in the hook... if (in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { $allowed = ['paypal','banktransfer','payza']; } ... so for AUD/CAD/GBP/USD, the only gateway options shown will be PayPal, Bank Transfer and Payza... all other gateways will be removed. Hello Brian, everythings looks good. but need a little help, according to the code client can pay their bill by using paypal but we want they can pay bill via their credit card without login to paypal. for this paypal express checkout is good option but paypal express checkout option not working when they select their currency USD/AUD/CAD here is the code <?php /** * Modify Payment Gateway Options Based On Currency * @author Brian! */ function cart_gateway_removal_based_on_currency_hook($vars) { if ($vars['templatefile']=='viewcart'){ $gateways = $vars['gateways']; $currency = $vars['currency']; if (in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { $allowed = ['paypalexpress','paypal','directdebit']; } elseif (in_array($currency['code'],array('BDT'))) { $allowed = ['walletmixgateway','directdebit']; } if (!empty($allowed)) { foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$allowed)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } } } add_hook("ClientAreaPageCart", 1, "cart_gateway_removal_based_on_currency_hook"); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 31, 2019 Share Posted January 31, 2019 10 hours ago, Code-Storm said: everythings looks good. but need a little help, according to the code client can pay their bill by using paypal but we want they can pay bill via their credit card without login to paypal. for this paypal express checkout is good option but paypal express checkout option not working when they select their currency USD/AUD/CAD the problem is that PayPal Express Checkout isn't a payment gateway option shown at checkout, it's shown at the View Cart stage.. https://docs.whmcs.com/PayPal_Express_Checkout Quote The PayPal Express checkout module allows your clients to check out in a single click without the need to enter their details into the WHMCS order form. The client's name, address, email and phone number will be taken from those stored in their PayPal account and a one-time payment sent when the Express Checkout button is clicked on the order form. so the hook is working fine - it's just that you're asking it to do something that it wasn't designed to do. 🙂 you could try another hook to cover PayPal Express Checkout and when it is or isn't shown.. <?php /** * PayPal Express Checkout Options Based On Currency * @author Brian! */ function cart_paypal_express_checkout_based_on_currency_hook($vars) { if ($vars['templatefile']=='viewcart'){ $currency = $vars['currency']; if (!in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { return array("gatewaysoutput" => null); } } } add_hook("ClientAreaPageCart", 1, "cart_paypal_express_checkout_based_on_currency_hook"); which basically says that if the current currency is AUD, CAD, GBP or USD, then do nothing (as you want PEC as an option for those currencies) - for any other currency, the PayPal Express option will be removed from View Cart. you might run into issues if multiple gateways were used at view cart like this, and you wanted to discriminate between them for certain currencies, but I think PEC is the only one so far that does it... 1 Quote Link to comment Share on other sites More sharing options...
Jarves Posted August 29, 2020 Share Posted August 29, 2020 can someone please help me on latest version? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted August 31, 2020 Share Posted August 31, 2020 On 29/08/2020 at 22:37, Jarves said: can someone please help me on latest version? to do what exactly ? PayPal Express has been deprecated or are talking about the original linked to hook ? 0 Quote Link to comment Share on other sites More sharing options...
cswschinmay Posted November 29, 2020 Share Posted November 29, 2020 On 1/31/2019 at 6:17 PM, brian! said: <?php /** * PayPal Express Checkout Options Based On Currency * @author Brian! */ function cart_paypal_express_checkout_based_on_currency_hook($vars) { if ($vars['templatefile']=='viewcart'){ $currency = $vars['currency']; if (!in_array($currency['code'],array('AUD','CAD','GBP','USD'))) { return array("gatewaysoutput" => null); } } } add_hook("ClientAreaPageCart", 1, "cart_paypal_express_checkout_based_on_currency_hook"); So I tried re-using this code, I wanted to include Add Funds and Invoices Payment Page with the pre-select per currency option. Currently all available payment gateway show up. I am trying to ensure clientarea addfunds and viewinvoice also uses the same logic. Using Standard Cart checkout with Six Theme. But I haven't had any success with this modification as all continue to show. Any indicators? <?php /** * Modify Payment Gateway Options Based On Currency * @author Brian! */ function cart_gateway_removal_based_on_currency_hook($vars) { if ($vars['templatefile']=='viewcart' && $vars['templatefile']=='clientareaaddfunds' && $vars['templatefile']=='viewinvoice'){ $gateways = $vars['gateways']; $currency = $vars['currency']; if (in_array($currency['code'],array('EUR'))) { $allowed = ['pl_stripe_sofort']; } elseif (in_array($currency['code'],array('INR'))) { $allowed = ['banktransfer']; } elseif (in_array($currency['code'],array('USD'))) { $allowed = ['paypal']; } if (!empty($allowed)) { foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$allowed)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } } } add_hook("ClientAreaPageCart", 1, "cart_gateway_removal_based_on_currency_hook"); add_hook("ClientAreaPageViewInvoice", 1, "cart_gateway_removal_based_on_currency_hook"); add_hook("ClientAreaPageAddFunds", 1, "cart_gateway_removal_based_on_currency_hook"); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 1, 2020 Share Posted December 1, 2020 On 29/11/2020 at 20:18, cswschinmay said: So I tried re-using this code, I wanted to include Add Funds and Invoices Payment Page with the pre-select per currency option. Currently all available payment gateway show up. I doubt it would work as all three pages handle gateway arrays slightly differently - and that first hook would have been about PayPal Express and similar... certainly add funds wouldn't use that gateway in the same away (it's not a cart page). On 29/11/2020 at 20:18, cswschinmay said: I am trying to ensure clientarea addfunds and viewinvoice also uses the same logic. Using Standard Cart checkout with Six Theme. But I haven't had any success with this modification as all continue to show. Any indicators? I would split this into two separate hooks - same file if you like, but separate.... you could do it as one hook, but there's little to be gained. addfunds & cart could basically use the same hook if it had to... so if I write a very basic example hook where you define the valid gateways that can be used in the add funds page... <?php # Remove Gateways From Add Funds Page Hook # Written by brian! function addfunds_gateway_removal($vars) { $gateways = $vars['gateways']; $validgateways = array('banktransfer','stripe'); foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$validgateways)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } add_hook("ClientAreaPageAddFunds", 1, "addfunds_gateway_removal"); before & after screenshots of the add funds page after the hook has defined banktransfer and stripe as the only valid gateways... you could add the code below to the end of the hook and it would work in the cart too. add_hook("ClientAreaPageCart", 1, "addfunds_gateway_removal"); though in the cart you can define gateways used per product group from product group settings... and as this is a basic example, watch out for leaving the user with no gateway options by removing all of the available gateways! with regards to viewinvoice, I don't propose to go it this now, but unlike AF/Cart. there isn't a gateways array that you can simple unset elements of to remove them - with VI, the equivalent variable is just the HTML code for a series of form dropdown select options that you would have to remove by replacing the specific string.... the idea is outlined in the hook below... as I said, you could use one hook if you had to with 2/3 if statements to determine which page the user is on and react accordingly, but there's little to be gained IMO. 1 Quote Link to comment Share on other sites More sharing options...
cswschinmay Posted December 23, 2020 Share Posted December 23, 2020 On 12/1/2020 at 6:16 PM, brian! said: <?php # Remove Gateways From Add Funds Page Hook # Written by brian! function addfunds_gateway_removal($vars) { $gateways = $vars['gateways']; $validgateways = array('banktransfer','stripe'); foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$validgateways)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } add_hook("ClientAreaPageAddFunds", 1, "addfunds_gateway_removal"); Hello Brain, Holidays are here finally can get this to work :) Thanks for the ideas. So i try this one file -> one hook for addfunds and cart. We have three currencies and 6 gateway. Not all currencies accepted in those gateway. But sadly only cart option works per currency-gateway. Add Funds show all Gateways and doesn't work if i do all (Cart and Add Funds in one file) <?php /** * Modify Payment Gateway Options Based On Currency * @author Brian! */ function addfunds_gateway_removal($vars) { { $gateways = $vars['gateways']; $currency = $vars['currency']; if (in_array($currency['code'],array('EUR'))) { $allowed = ['stripe']; } elseif (in_array($currency['code'],array('INR'))) { $allowed = ['razorpay']; } elseif (in_array($currency['code'],array('USD'))) { $allowed = ['paypal']; } if (!empty($allowed)) { foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$allowed)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } } } add_hook("ClientAreaPageCart", 1, "addfunds_gateway_removal"); add_hook("ClientAreaPageAddFunds", 1, "addfunds_gateway_removal"); I also tried the hook example you provided from above it worked for selected gateway and modified it slightly for more currency options: This another Hook file for Add Funds which doesn't work :( <?php /** * Modify Payment Gateway Options Based On Currency * @author Brian! */ function addfunds_credit_gateway_removal($vars) { { $gateways = $vars['gateways']; $currency = $vars['currency']; if ($currency == '6') { $validgateways = ['stripe']; } elseif ($currency == '3') { $validgateways = ['razorpay']; } elseif ($currency == '1') { $validgateways = ['paypal']; } if (!empty($allowed)) { foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$validgateways)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } } } add_hook("ClientAreaPageAddFunds", 1, "addfunds_credit_gateway_removal"); For the Invoices an logic like this doesn't seem to work <?php # ViewInvoice Gateway Hook # Written by brian! function hook_view_invoice_gateway($vars) { $client = $vars['clientsdetails']; $currency = $client['currency']; $gateways = $vars['gateways']; if ($currency == '1') { $allowed = ['stripe','paypal','bitpay','banktransfer']; } elseif ($currency == '3') { $allowed = ['razorpay','banktransfer']; } elseif ($currency == '6') { $allowed = ['stripe','pl_stripe_sofort','banktransfer']; } else { $gatewaylimit = 0; } if ($vars['status'] == 'Unpaid' && $vars['clientdetails']->toNumeric() = $currency) { $gatewaydropdown = $vars['gatewaydropdown']; $stripe = '<option value="stripe">Stripe</option>'; $pl_stripe_sofort = '<option value="pl_stripe_sofort">Stripe</option>'; $gd2 = str_replace($stripe, '', $gatewaydropdown) ; return array("gatewaydropdown" => $gd2); } } add_hook('ClientAreaPageViewInvoice', 1, 'hook_view_invoice_gateway'); 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted December 27, 2020 Share Posted December 27, 2020 On 23/12/2020 at 21:43, cswschinmay said: Holidays are here finally can get this to work 🙂 I think you'll find holidays are not for coding! 🎄 On 23/12/2020 at 21:43, cswschinmay said: But sadly only cart option works per currency-gateway. three points... I would consider keeping the hooks separate - I know why you would like to join them together (e.g to only define the allowed gateways once), but they all work in slightly different ways, so not easily combined in one hook (can be done, just complicates the coding). I would not consider the Add Funds page to be part of the cart - so the currency value that is available to the cart will NOT exist... but with Add Funds, the client must be logged in and so therefore you can get the value by other means. Similarly, the View Invoice page cannot access currency in the same way as the cart - so other methods would be required for that (should be the same as 2). <?php # Remove Gateways From Add Funds Page Hook # Written by brian! function addfunds_gateway_removal($vars) { $client = Menu::context('client'); $currency = $client->currency; $gateways = $vars['gateways']; if ($currency == 1) { $validgateways = array('banktransfer'); } elseif ($currency == 2) { $validgateways = array('banktransfer'); } foreach ($gateways as $k => $item) { if (!in_array($item['sysname'],$validgateways)) { unset($gateways[$k]); } } return array("gateways" => $gateways); } add_hook("ClientAreaPageAddFunds", 1, "addfunds_gateway_removal"); 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.