commerce_inventory-8.x-1.0-alpha6/src/Plugin/Commerce/InventoryAdjustmentType/IncreaseInventory.php

src/Plugin/Commerce/InventoryAdjustmentType/IncreaseInventory.php
<?php

namespace Drupal\commerce_inventory\Plugin\Commerce\InventoryAdjustmentType;

/**
 * Provides a generic adjustment-type for increasing inventory.
 *
 * @CommerceInventoryAdjustmentType(
 *   id = "increase",
 *   label = @Translation("Increase")
 * )
 */
class IncreaseInventory extends InventoryAdjustmentTypeBase implements InventoryAdjustmentTypeInterface {

  /**
   * {@inheritdoc}
   */
  public function adjustQuantity($quantity) {
    // If-check and negative multiplier are faster than abs()
    if ($quantity < 0) {
      return $quantity * -1;
    }
    return $quantity;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc