Skip to content

Commit

Permalink
Limit the AddToCart formatter to the variations field.
Browse files Browse the repository at this point in the history
  • Loading branch information
bojanz committed Jan 19, 2016
1 parent 99055d9 commit 75fa8cc
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -140,6 +140,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
* {@inheritdoc}
*/
public static function isApplicable(FieldDefinitionInterface $field_definition) {
return \Drupal::moduleHandler()->moduleExists('commerce_cart');
$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';
}

}

0 comments on commit 75fa8cc

Please sign in to comment.