Skip to content

Reference price is not shown for products with calculatedPrices #15858

Description

@nfech01

After the recent changes to the buy-widget structure, the reference price is no longer displayed correctly.

The current implementation wraps the reference price output in an if condition that only evaluates to true when the calculatedPrices array is empty. As a result, the reference price is not shown whenever calculatedPrices contains entries.

This becomes a critical issue when using the JTL connector, as it typically populates the calculatedPrices array. Consequently, reference prices are never displayed in these cases.

Expected behavior:
The reference price should be displayed independently of whether calculatedPrices contains values.

Actual behavior:
The reference price is only displayed when calculatedPrices is empty.

{% if product.calculatedPrices|length == 0 %}
  {% set price = product.calculatedPrice %}

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

Possible solution might be the one used in buy-widget-price.html.twig

{% set price = product.calculatedPrice %}

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

Affected code:

Metadata

Metadata

Assignees

No one assigned

    Labels

    component/storefrontdomain/frameworkResponsible for the framework-level code includes core, administration, storefront, and frontendspriority/highItems that we should do soon.

    Type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions