If you wan to get coupon entity from order there is a quick magic method to do that. First load order by some property, we can use ID
$orders= \Drupal::entityTypeManager()->getStorage('commerce_order')-> loadByProperties(['order_id' => '233136']); $order= reset($orders); or just $order= \Drupal::entityTypeManager()->getStorage('commerce_order')->load('233136');
and then we can get Coupon entity with
$coupon = $order->get('coupons')->entity;
and use it as we like, for example we can get that coupon code and check its value
if ($coupon->getCode() == "BALANCE20")
if you want to get direct value of some field, you can do this instead.
$state = $order->get('state')->value;
which will give you state value, for example "completed" if order is in that state. This are some basics how to use entitys and OOP in drupal 8, no more looping through arrays and trying to find proper selector of value you want to use.