/**
  * @param Cart $cart
  * @return array
  */
 public static function availableShippingTypes(Cart $cart)
 {
     $availableShippingTypes = [];
     $first = true;
     if ($cart->totalProducts() == 0) {
         return $availableShippingTypes;
     }
     foreach ($cart->getItems() as $cartItem) {
         /* @var $cartItem CartItem */
         $product = $cartItem->getProduct();
         /* @var $product Product */
         $productShippingTypes = [];
         if (count($product->getShipping())) {
             foreach ($product->getShipping() as $sh) {
                 /* @var $sh ProductShippingOption */
                 if ($shippingType = $sh->matchShippingType($cart->getCountryId())) {
                     $productShippingTypes[] = $shippingType;
                 }
             }
             if (!$first) {
                 // if there are any available ones that aren't available for this product, remove them
                 $newAvailable = [];
                 foreach ($productShippingTypes as $type) {
                     if (in_array($type, $availableShippingTypes)) {
                         $newAvailable[] = $type;
                     }
                 }
                 $availableShippingTypes = $newAvailable;
             } else {
                 $first = false;
                 $availableShippingTypes = $productShippingTypes;
             }
         }
     }
     return $availableShippingTypes;
 }