CalculatedPrice per Plugin ergänzen.

Wir haben “Erweiterte Preise” in Benutzung - jetzt möchte ich jedoch nicht Preise “bis” - sondern Preise “ab”.

Wenn man im Dump schaut wird unter “quantity” lediglich der “bis” Wert angezeigt - nicht jedoch “ab” (außer beim letzten Element).

Hier wird in der Schleife immer der “bis” Wert angezeigt - und beim letzten Element der “ab” Wert - weiß jemand wo genau das definiert ist?
Ich habe bereits alles mögliche gefunden - aber in welcher Datei wird aus quantityStart bzw quantityEnd das “quantity”?

Bin hier auch auf der Suche. Geht leider nur bis. Aber das ist doch einfach nur verwirrend. Ich würde lieber “ab” nehmen.

 

@systemmarketing‍ Habt ihr diesbezüglich vielleicht eine Lösung gefunden?

@shoshosho schrieb:

Bin hier auch auf der Suche. Geht leider nur bis. Aber das ist doch einfach nur verwirrend. Ich würde lieber „ab“ nehmen.

 

@systemmarketing‍ Habt ihr diesbezüglich vielleicht eine Lösung gefunden?

 

Ich hab mittlerweile eine Lösung - bisschen unschön aber es funktioniert:

In der „buy-widget-price.html.twig“

{% block page_product_detail_price_block_table_body %}
    
        {% block page_product_detail_price_block_table_body_inner %}
            {% for price in page.product.calculatedPrices %}
                {% block page_product_detail_price_block_table_body_row %}
                    

                        {% block page_product_detail_price_block_table_body_cell_quantity %}
                            
                                
                                
                                
                                {% if loop.last %}
                                    {{ "detail.priceDataInfoFrom"|trans|sw_sanitize }}
                                    {{ price.quantity }}
                                {% else %}
                                    {% if page.product.customFields.product_abbis %}
                                        {{ "detail.priceDataInfoUntil"|trans|sw_sanitize }}
                                        {{ price.quantity }}
                                    {% else %}
                                        {{ "detail.priceDataInfoFrom"|trans|sw_sanitize }}
                                        
                                            {% if oldquantity %}
                                                {{ oldquantity}}
                                            {% else %}
                                                {{ page.product.minPurchase }}
                                            {% endif %}
                                        
                                    {% endif %}
                                {% endif %}
                            
                        {% endblock %}

                        {% block page_product_detail_price_block_table_body_cell_price %}
                            
                                {{ price.unitPrice|currency }}{{ "general.star"|trans|sw_sanitize }}
                            
                        {% endblock %}

                        {% block page_product_detail_price_block_table_body_cell_reference_price %}
                            {% if price.referencePrice is not null %}
                                
                                    {{ price.referencePrice.price|currency }}{{ "general.star"|trans|sw_sanitize }} / {{ price.referencePrice.referenceUnit }} {{ price.referencePrice.unitName }}
                                
                            {% endif %}
                        {% endblock %}
                    
                {% endblock %}
                {% set oldquantity = price.quantity+1 %}
            {% endfor %}
        {% endblock %}
    
{% endblock %}

 

Im Detail:

Am Ende der For-Schleife erstelle ich eine Variable die den Wert in die nächste Schleife übernimmt +1.

{% set oldquantity = price.quantity+1 %}

Diese wird dann abgefragt und als neuer Wert ausgegeben, falls nicht vorhanden (weil 1. Schleife) wird der Mindestabnahme Wert gesetzt.

{{ "detail.priceDataInfoFrom"|trans|sw_sanitize }}

   {% if oldquantity %}
      {{ oldquantity}}
   {% else %}
      {{ page.product.minPurchase }}
   {% endif %}

Ich hab dann aber auch noch ein Zusatzfeld „page.product.customFields.product_abbis“ angelegt, wo man wieder auf die „bis-Preise“ umschalten kann.

{% if page.product.customFields.product_abbis %}
   {{ "detail.priceDataInfoUntil"|trans|sw_sanitize }}
   {{ price.quantity }}
{% else %}
...

 

Bei Fragen stehe ich gerne zur Verfügung.

@systemmarketing ich habe da eine Frage zu.

Ich habe mir dazu via „Custom Template Manager“ Plugin die entsprechende TWIG Datei ("/page/product-detail/buy-widget-price.html.twig") rausgesucht.
Die entsprechende Stelle habe ich auch gefunden.

