public function FlatRate::calculateRates in Commerce Shipping 8.2
Calculates rates for the given shipment.
Parameters
\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment.
Return value
\Drupal\commerce_shipping\ShippingRate[] The rates.
Overrides ShippingMethodInterface::calculateRates
2 methods override FlatRate::calculateRates()
- DynamicRate::calculateRates in tests/
modules/ commerce_shipping_test/ src/ Plugin/ Commerce/ ShippingMethod/ DynamicRate.php - Calculates rates for the given shipment.
- FlatRatePerItem::calculateRates in src/
Plugin/ Commerce/ ShippingMethod/ FlatRatePerItem.php - Calculates rates for the given shipment.
File
- src/
Plugin/ Commerce/ ShippingMethod/ FlatRate.php, line 107
Class
- FlatRate
- Provides the FlatRate shipping method.
Namespace
Drupal\commerce_shipping\Plugin\Commerce\ShippingMethodCode
public function calculateRates(ShipmentInterface $shipment) {
$rates = [];
$rates[] = new ShippingRate([
'shipping_method_id' => $this->parentEntity
->id(),
'service' => $this->services['default'],
'amount' => Price::fromArray($this->configuration['rate_amount']),
'description' => $this->configuration['rate_description'],
]);
return $rates;
}