public static function AddToCartFormatter::isApplicable in Commerce Product Bundle 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/ AddToCartFormatter.php, line 79
Class
- AddToCartFormatter
- Plugin implementation of the 'commerce_product_bundle_add_to_cart' formatter.
Namespace
Drupal\commerce_product_bundle\Plugin\Field\FieldFormatterCode
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_bundle' && $field_name == 'bundle_items';
}