protected function AddToCart::getVariationInjectedFields in Commerce Cart Flyout 8
Get injected variation fields.
Parameters
\Drupal\commerce_product\Entity\ProductVariationInterface[] $variations: The variations.
Return value
array The array of injected variation fields.
1 call to AddToCart::getVariationInjectedFields()
- AddToCart::viewElements in src/
Plugin/ Field/ FieldFormatter/ AddToCart.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ AddToCart.php, line 347
Class
- AddToCart
- Plugin implementation of the 'commerce_cart_flyout_add_to_cart' formatter.
Namespace
Drupal\commerce_cart_flyout\Plugin\Field\FieldFormatterCode
protected function getVariationInjectedFields(array $variations) {
return array_map(function (ProductVariationInterface $variation) {
return array_filter(array_map(function ($build) {
return [
'class' => $build['#ajax_replace_class'],
'output' => trim($this->renderer
->render($build)),
];
}, $this->variationFieldRenderer
->renderFields($variation, $this->viewMode)), function ($built) {
return !empty($built['output']);
});
}, $variations);
}