Order quantity increment condition for payment method I need to set order increment quantities in my Commerce 2 website. The website has two stores: retail and wholesale. Customers who are shopping in my &quot;retail consumers&quot; store must have increments of 6 products in their cart in order to check out (6, 12, 18, 24, etc). Customers in my &quot;wholesale consumers&quot; store must have at least 4 products in their cart in order to check out (4, 8, 12, 16, etc).
My plan is to add a custom Condition that can be used for the two payment gateways that will be used in the stores (one for each store). That custom Condition would allow me to designate an increment value for the product quantity for each gateway. &quot;Make this gateway available if the cart contains an increment of 6 products&quot;.
I recently created a similar plugin for product quantity minimums in the cart, and I think I can re-use most of that code with a few adjustments. I am just not sure how to factor in the incremental requirement. It would be acceptable to hard-code the increments of 6 if that is the best/easiest way to do it; I could then create two separate condition plugins, one for 6 and one for 4.
Below is the Condition plugin code I have so far:
&lt;?php

namespace Drupal\order_total_quantity_increments\Plugin\Commerce\Condition;

use Drupal\commerce\Plugin\Commerce\Condition\ConditionBase;
use Drupal\commerce_price\Calculator;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Provides the quantity increment condition for order items.
 *
 * @CommerceCondition(
 *   id = &quot;order_total_quantity_increments&quot;,
 *   label = @Translation(&quot;Quantity Increment&quot;),
 *   display_label = @Translation(&quot;Limit by quantity increments&quot;),
 *   category = @Translation(&quot;Products&quot;),
 *   entity_type = &quot;commerce_order&quot;,
 *   weight = 10,
 * )
 */
class OrderTotalQuantityIncrements extends ConditionBase {
    
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'increment' =&gt; NULL,
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildConfigurationForm($form, $form_state);

    $increment = $this-&gt;configuration['increment'];
    
    if (isset($increment) &amp;&amp; !isset($increment['number'])) {
      $increment = NULL;
    }

    $form['increment'] = [
      '#type' =&gt; 'number',
      '#title' =&gt; t('Increment'),
      '#default_value' =&gt; $this-&gt;configuration['increment'],
      '#min' =&gt; 1,
      '#required' =&gt; TRUE,
    ];

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitConfigurationForm(array &amp;$form, FormStateInterface $form_state) {
    parent::submitConfigurationForm($form, $form_state);

    $values = $form_state-&gt;getValue($form['#parents']);
    $this-&gt;configuration['increment'] = $values['increment'];
  }

  /**
   * {@inheritdoc}
   */
  public function evaluate(EntityInterface $entity) {
    $this-&gt;assertEntity($entity);
    /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
    $order = $entity;
    $increment = '0';
    foreach ($order-&gt;getItems() as $order_item) {
      $increment = Calculator::add($increment, $order_item-&gt;getQuantity());
    }

  }

}

I believe I have to modify the last part of the code (below) or add something after it.
  public function evaluate(EntityInterface $entity) {
    $this-&gt;assertEntity($entity);
    /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
    $order = $entity;
    $increment = '0';
    foreach ($order-&gt;getItems() as $order_item) {
      $increment = Calculator::add($increment, $order_item-&gt;getQuantity());
    }

  }

Can anyone please provide me with a direction to go in/guidance on how I should modify the code to meet my objective?
Per OP's comment, updated solution:
 public function evaluate(EntityInterface $entity) {
    $this-&gt;assertEntity($entity);
    /** @var \Drupal\commerce_order\Entity\OrderInterface $order */
    $order = $entity;
    $increment = $this-&gt;configuration['increment'];
    $total = 0;

    foreach ($order-&gt;getItems() as $order_item) {
      $total += $order_item-&gt;getQuantity();
    }
    if ($total % $increment !== 0) {  return FALSE;  }

    return TRUE;
  }