You are here

public static function AddToCart::isApplicable in Commerce Cart Flyout 8

Returns if the formatter can be used for the provided field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition that should be checked.

Return value

bool TRUE if the formatter can be used, FALSE otherwise.

Overrides FormatterBase::isApplicable

File

src/Plugin/Field/FieldFormatter/AddToCart.php, line 260

Class

AddToCart
Plugin implementation of the 'commerce_cart_flyout_add_to_cart' formatter.

Namespace

Drupal\commerce_cart_flyout\Plugin\Field\FieldFormatter

Code

public static function isApplicable(FieldDefinitionInterface $field_definition) {
  $has_cart = \Drupal::moduleHandler()
    ->moduleExists('commerce_cart');
  $entity_type = $field_definition
    ->getTargetEntityTypeId();
  $field_name = $field_definition
    ->getName();
  return $has_cart && $entity_type == 'commerce_product' && $field_name == 'variations';
}