public function CommerceAddToCartLinkViewsField::render in Commerce Add To Cart Link 8
Same name and namespace in other branches
- 2.x src/Plugin/views/field/CommerceAddToCartLinkViewsField.php \Drupal\commerce_add_to_cart_link\Plugin\views\field\CommerceAddToCartLinkViewsField::render()
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides LinkBase::render
File
- src/
Plugin/ views/ field/ CommerceAddToCartLinkViewsField.php, line 110
Class
- CommerceAddToCartLinkViewsField
- Defines a Views field that adds an add to cart link.
Namespace
Drupal\commerce_add_to_cart_link\Plugin\views\fieldCode
public function render(ResultRow $row) {
$build = parent::render($row);
$metadata = AddToCartLink::fromVariationId($this
->getValue($row))
->metadata();
$metadata
->applyTo($build);
return $build;
}