【参考】
【実施】
商品リスト
「app/template/test/Product/list.twig」の
{% if Product.hasProductClass %} から {% endif %} 値段(Price)が書いてあるあたりを
{% if is_granted(‘ROLE_USER’) %} から {% endif %}で囲む。
会員じゃない人へのメッセージと、会員登録へ誘導するのが親切なので
<dl id="result_list__detail--{{ Product.id }}"> <dt id="result_list__name--{{ Product.id }}" class="item_name">{{ Product.name }}</dt> {% if Product.description_list %} <dd id="result_list__description_list--{{ Product.id }}" class="item_comment">{{ Product.description_list|raw|nl2br }}</dd> {% endif %} {% if is_granted('ROLE_USER') %} {% if Product.hasProductClass %} {% if Product.getPrice02Min == Product.getPrice02Max %} <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price"> {{ Product.getPrice02IncTaxMin|price }} </dd> {% else %} <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price"> {{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }} </dd> {% endif %} {% else %} <dd id="result_list__price02_inc_tax--{{ Product.id }}" class="item_price">{{ Product.getPrice02IncTaxMin|price }}</dd> {% endif %} {% else %} <dd>価格は会員のみ公開しています。<br /> 登録済みの方は<a href="{{ url('mypage_login') }}">ログイン</a>を行ってください。<br /> 登録がまだの方は<a href="{{ url('entry') }}">会員登録</a>を行ってください。</dd> {% endif %} </dl>
などと記載すると親切かと思います。
詳細ページ
「app/template/test/Product/detail.twig」の
価格部分
{% if is_granted('ROLE_USER') %} <!--★通常価格★--> {% if Product.hasProductClass -%} {% if Product.getPrice01Min is not null and Product.getPrice01IncTaxMin == Product.getPrice01IncTaxMax %} <p id="detail_description_box__class_normal_price" class="normal_price"> 通常価格:<span class="price01_default">{{ Product.getPrice01IncTaxMin|price }}</span> <span class="small">税込</span></p> {% elseif Product.getPrice01Min is not null and Product.getPrice01Max is not null %} <p id="detail_description_box__class_normal_range_price" class="normal_price"> 通常価格:<span class="price01_default">{{ Product.getPrice01IncTaxMin|price }} ~ {{ Product.getPrice01IncTaxMax|price }}</span> <span class="small">税込</span></p> {% endif %} {% else -%} {% if Product.getPrice01Max is not null %} <p id="detail_description_box__normal_price" class="normal_price"> 通常価格:<span class="price01_default">{{ Product.getPrice01IncTaxMin|price }}</span> <span class="small">税込</span></p> {% endif %} {% endif -%} <!--★販売価格★--> {% if Product.hasProductClass -%} {% if Product.getPrice02IncTaxMin == Product.getPrice02IncTaxMax %} <p id="detail_description_box__class_sale_price" class="sale_price text-primary"> <span class="price02_default">{{ Product.getPrice02IncTaxMin|price }}</span> <span class="small">税込</span></p> {% else %} <p id="detail_description_box__class_range_sale_price" class="sale_price text-primary"> <span class="price02_default">{{ Product.getPrice02IncTaxMin|price }} ~ {{ Product.getPrice02IncTaxMax|price }}</span> <span class="small">税込</span></p> {% endif %} {% else -%} <p id="detail_description_box__sale_price" class="sale_price text-primary"> <span class="price02_default">{{ Product.getPrice02IncTaxMin|price }}</span> <span class="small">税込</span></p> {% endif -%} {% else %} <dd>価格は会員のみ公開しています。<br /> 登録済みの方は<a href="{{ url('mypage_login') }}">ログイン</a>を行ってください。<br /> 登録がまだの方は<a href="{{ url('entry') }}">会員登録</a>を行ってください。</dd> {% endif %}
カート部分
{% if is_granted('ROLE_USER') %} <form action="?" method="post" id="form1" name="form1"> <!--▼買い物かご--> <div id="detail_cart_box" class="cart_area"> {% if Product.stock_find %} {# 規格 #} {% if form.classcategory_id1 is defined %} <ul id="detail_cart_box__cart_class_category_id" class="classcategory_list"> {# 規格1 #} <li> {{ form_widget(form.classcategory_id1) }} {{ form_errors(form.classcategory_id1) }} </li> {# 規格2 #} {% if form.classcategory_id2 is defined %} <li> {{ form_widget(form.classcategory_id2) }} {{ form_errors(form.classcategory_id2) }} </li> {% endif %} </ul> {% endif %} {# 数量 #} <dl id="detail_cart_box__cart_quantity" class="quantity"> <dt>数量</dt> <dd> {{ form_widget(form.quantity) }} {{ form_errors(form.quantity) }} </dd> </dl> <div class="extra-form"> {% for f in form.getIterator %} {% if f.vars.name matches '[^plg*]' %} {{ form_row(f) }} {% endif %} {% endfor %} </div> {# カートボタン #} <div id="detail_cart_box__button_area" class="btn_area"> <ul id="detail_cart_box__insert_button" class="row"> <li class="col-xs-12 col-sm-8"><button type="submit" id="add-cart" class="btn btn-primary btn-block prevention-btn prevention-mask">カートに入れる</button></li> </ul> {#Favorite product button#} {% if BaseInfo.option_favorite_product == 1 %} <ul id="detail_cart_box__favorite_button" class="row"> {% if is_favorite == false %} <li class="col-xs-12 col-sm-8"><button type="submit" id="favorite" class="btn btn-info btn-block prevention-btn prevention-mask">お気に入りに追加</button></li> {% else %} <li class="col-xs-12 col-sm-8"><button type="submit" id="favorite" class="btn btn-info btn-block" disabled="disabled">お気に入りに追加済みです</button></li> {% endif %} </ul> {% endif %} </div> {#End div#detail_cart_box__button_area #} {% else %} {# 在庫がない場合は品切れボタンを表示 #} <div id="detail_cart_box__button_area" class="btn_area"> <ul class="row"> <li class="col-xs-12 col-sm-8"><button type="button" class="btn btn-default btn-block" disabled="disabled">ただいま品切れ中です</button></li> </ul> {#Favorite product button#} {% if BaseInfo.option_favorite_product == 1 %} <ul id="detail_cart_box__favorite_button" class="row"> {% if is_favorite == false %} <li class="col-xs-12 col-sm-8"><button type="submit" id="favorite" class="btn btn-info btn-block prevention-btn prevention-mask">お気に入りに追加</button></li> {% else %} <li class="col-xs-12 col-sm-8"><button type="submit" id="favorite" class="btn btn-info btn-block" disabled="disabled">お気に入りに追加済みです</button></li> {% endif %} </ul> {% endif %} </div> {#End div#detail_cart_box__button_area #} {% endif %} {#End stock find#} </div> <!--▲買い物かご--> {{ form_rest(form) }} </form> {% else %} <dd>商品は会員のみ購入が可能です。<br /> 登録済みの方は<a href="{{ url('mypage_login') }}">ログイン</a>を行ってください。<br /> 登録がまだの方は<a href="{{ url('entry') }}">会員登録</a>を行ってください。</dd> {% endif %}
コメントを残す