Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
会員グループ管理::会員グループ価格管理アドオンで未ログイン時の場合、商品詳細ページにグループ会員価格一覧を表示させる
{% if not is_granted('ROLE_USER') %}
{% set Groups = repository('Plugin\\CustomerGroup\\Entity\\Group').findAll() %}
<div class="ec-productRole__groupPrice">
{% for Group in Groups %}
<div class="ec-price">
<span class="">{{ Group.name }}価格:</span>
{% set GroupPrices = [] %}
{% for ProductClass in Product.getProductClasses %}
{% set GroupPrice = repository('Plugin\\CustomerGroupPrice\\Entity\\GroupPrice').findBy({'group': Group, 'ProductClass': ProductClass}) %}
{% if GroupPrice and GroupPrice[0].getPriceIncTax %}
{% set GroupPrices = GroupPrices|merge([GroupPrice[0].getPriceIncTax]) %}
{% else %}
{% set GroupPrices = GroupPrices|merge([ProductClass.getPrice02IncTax]) %}
{% endif %}
{% endfor %}
{% if Product.hasProductClass -%}
{% if min(GroupPrices) == max(GroupPrices) %}
<span class="ec-price__price price02-default">{{ min(GroupPrices)|price }}</span>
<span class="ec-price__tax">{{ 'common.tax_include'|trans }}</span>
{% else %}
<span class="ec-price__price price02-default">{{ min(GroupPrices)|price }} ~ {{ max(GroupPrices)|price }}</span>
<span class="ec-price__tax">{{ 'common.tax_include'|trans }}</span>
{% endif %}
{% else %}
<span class="ec-price__price">{{ min(GroupPrices)|price }}</span>
<span class="ec-price__tax">{{ 'common.tax_include'|trans }}</span>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment