You are here

public function CommerceCurrencyResolversRefreshTrait::shouldCurrencyRefresh in Commerce Currency Resolver 8

Get refresh state based on path.

Parameters

\Drupal\commerce_order\Entity\OrderInterface $order: Order object to check for currency changes.

Return value

bool Return true or false.

2 calls to CommerceCurrencyResolversRefreshTrait::shouldCurrencyRefresh()
CurrencyOrderProcessor::process in src/CurrencyOrderProcessor.php
Processes an order.
CurrencyOrderRefresh::checkCurrency in src/EventSubscriber/CurrencyOrderRefresh.php
Check for misplace in currency. Refresh order if necessary.

File

src/CommerceCurrencyResolversRefreshTrait.php, line 81

Class

CommerceCurrencyResolversRefreshTrait
Handle access where currency resolver can refresh order.

Namespace

Drupal\commerce_currency_resolver

Code

public function shouldCurrencyRefresh(OrderInterface $order) {

  // If order have specific flag set, skip refreshing currency.
  if ($order
    ->getData('currency_resolver_skip')) {
    return FALSE;
  }

  // Do not trigger currency refresh in cli - drush, cron, etc.
  // If we load order in cli, we don't want to manipulate order
  // with currency refresh.
  if (PHP_SAPI === 'cli') {
    return FALSE;
  }
  if ($this
    ->isAdminPath()) {
    return FALSE;
  }

  // Not owner of order.
  if ($this
    ->checkOrderOwner($order)) {
    return FALSE;
  }

  // Order is not in draft status.
  if ($this
    ->checkOrderStatus($order)) {
    return FALSE;
  }
  return TRUE;
}