Jump to content

Pre Select Payment Gateway For Each Currency


Code-Storm

Recommended Posts

  • 2 months later...
On 12/27/2020 at 11:15 AM, brian! said:

 


<?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");

 

So for ClientAreaPageViewInvoice , why this does not work ?

<?php
 



function gateway_pormoneda($vars) {

	//$client = Menu::context('client');
	//$currency = $client->currency;
	 $currency = $vars['currency'];
	$gateways = $vars['gateways'];
	if ($currency == 1) {
		$validgateways = array('paypalcheckout','stripe');
	}
	elseif ($currency == 2) {
		$validgateways = array('directopago_cl','stripe');
	}
  
  elseif ($currency == 7) {
    $validgateways = array('directopago_uy','stripe');
  }
  elseif ($currency == 10) {
    $validgateways = array('cuentadigital');
  }

	foreach ($gateways as $k => $item) {
		if (!in_array($item['sysname'],$validgateways)) {
			unset($gateways[$k]);
		}
	}
	return array("gateways" => $gateways);
}
add_hook("ClientAreaPageViewInvoice", 1, "gateway_pormoneda");

 

 

Link to comment
Share on other sites

  • 1 month later...
On 12/24/2020 at 3:43 AM, cswschinmay said:

 


 <?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");

 

 

 

Thanks for your help. This hook worked for me.

But, one issue. After placing an order, on the invoice page. There is no dropdown for selecting another gateway as per the hook.

Link to comment
Share on other sites

  • 1 year later...

Hola alguien ha podido resolver porque no funciona el hook para cuando se visualizan las factura aquí dejo el que ha desarrollado brian

 

<?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');

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated