You are here

public function ShippingCurrencyOrderProcessor::process in Commerce Currency Resolver 8

Processes an order.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: The order.

Overrides OrderProcessorInterface::process

File

modules/shipping/src/ShippingCurrencyOrderProcessor.php, line 35

Class

ShippingCurrencyOrderProcessor
Force refresh of shipping rates for shipment for currency changes.

Namespace

Drupal\commerce_currency_resolver_shipping

Code

public function process(OrderInterface $order) {

  // No shipment, skip order.
  if (!$this->shippingOrderManager
    ->hasShipments($order)) {
    return;
  }

  // No need to trigger this processor.
  if (!$order
    ->getData(CurrencyHelper::CURRENCY_ORDER_REFRESH)) {
    return;
  }

  // Unset flag.
  $order
    ->unsetData(CurrencyHelper::CURRENCY_ORDER_REFRESH);

  // If we don't have already this flag, trigger it.
  // Otherwise amount on shipment is gonna be on old currency.
  if (!$order
    ->getData(ShippingOrderManagerInterface::FORCE_REFRESH)) {
    $order
      ->setData(ShippingOrderManagerInterface::FORCE_REFRESH, TRUE);
  }
}