So, what’s the specific problem? What was expected? What did you get? Where do you you guess which code causes the problem? Until which line your code runs fine? Where is the test data?
I’m wondering whether you intended to compare the trackingNumbers array count to be greater than 1, or whether you meant to check it was greater than zero. I can’t see why you would not just run the foreach() if there is 1 or more array element, and do something else if there are none.
What is in the trackingNumbers array, how many elements when you test it?
The loop code is confusing. At the top, you create a variable called $trackNo which apparently contains a comma-separated list of tracking numbers. You then explode() it into an array called $trackNos, and then have a for() loop through it.
But, inside that loop, you create an entry in your $trackingNumbers[] array with an element called track_no which contains your initial comma-separated list. Surely in that part, you just want to put the appropriate element from $trackNos?
Same reason I gave above - you are assigning the complete list of tracking numbers that you have in $trackNo into each individual entry in your new array.
If that’s not the fault, perhaps you could respond to the question @rpkamp asked - what are you expecting, and what are you getting instead?
I was able to Get back the Array, but when the Second email kicks-off, still returning the same tracking number from the array and not going to the next(). Can someone tell me if there is a way to if check current(), then go to next()
if (!$isOrderShipped) {
return false;
} else {
if (count($items) > 1 && count($trackingNumbers) >= 1) {
echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail);
next($trackingInfoInEmail);
} else if(count($items) == 1) {
if (count($trackingNumbers) == 1) {
echo "The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail);
next($trackingInfoInEmail);
} else if (count($trackingNumbers) > 1){
echo "You may receive multiple shipments and emails. The tracking number for this shipment is " . $displayShippingMethod . " # " . next($trackingInfoInEmail);
next($trackingInfoInEmail);
} else if(count($trackingNumbers)==0){
echo "Your Order has been Shipped with" . $displayShippingMethod;
}
} else {
echo "Your Order has been Shipped with" . $displayShippingMethod;
}
}