バージョン選択

フォーラム

メニュー

オンライン状況

52 人のユーザが現在オンラインです。 (38 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 52
もっと...

サイト内検索

質問 > フロント機能 > 特定の商品を入れた際に、買い物かご画面での送料無料アナウンスを非表示にしたい

フロント機能

新規スレッドを追加する

スレッド表示 | 古いものから 前のトピック | 次のトピック | 下へ
投稿者 スレッド
toku712
投稿日時: 2020/3/26 14:30
対応状況: 解決済
新米
登録日: 2019/11/1
居住地:
投稿: 4
Re: 特定の商品を入れた際に、買い物かご画面での送料無料アナウンスを非表示にしたい
ご教示頂きありがとうございます!
教えて頂いた方法で解決しました!

下記の様にtwig修正して反映できました。

app/template/[テーマ名]/Cart/index.twig 118行目辺りから

<div class="ec-cartRole__cart">
    <div class="ec-cartTable">
        <ol class="ec-cartHeader">
            <li class="ec-cartHeader__label">{{ '削除'|trans }}</li>
            <li class="ec-cartHeader__label">{{ '商品内容'|trans }}</li>
            <li class="ec-cartHeader__label">{{ '数量'|trans }}</li>
            <li class="ec-cartHeader__label">{{ '小計'|trans }}</li>
        </ol>
        {% set flg = 0 %}
        {% for CartItem in Cart.CartItems %}
            {% set ProductClass = CartItem.ProductClass %}
            {% set Product = ProductClass.Product %}
            <ul class="ec-cartRow">
                <li class="ec-cartRow__delColumn">
                    <a href="{{ url('cart_handle_item', {'operation': 'remove', 'productClassId': ProductClass.id }) }}" {{ csrf_token_for_anchor() }} class="ec-icon" data-method="put" data-message="カートから商品を削除してもよろしいですか?">
                        <img src="{{ asset('assets/icon/cross.svg') }}" alt="delete">
                    </a>
                </li>
                <li class="ec-cartRow__contentColumn">
                    <div class="ec-cartRow__img">
                        <a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">
                            <img src="{{ asset(Product.MainListImage|no_image_product, 'save_image') }}" alt="{{ Product.name }}"/>
                        </a>
                    </div>
                    <div class="ec-cartRow__summary">
                        <div class="ec-cartRow__name">
                            <a target="_blank" href="{{ url('product_detail', {id : Product.id} ) }}">{{ Product.name }}</a>
                            {% if ProductClass.ClassCategory1 and ProductClass.ClassCategory1.id %}
                                <br>{{ ProductClass.ClassCategory1.ClassName.name }}:{{ ProductClass.ClassCategory1 }}
                            {% endif %}
                            {% if ProductClass.ClassCategory2 and ProductClass.ClassCategory2.id %}
                                <br>{{ ProductClass.ClassCategory2.ClassName.name }}:{{ ProductClass.ClassCategory2 }}
                            {% endif %}
                        </div>
                        <div class="ec-cartRow__unitPrice">{{ CartItem.price|price }}</div>
                        <div class="ec-cartRow__sutbtotalSP">{{ '小計:'|trans }}{{ CartItem.total_price|price }}</div>
                    </div>
                </li>
                <li class="ec-cartRow__amountColumn">
                    <div class="ec-cartRow__amount">{{ CartItem.quantity|number_format }}</div>
                    <div class="ec-cartRow__amountSP">{{ '数量:'|trans }}{{ CartItem.quantity|number_format }}</div>
                    <div class="ec-cartRow__amountUpDown">
                        {% if CartItem.quantity > 1 %}
                            <a href="{{ url('cart_handle_item', {'operation': 'down', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="ec-cartRow__amountDownButton load-overlay" data-method="put" data-confirm="false">
                                <span class="ec-cartRow__amountDownButton__icon"><img src="{{ asset('assets/icon/minus-dark.svg') }}" alt="reduce"></span>
                            </a>
                        {% else %}
                            <div class="ec-cartRow__amountDownButtonDisabled">
                                <span class="ec-cartRow__amountDownButton__icon"><img src="{{ asset('assets/icon/minus.svg') }}" alt="reduce"></span>
                            </div>
                        {% endif %}
                        <a href="{{ url('cart_handle_item', {'operation': 'up', 'productClassId': ProductClass.id}) }}" {{ csrf_token_for_anchor() }} class="ec-cartRow__amountUpButton load-overlay" data-method="put" data-confirm="false">
                            <span class="ec-cartRow__amountUpButton__icon"><img src="{{ asset('assets/icon/plus-dark.svg') }}" alt="increase"></span>
                        </a>
                    </div>
                </li>
                <li class="ec-cartRow__subtotalColumn">
                    <div class="ec-cartRow__sutbtotal">{{ CartItem.total_price|price }}</div>
                </li>
            </ul>
            {% if CartItem.ProductClass.SaleType.id==2 %}
            {% set flg = 1 %}
            {% endif %}
        {% endfor %}
    </div>
</div>

{% if flg != 1 %}
<div class="ec-cartRole__progress">
    {% if BaseInfo.delivery_free_amount and BaseInfo.delivery_free_quantity %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%price%</strong>」または「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price, '%quantity%': quantity[cartKey]|number_format })|raw }}
        {% endif %}
    {% elseif BaseInfo.delivery_free_amount %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%price%</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price })|raw }}
        {% endif %}
    {% elseif BaseInfo.delivery_free_quantity %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%quantity%': quantity[cartKey]|number_format })|raw }}
        {% endif %}
    {% endif %}
</div>
{% endif %}


非表示確認後、決済入力画面→購入完了画面まで進んでもエラー出なかったので、解決できました。

ありがとうございました!

引き続きよろしくお願い致します。
468
投稿日時: 2020/3/26 10:40
対応状況: −−−
登録日: 2008/10/26
居住地:
投稿: 3217
Re: 特定の商品を入れた際に、買い物かご画面での送料無料アナウンスを非表示にしたい
デフォルトではカートの中に販売種別Bが入っているかどうかを判定する処理が存在しない為、
カートの中に販売種別Bが入っているかどうかの判定を実装する必要があると思います。
ロジック的には、カート内の商品を1つずつループして販売種別をチェックする必要があると思います。

実装の方法はいくつかあるかと思いますが
twigのみで完結させたい場合は
送料アナウンスの前に以下のようにカート内商品をループしている箇所がありますので
{% for CartItem in Cart.CartItems %}

{% endfor %}
このループの外で判定用変数を用意して
{% set flg = 0 %}

ループ内に
{% if CartItem.ProductClass.SaleType.id==2 %}
{% set flg = 1 %}
{% endif %}
の判定を入れておき、
最後に送料アナウンスを
{% if flg != 1 %}

{% endif %}
で囲めば判定できるのではないかと思います。


----------------
株式会社シロハチ
■ECCUBE2系、3系構築カスタマイズご相談ください。
EC-CUBE3マニュアル
blog

toku712
投稿日時: 2020/3/25 19:32
対応状況: 解決済
新米
登録日: 2019/11/1
居住地:
投稿: 4
特定の商品を入れた際に、買い物かご画面での送料無料アナウンスを非表示にしたい
いつもお世話になっております。

▼希望
今回は特定の商品をカートに入れた際に、
買い物かご画面の商品最後に表示される送料無料アナウンスを非表示にしたいと考えております。

▼使用環境
[EC-CUBE] 4.0.3(4.0.2からプラグインによるアップデート済)
[レンタルサーバ] さくらのレンタルサーバ スタンダード
[サーバーOS] FreeBSD 11.2
[PHP] 7.3.15
[データベース] MySQL 5.7
[WEBサーバ] Apache
[ブラウザ] Google Chrome
[導入プラグインの有無] 有
[カスタマイズの有無] 有

▼現在の問題
通常の場合は表示させておいて、
特定の商品が入った場合のみ非表示にしたい為、
販売種別にて実装しようして下記の様に条件分岐を追加しました。

イメージ:販売種別B(ID=2)がカートに入っていた場合のみ非表示、それ以外は通常通り表示

app/template/[テーマ名]/Cart/index.twig 180行目付近

{% if CartItem.ProductClass.SaleType.id==2 %}
{% else %}
<div class="ec-cartRole__progress">
    {% if BaseInfo.delivery_free_amount and BaseInfo.delivery_free_quantity %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%price%</strong>」または「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price, '%quantity%': quantity[cartKey]|number_format })|raw }}
        {% endif %}
    {% elseif BaseInfo.delivery_free_amount %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%price%</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%price%': least[cartKey]|price })|raw }}
        {% endif %}
    {% elseif BaseInfo.delivery_free_quantity %}
        <br/>
        {% if is_delivery_free[cartKey] %}
            {{ '現在送料無料です。'|trans }}
        {% else %}
            {{ 'あと「<strong>%quantity%個</strong>」のお買い上げで<strong class="ec-color-red">送料無料</strong>になります。'|trans({ '%quantity%': quantity[cartKey]|number_format })|raw }}
        {% endif %}
    {% endif %}
</div>
{% endif %}


上記内容で試したところ、販売種別Bの商品を入れても非表示になりませんでした。
カート部分の外の項目の為だと思いますが、どうすればよいか分かりかねました。

不勉強にて恐縮ですが、ご教示頂けますと幸いです。
どうぞよろしくお願い致します。
スレッド表示 | 古いものから 前のトピック | 次のトピック | トップ


 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,287名です
総投稿数は109,688件です

投稿数ランキング

1
seasoft
7365
2
468
3217
3
AMUAMU
2712
4
nanasess
2303
5
umebius
2085
6
yuh
1818
7
h_tanaka
1610
8
red
1567
9
mcontact
1240
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
796
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.