Hallo zusammen,
ist es möglich, im Template box-standard.html.twig oder in price-unit.html.twig eine CSS-Klasse oder eine Abfrage wie z. B. “isOnSale” einzufügen? Habe dazu in der Doku und dem Github Repo leider nichts gefunden.
Hallo zusammen,
ist es möglich, im Template box-standard.html.twig oder in price-unit.html.twig eine CSS-Klasse oder eine Abfrage wie z. B. “isOnSale” einzufügen? Habe dazu in der Doku und dem Github Repo leider nichts gefunden.
Ein Sale gibt es bei Shopware nicht. Es gibt nur einen ListPrice, der dann den durchgestrichenen Preis und den prozentualen Rabatt erzeugt.
{% sw_extends ‚@Storefront/storefront/component/product/card/price-unit.html.twig‘ %}
{% block component_product_box_main_price %}
{% if isListPrice %}
{{parent()}}
{% else %}
{{parent()}}
{% endif %}
{% endblock %}
Je nachdem was du vor hast, könnte das helfen
Kannst natürlich die Klasse auch schon in ein bestehendes Element schreiben anstatt eine neue div aufzumachen
LG
Hi zusammen,
danke für die Lösungsvorschläge
Aber ganz klappen tut es immer noch nicht.
Es geht mir hauptsächlich darum diesen Part hier auszublenden, wenn der Artikel nicht reduziert ist:
<span class="regulation-price">vorher 99,90 €</span>
Gibt es dafür eine Bedingung? Denn bei allen reduzierten Artikeln soll der Regulation Price noch angezeigt werden. Aktuell ist er sowohl bei reduzierten, als auch bei regulären Artikeln sichtbar.
Hey,
{% if isRegulationPrice && product.price|first.regulationPrice.gross > product.price|first.gross %}
<span class="product-price with-regulation-price">
{# @deprecated tag:v6.7.0 - Showing asterisk next to every price is deprecated. Tax and shipping info is displayed as text instead if `allowBuyInListing` is true. #}
{% if isListPrice %}<br>{% endif %}
<span class="regulation-price">{{ 'general.listPricePreviously'|trans({'%price%': price.regulationPrice.price|currency }) }}
{% if not feature('ACCESSIBILITY_TWEAKS') %}
{{ 'general.star'|trans|sw_sanitize }}
{% endif %}
</span>
</span>
{% endif %}
Schau mal ob ich dich da richtig verstanden habe.
Grüße
Den |first Filter kannst du weglassen und direkt die Variablen price.regulationPrice.price bzw. price.unitPrice nutzen.
Hi, das hat mir in der Tat weitergeholfen, allerdings musste ich den Regulation Price an zwei Stellen anpassen. Hier die vollständige Lösung falls jemand an einer ähnlichen Stelle hängt:
{% sw_extends ‚@Storefront/storefront/component/buy-widget/buy-widget-price.html.twig‘ %}
{# Regulation Preis nur bei Sale-Artikeln zeigen #}
{% block buy_widget_price_content %}
{% set listPrice = price.listPrice %} {% set isListPrice = price.listPrice.percentage > 0 %} {% set isRegulationPrice = price.regulationPrice != null %} <p class="product-detail-price{% if isListPrice %} with-list-price{% endif %}{% if isRegulationPrice and isListPrice %} with-regulation-price{% endif %}"> {{ price.unitPrice|currency }} </p> {% if isListPrice %} {% block buy_widget_was_price %} {% block buy_widget_was_price_badge %} <span class="list-price-badge">%</span> {% endblock %} {% set afterListPriceSnippetExists = 'listing.afterListPrice'|trans|*length* > 0 %} {% set beforeListPriceSnippetExists = 'listing.beforeListPrice'|trans|*length* > 0 %} {% block buy_widget_was_price_wrapper %} <span class="product-detail-list-price-wrapper"> {% if beforeListPriceSnippetExists %}{{ 'listing.beforeListPrice'|trans|*trim* }}{% endif %} <span{% if not (afterListPriceSnippetExists or beforeListPriceSnippetExists) %} class="list-price-price"{% endif %}> {{ listPrice.price|currency }} </span> {% if afterListPriceSnippetExists %} {{ 'listing.afterListPrice'|trans|*trim* }} {% endif %} <span class="list-price-percentage"> {{ 'detail.listPricePercentage'|trans({'%price%': listPrice.percentage })|sw_sanitize }} </span> </span> {% endblock %} {% endblock %} {% endif %} *{# regulationPrice NUR bei Sale #}* {% if isRegulationPrice and isListPrice %} <span class="product-detail-list-price-wrapper"> <span class="regulation-price"> {{ 'general.listPricePreviously'|trans({'%price%': price.regulationPrice.price|currency }) }} </span> </span> {% endif %}{% endblock %}
{% sw_extends ‚@Storefront/storefront/component/product/card/price-unit.html.twig‘ %}
{% block component_product_box_regulation_price %}
*{# regulationPrice nur anzeigen, wenn auch ein Sale (listPrice) aktiv ist #}* {% if isRegulationPrice and isListPrice %} <span class="product-price with-regulation-price"> <br aria-hidden="true"> <span class="regulation-price"> {{ 'general.listPricePreviously'|trans({'%price%': price.regulationPrice.price|currency }) }} </span> </span> {% endif %}
Danke für eure Hilfe.