You are here

class TestAdjustmentProcessor in Commerce Core 8.2

Adds order and order item adjustments for testing purposes.

Hierarchy

Expanded class hierarchy of TestAdjustmentProcessor

1 string reference to 'TestAdjustmentProcessor'
commerce_order_test.services.yml in modules/order/tests/modules/commerce_order_test/commerce_order_test.services.yml
modules/order/tests/modules/commerce_order_test/commerce_order_test.services.yml
1 service uses TestAdjustmentProcessor
commerce_order_test.test_adjustment_processor in modules/order/tests/modules/commerce_order_test/commerce_order_test.services.yml
Drupal\commerce_order_test\TestAdjustmentProcessor

File

modules/order/tests/modules/commerce_order_test/src/TestAdjustmentProcessor.php, line 13

Namespace

Drupal\commerce_order_test
View source
class TestAdjustmentProcessor implements OrderProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function process(OrderInterface $order) {
    foreach ($order
      ->getItems() as $order_item) {

      // Add adjustment for PriceCalculatorTest.
      if ($order
        ->getEmail() == 'user2@example.com') {
        $order_item
          ->addAdjustment(new Adjustment([
          'type' => 'test_adjustment_type',
          'label' => '$2.00 fee',
          'amount' => new Price('2.00', 'USD'),
        ]));
      }
    }
  }

}

Members