Jump to content

How do I obtain the active gateway count?


Nullified

Recommended Posts

{php}print count($gateways);{/php}

I am using the above code to print out the count of items in the $gateways array, however it outputs 0 every time, even with recursive counting. I know the array contains 3 gateways based on the debug output. Can anyone shed some light on why this is not working as planned?

 

What I am trying to do is create an if statement that hides the gateway radio boxes (payment method selection area) if the available gateway count is one:

{if ($selectedgatewaytype eq "CC") and (count($gateways) eq 1)} style="display: none;"{/if}

Link to comment
Share on other sites

$gateways is a smarty var and wont show under that var in php code

try

[color=#000000][color=#007700]{[/color][color=#0000BB]php[/color][color=#007700]}print [/color][color=#0000BB]count[/color][color=#007700]([/color][color=#0000BB]$this->_tpl_vars->gateways[/color][color=#007700]);{/[/color][color=#0000BB]php[/color][color=#007700]}[/color][/color]

or in smarty (not tested)

{$gateways|count}
[color=#000000][color=#007700]{if [/color][color=#0000BB]$selectedgatewaytype eq [/color][color=#DD0000]"CC"[/color][color=#007700] AND [/color][color=#0000BB]$gateways|count [/color][color=#0000BB]eq 1[/color][color=#007700]} [/color][color=#0000BB]style[/color][color=#007700]=[/color][color=#DD0000]"display: none;"[/color][color=#007700]{/if}  [/color][/color]

Edited by sparky
Link to comment
Share on other sites

Yep... just tested it and see what you mean... had it wrong sorry

try this

{php}$this->assign("numgateways" , count($this->_tpl_vars["gateways"]));{/php}

[color=#000000][color=#007700]{if [/color][color=#0000BB]$selectedgatewaytype eq [/color][color=#DD0000]"CC"[/color][color=#007700] AND [/color][color=#0000BB]$[/color][/color]numgateways [color=#000000][color=#0000BB]eq 1[/color][color=#007700]} [/color][color=#0000BB]style[/color][color=#007700]=[/color][color=#DD0000]"display: none;"[/color][color=#007700]{/if}[/color][/color]

 

Not sure why you want that as if there is only 1 gateway it is hidden

Edited by sparky
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