shippingRate; $shippingMethod = $shippingRate->shippingMethod; $cart = $shippingOptionRequest->cart; $subTotal = $cart->lines->sum('subTotal.value'); $pricing = Pricing::for($shippingRate)->qty($subTotal)->get(); if (! $pricing->matched) { return null; } return new ShippingOption( name: $shippingMethod->name ?: $this->name(), description: $shippingMethod->description ?: $this->description(), identifier: $shippingRate->getIdentifier(), price: $pricing->matched->price, taxClass: $shippingRate->getTaxClass(), taxReference: $shippingRate->getTaxReference(), ); } public function on(ShippingRate $shippingRate): self { $this->shippingRate = $shippingRate; return $this; } }