public static function AddToCartLink::fromVariationId in Commerce Add To Cart Link 8
Same name and namespace in other branches
- 2.x src/AddToCartLink.php \Drupal\commerce_add_to_cart_link\AddToCartLink::fromVariationId()
AddToCartLink convenience constructor.
Parameters
int $id: The product variation ID.
Return value
\Drupal\commerce_add_to_cart_link\AddToCartLink The constructed object.
File
- src/
AddToCartLink.php, line 41
Class
- AddToCartLink
- Defines a helper class for constructing add to cart links.
Namespace
Drupal\commerce_add_to_cart_linkCode
public static function fromVariationId($id) {
if ($variation = ProductVariation::load($id)) {
return new static($variation);
}
else {
throw new \UnexpectedValueException('Can not load product variation: %s', $id);
}
}