public function USPSRateBase::getQuotes in Ubercart 8.4
Retrieves shipping quotes for this method.
Parameters
\Drupal\uc_order\OrderInterface $order: The order to retrieve the quotes for.
Return value
array An array of shipping quotes.
Overrides ShippingQuotePluginInterface::getQuotes
2 methods override USPSRateBase::getQuotes()
- USPSDomesticRate::getQuotes in shipping/
uc_usps/ src/ Plugin/ Ubercart/ ShippingQuote/ USPSDomesticRate.php - Retrieves shipping quotes for this method.
- USPSInternationalRate::getQuotes in shipping/
uc_usps/ src/ Plugin/ Ubercart/ ShippingQuote/ USPSInternationalRate.php - Retrieves shipping quotes for this method.
File
- shipping/
uc_usps/ src/ Plugin/ Ubercart/ ShippingQuote/ USPSRateBase.php, line 104
Class
- USPSRateBase
- Common functionality for USPS shipping quotes plugins.
Namespace
Drupal\uc_usps\Plugin\Ubercart\ShippingQuoteCode
public function getQuotes(OrderInterface $order) {
$rate = $this->configuration['base_rate'];
$field = $this->configuration['field'];
foreach ($order->products as $product) {
if (isset($product->nid->entity->{$field}->value)) {
$product_rate = $product->nid->entity->{$field}->value * $product->qty->value;
}
else {
$product_rate = $this->configuration['product_rate'] * $product->qty->value;
}
$rate += $product->price->value * floatval($product_rate) / 100;
}
return [
$rate,
];
}