{% if loop.last %}
{{ „detail.priceDataInfoFrom“|trans|sw_sanitize }}

{{ price.quantity }}
{% else %}
{{ „detail.priceDataInfoUntil“|trans|sw_sanitize }}

{{ price.quantity }}
{% endif %}

Nach meinem Verständnis steuert der obere If-Bereich den letzten Wert bei der Preisstaffelung (z.B. Screenshot Wert ab 22). Der untere Bereich steuert die anderen Staffelmengen. Damit in jeder Zeile, statt „Bis“ jetzt „Ab“ angezeigt wird muss man einfach bei „detail.priceDataInfoUntil“ das Until auf From umbenennen. Dann zieht er sich auch an der Stelle den anderen Textbaustein.

Jetzt zu meinem Problem, wo du vielleicht eine Lösung kennst:
Die Staffellungen sind bei mir nicht immer gleich. Sprich bei einer Produktkategorie ist die Staffelung immer in 20er Schritten und bei einer anderen in 1er Schritten.
Das bedeutet ich kann nicht einfach {{ price.quantity -1 }} anwenden.
Weisst du wie ich eine generische Lösung finde, die immer den passenden „Ab-Wert“ auswählt?

Man könnte in deinem Fall eventuell mehrere Zusatzfelder anlegen, um diese Fälle abzufangen.
Diese kann man dann im Template entsprechend anders darstellen.

Allerdings weiß ich auch aktuell nicht genau, wie die Listen im groben und ganzen bei dir aussehen sollen
Ab 1
Ab 10

oder
Ab 1 - 9
Ab 10 - 19

oder
Ab 1 - 20
Ab 20 - 40
Ab 40 - 60

Hi @systemmarketing, Danke für deine Antwort. Bei mir sind es bis jetzt drei verschiedene Staffellungen.

  1. Staffelung:
    Ab 1
    Ab 2
    Ab 3

  2. Staffelung:
    Ab 1
    Ab 20
    Ab 40
    Ab 80

  3. Staffelung:
    Ab 1
    Ab 25
    Ab 50
    Ab 100

Ich habe auch schon Mal ein Zusatzset angelegt und es „custom_page.product.customfields.product_bulksize“ genannt. Jetzt könnte ich dazu Zusatzfelder anlegen. Da aber gleich die erste Frage…welcher Typ, was soll da genau rein?

Und wie sähe das dann in meinem Code aus, damit es richtig funktioniert?

