Skip to content

Instantly share code, notes, and snippets.

@bencroker
bencroker / _productComponent.twig
Last active November 3, 2020 22:35 — forked from piotrpog/product.twig
Commerce product page with Sprig
{% set variantParam = 'variant' %}
{# set product #}
{% set product = craft.products.id(productId).one() %}
{# set variant #}
{% set variant = product.defaultVariant %}
{# overvrite default variant with url param #}
{% if product.variants|filter(v => v.id == craft.app.request.getParam(variantParam)) is not empty %}