Zen Cart Logo
Forums / Contribution-Writing Guidelines / die in a foreach()

die in a foreach()

Views: 1,787

Results 1 to 5 of 5
22 Oct 2012, 8:07 AM
#1
frilansreklam avatar

frilansreklam

New Zenner

Join Date:
Sep 2008
Location:
Sweden
Posts:
99
Plugin Contributions:
1

die in a foreach()

One of our partners in Payment modules need to have a correct answer on why the die not work. Can someone help me to se the problem or give a good answer.

    foreach($GLOBALS['order_totals'] as $k_global => $v_global)
    {
       $name = strip_tags($v_global['title']);
        die($name);
   }
22 Oct 2012, 3:24 PM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,688
Plugin Contributions:
56

Re: die in a foreach()

Are you sure you're entering the foreach loop?

if $GLOBALS['order_totals'] is empty or null, the foreach won't loop.

22 Oct 2012, 7:12 PM
#3
frilansreklam avatar

frilansreklam

New Zenner

Join Date:
Sep 2008
Location:
Sweden
Posts:
99
Plugin Contributions:
1

Re: die in a foreach()

Thanks Swguy. It's not my payment module but they have made lot of bugs so I tried to fix it. It is the most popular card payment module in Sweden so it has to work correct.

The die part of the code I toke that away and the checkout confirmation was working so you are right about that. But do they need that part that is my own question. Why pick up subtotal, tax and shipping when it is in the checkout page. in the payment service all information is there when I take the die row away. It only print it out or have I wrong? (never use die)

22 Oct 2012, 7:30 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,688
Plugin Contributions:
56

Re: die in a foreach()

It looks like a debugging statement to me; it's certainly not intended for final release (why would you want to stop processing in the middle?).

22 Oct 2012, 8:08 PM
#5
frilansreklam avatar

frilansreklam

New Zenner

Join Date:
Sep 2008
Location:
Sweden
Posts:
99
Plugin Contributions:
1

Re: die in a foreach()

Yes it look like that so I should look in the older version if it's different and se what to find out on that. Thanks again.