{% block page_product_detail_price_inner %}
    {% if page.product.calculatedPrices|length > 1 %}
        {% block page_product_detail_price_block %}
            <div class="product-block-prices">
                {% block page_product_detail_price_block_table %}
                    <table class="table product-block-prices-grid">
                        {% block page_product_detail_price_block_table_head %}
                            <thead class="product-block-prices-head">
                                {% block page_product_detail_price_block_table_head_inner %}
                                    <tr class="product-block-prices-row">
                                        <th scope="col" class="product-block-prices-cell">
                                            {{ "detail.dataColumnQuantity"|trans|sw_sanitize }}
                                        </th>
                                        <th scope="col" class="product-block-prices-cell">
                                            {{ "detail.dataColumnPrice"|trans|sw_sanitize }}
                                        </th>
                                        {% if page.product.calculatedPrice.referencePrice %}
                                            <th scope="col" class="product-block-prices-cell">
                                                {{ "detail.dataColumnReferencePrice"|trans|sw_sanitize }}
                                            </th>
                                        {% endif %}
                                    </tr>
                                {% endblock %}
                            </thead>
                        {% endblock %}

                        {% block page_product_detail_price_block_table_body %}
                            <tbody class="product-block-prices-body">
                                {% block page_product_detail_price_block_table_body_inner %}
                                    {% for price in page.product.calculatedPrices %}
                                        {% block page_product_detail_price_block_table_body_row %}
                                            <tr class="product-block-prices-row"
                                                itemprop="offers" itemscope
                                                itemtype="https://schema.org/Offer">

                                                {% block page_product_detail_price_block_table_body_cell_quantity %}
                                                    <th scope="row" class="product-block-prices-cell product-block-prices-cell-thin">
                                                        <meta itemprop="priceCurrency" content="{{ page.header.activeCurrency.translated.shortName }}" />
                                                        <meta itemprop="price" content="{{ price.unitPrice }}" />
                                                        <link itemprop="availability" href="https://schema.org/InStock" />

                                                        {% if loop.last %}
                                                            {{ "detail.priceDataInfoFrom"|trans|sw_sanitize }}
                                                            <span class="product-block-prices-quantity">{{ price.quantity }}</span>

                                                        {% else %}
                                                            {{ "detail.priceDataInfoUntil"|trans|sw_sanitize }}
                                                            <span class="product-block-prices-quantity">{{ price.quantity }}</span>
                                                        {% endif %}
                                                    </th>
                                                {% endblock %}

                                                {% block page_product_detail_price_block_table_body_cell_price %}
                                                    <td class="product-block-prices-cell">
                                                        {% sw_include '@Storefront/storefront/component/product/block-price.html.twig' with {
                                                            price: price
                                                        } only %}
                                                    </td>
                                                {% endblock %}

                                                {% block page_product_detail_price_block_table_body_cell_reference_price %}
                                                    {% if price.referencePrice is not null %}
                                                        <td class="product-block-prices-cell product-block-prices-cell-thin">
                                                            {{ price.referencePrice.price|currency }}{{ "general.star"|trans|sw_sanitize }} / {{ price.referencePrice.referenceUnit }} {{ price.referencePrice.unitName }}
                                                        </td>
                                                    {% endif %}
                                                {% endblock %}
                                            </tr>
                                        {% endblock %}
                                    {% endfor %}
                                {% endblock %}
                            </tbody>
                        {% endblock %}
                    </table>
                {% endblock %}
            </div>
        {% endblock %}
    {% else %}
        {% set price = page.product.calculatedPrice %}

        {% if page.product.calculatedPrices|length == 1 %}
            {% set price = page.product.calculatedPrices.first %}
        {% endif %}

        <meta itemprop="price"
              content="{{ price.unitPrice }}">

        {% block page_product_detail_price_content %}
            {% set listPrice = price.listPrice %}

            <p class="product-detail-price{% if listPrice.percentage > 0 %} with-list-price{% endif %}">
                {{ price.unitPrice|currency }}{{ "general.star"|trans|sw_sanitize }}
            </p>

            {% if listPrice.percentage > 0 %}
                {% block page_product_detail_was_price %}

                    {% block page_product_detail_was_price_badge %}
                        <span class="list-price-badge">&#37;</span>
                    {% endblock %}

                    {% set afterListPriceSnippetExists = "listing.afterListPrice"|trans|length > 0 %}
                    {% set beforeListPriceSnippetExists = "listing.beforeListPrice"|trans|length > 0 %}

                    {% block page_product_detail_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 }}{{ "general.star"|trans|sw_sanitize }}</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 %}
        {% endblock %}

        {% if page.product.purchaseUnit %}
            {% block page_product_detail_price_unit %}
                <div class="product-detail-price-unit">
                    {% block page_product_detail_price_unit_label %}
                        <span class="price-unit-label">
                            {{ "detail.priceUnitName"|trans|sw_sanitize }}
                        </span>
                    {% endblock %}

                    {% block page_product_detail_price_unit_content %}
                        <span class="price-unit-content">
                            {{ page.product.purchaseUnit }} {{ page.product.unit.name }}
                        </span>
                    {% endblock %}

                    {% if price.referencePrice is not null %}
                        {% block page_product_detail_price_unit_reference_content %}
                            <span class="price-unit-reference-content">
                                ({{ price.referencePrice.price|currency }}{{ "general.star"|trans|sw_sanitize }} / {{ price.referencePrice.referenceUnit }} {{ price.referencePrice.unitName }})
                            </span>
                        {% endblock %}
                    {% endif %}
                </div>
            {% endblock %}
        {% endif %}
    {% endif %}
{% endblock %}

Glaub da war ein Denkfehler bei dir.
Hab jetzt mal deine Staffelungen nachgestellt ohne weitere Anpassungen - hier die Beispiele: Freizeit & Elektro
Das Plugin dafür wäre hier: https://github.com/supercat1510/McwPreisstaffel
Einfach im Ordner „/custom/plugins/“ hochladen, installieren und dann einfach Häckchen setzen wenn „Ab“ benötigt wird.

Hey @systemmarketing , ab der Shopware 6.5.5.1 werden die Staffelpreise wieder alle mit „bis“ anstatt mit „ab“ dargestellt. Ich schätze, weil sich was am Template geändert hat. Weißt du zufällig was und wo man das anpassen kann?
Ich hatte bisher dein Plugin genutzt, was du hier verlinkt hattest.

image