Jump to content

Hook to modify gateways variable


Chris-M

Recommended Posts

I am looking to delete certain gateways from a hook so that these gateways are not shown on the cart. The following code does the filtering/removal of the relevant gateways in a hook:

 

function hook_HideGateways($vars) {
 global $CONFIG;
 if ($vars['filename']=='cart') {

   // delete all but securetradingadvanced from gateways array
   foreach ($vars['gateways'] as $gw_name => $gw) {
     if ($gw_name != 'securetradingadvanced') {
       unset($vars['gateways'][$gw_name]); // delete gateway
     }
   }
 }
}

add_hook('ClientAreaPage', 1, 'hook_HideGateways');

 

How can I then return/override the $gateways Smarty variable as used in the cart templates?

 

Thanks in advance!

Link to comment
Share on other sites

I am looking to delete certain gateways from a hook so that these gateways are not shown on the cart. The following code does the filtering/removal of the relevant gateways in a hook:

 

function hook_HideGateways($vars) {
 global $CONFIG;
 if ($vars['filename']=='cart') {

   // delete all but securetradingadvanced from gateways array
   foreach ($vars['gateways'] as $gw_name => $gw) {
     if ($gw_name != 'securetradingadvanced') {
       unset($vars['gateways'][$gw_name]); // delete gateway
     }
   }
 }
}



add_hook('ClientAreaPage', 1, 'hook_HideGateways');

 

How can I then return/override the $gateways Smarty variable as used in the cart templates?

 

Thanks in advance!

 

 

 

Hi Chris-M

 

One of the solutions for this problem is as under:

 

function hideGateways($vars){

if($vars["filename"] == "cart" && ($_REQUEST["a"] == "view" || $_REQUEST["a"] == "checkout" )){

$gateways = $vars["gateways"]["securetradingadvanced"];

 

$return = array();

$return = array("gateways" => array("securetradingadvanced" => $gateways));

return $return;

}

}

 

add_hook("ClientAreaPage", 1, "hideGateways");

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.

×
×
  • 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