public function OrderRefresh::shouldRefresh in Commerce Core 8.2
Checks whether the order should be refreshed.
Wraps the needsRefresh() check with an additional refresh mode check, skipping the refresh for non-customers when specified.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
Return value
bool TRUE if the order should be refreshed, FALSE otherwise.
Overrides OrderRefreshInterface::shouldRefresh
File
- modules/
order/ src/ OrderRefresh.php, line 97
Class
- OrderRefresh
- Default implementation for order refresh.
Namespace
Drupal\commerce_orderCode
public function shouldRefresh(OrderInterface $order) {
if (!$this
->needsRefresh($order)) {
return FALSE;
}
/** @var \Drupal\commerce_order\Entity\OrderTypeInterface $order_type */
$order_type = $this->orderTypeStorage
->load($order
->bundle());
// Ensure the order is only refreshed for its customer, when configured so.
if ($order_type
->getRefreshMode() == OrderType::REFRESH_CUSTOMER) {
if ($order
->getCustomerId() != $this->currentUser
->id()) {
return FALSE;
}
}
return TRUE;
}