You are here

public function Order::getCalculationDate in Commerce Core 8.2

Gets the calculation date/time for the order.

Used during order processing, for determining promotion/tax availability. Matches the placed timestamp, if the order has been placed. Otherwise, falls back to the current request date/time.

Return value

\Drupal\Core\Datetime\DrupalDateTime The calculation date/time, in the store timezone.

Overrides OrderInterface::getCalculationDate

File

modules/order/src/Entity/Order.php, line 645

Class

Order
Defines the order entity class.

Namespace

Drupal\commerce_order\Entity

Code

public function getCalculationDate() {
  $timezone = $this
    ->getStore()
    ->getTimezone();
  $timestamp = $this
    ->getPlacedTime() ?: \Drupal::time()
    ->getRequestTime();
  $date = DrupalDateTime::createFromTimestamp($timestamp, $timezone);
  return $date;
}