data['charge_by'] ?? 'cart_total'; $tier = $chargeBy === 'weight' ? $cart->lines->load('purchasable')->sum(fn ($line) => ($line->purchasable->weight_value ?? 0) * $line->quantity) : $cart->lines->sum('subTotal.value'); $pricing = Pricing::for($shippingRate)->qty($tier)->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(), ); } }