You are here

public static function Avatax::hasAvataxAdjustments in Drupal Commerce Connector for AvaTax 8

Check if the given order has AvaTax adjustments.

Parameters

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

Return value

bool TRUE if the order has AvaTax adjustments, FALSE if not.

2 calls to Avatax::hasAvataxAdjustments()
OrderSubscriber::commitTransaction in src/EventSubscriber/OrderSubscriber.php
Commits a transaction or the order in AvaTax.
OrderSubscriber::voidTransaction in src/EventSubscriber/OrderSubscriber.php
Voids a transaction in AvaTax for the given order.

File

src/Avatax.php, line 47

Class

Avatax

Namespace

Drupal\commerce_avatax

Code

public static function hasAvataxAdjustments(OrderInterface $order) {

  /** @var \Drupal\commerce_order\Adjustment[] $avatax_adjustments */
  $avatax_adjustments = array_filter($order
    ->collectAdjustments(), function (Adjustment $adjustment) use ($order) {
    return $adjustment
      ->getType() == 'tax' && strpos($adjustment
      ->getSourceId(), 'avatax|') !== FALSE;
  });
  return !empty($avatax_adjustments);
}