3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[EC-CUBE4]商品購入時、会員登録必須にする

Last updated at Posted at 2019-12-06

概要

EC-CUBEには標準で非会員登録があるのですが、
ショップとしては、1回きりの購入で終わらず、継続的に顧客と接点を持つために、
会員登録を必須にしたい場合があるかと思います。

そこで、今回は会員登録を必須にする方法を記載します。

対象画面

対応前 → 対応後

対応前

スクリーンショット 2019-12-06 11.19.30.png

対応後

スクリーンショット 2019-12-06 11.19.39.png

修正

修正箇所、内容

  • 管理画面 > コンテンツ管理 > ページ管理 > MYページ/ログインを選択
    ページ名:MYページ/ログイン
    変更対象画面のURL:https://site4.ec-cube.net/mypage/login

  • (ソースコード変更)72行目あたりの「 {% if is_granted('IS_AUTHENTICATED_REMEMBERED') == false %}」以下をコメントアウト

上記対応で、修正後の画面になります。
あとは、右寄せになっているデザインを、微調整し完了となります。
(「class="ec-Grid3"」「ec-Grid3__cell」あたりを、2→3に変更するなど)

修正前後のソースコード

修正前

{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}

{% set body_class = 'cart_page' %}

{% block main %}

    <div class="ec-role">
        <div class="ec-pageHeader">
            <h1>{{ 'common.login'|trans }}</h1>
        </div>
    </div>

    <div class="ec-role">
        <div class="ec-grid3">

            <div class="ec-grid3__cell2">
                <form name="shopping_login" id="shopping_login" method="post" action="{{ url('mypage_login') }}">
                    <input type="hidden" name="_target_path" value="shopping" />
                    <input type="hidden" name="_failure_path" value="shopping_login" />
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
                    <div class="ec-login">
                        <div class="ec-login__icon">
                            <div class="ec-icon"><img src="{{ asset('assets/icon/user.svg') }}" alt=""></div>
                        </div>
                        <div class="ec-login__input">
                            <div class="ec-input">
                                {{ form_widget(form.login_email, { attr: { 'style' : 'ime-mode: disabled;', placeholder: 'common.mail_address'|trans, 'autofocus': true }}) }}
                                {{ form_widget(form.login_pass, { attr: { placeholder: 'common.password'|trans }}) }}
                            </div>
                            {% if BaseInfo.option_remember_me %}
                            <div class="ec-checkbox">
                                <label>
                                    {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
                                        <input type="hidden" name="login_memory" value="1">
                                    {% else %}
                                        {{ form_widget(form.login_memory, { 'label': 'common.remember_me'|trans }) }}
                                    {% endif %}
                                </label>
                            </div>
                            {% endif %}
                        </div>
                        {% if error %}
                            <p class="ec-errorMessage">{{ error.messageKey|trans(error.messageData, 'validators')|nl2br }}</p>
                        {% endif %}
                        <div class="ec-grid2">
                            <div class="ec-grid2__cell">
                                <div class="ec-login__actions">
                                    <button type="submit" class="ec-blockBtn--cancel">{{ 'common.login'|trans}}</button>
                                </div>
                            </div>
                            <div class="ec-grid2__cell">
                                <div class="ec-login__link"><a class="ec-link" href="{{ url('forgot') }}">{{ 'common.forgot_login'|trans}}</a>
                                </div>
                                <div class="ec-login__link"><a class="ec-link" href="{{ url('entry') }}">{{ 'common.signup'|trans}}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            {% if is_granted('IS_AUTHENTICATED_REMEMBERED') == false %}
                <div class="ec-grid3__cell">
                    <div class="ec-guest">
                        <div class="ec-guest__inner">
                            <p>{{ 'front.shopping.guest_purchase_message'|trans }}</p>
                            <div class="ec-guest__actions"><a class="ec-blockBtn--cancel" href="{{ url('shopping_nonmember') }}">{{ 'front.shopping.guest_purchase'|trans }}</a>
                            </div>
                        </div>
                    </div>
                </div>
            {% endif %}
        </div>
    </div>
{% endblock %}

修正後

{#
This file is part of EC-CUBE

Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.

http://www.ec-cube.co.jp/

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.
#}
{% extends 'default_frame.twig' %}

{% set body_class = 'cart_page' %}

{% block main %}

    <div class="ec-role">
        <div class="ec-pageHeader">
            <h1>{{ 'common.login'|trans }}</h1>
        </div>
    </div>

    <div class="ec-role">
        <div class="ec-grid3">

            <div class="ec-grid3__cell2">
                <form name="shopping_login" id="shopping_login" method="post" action="{{ url('mypage_login') }}">
                    <input type="hidden" name="_target_path" value="shopping" />
                    <input type="hidden" name="_failure_path" value="shopping_login" />
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}">
                    <div class="ec-login">
                        <div class="ec-login__icon">
                            <div class="ec-icon"><img src="{{ asset('assets/icon/user.svg') }}" alt=""></div>
                        </div>
                        <div class="ec-login__input">
                            <div class="ec-input">
                                {{ form_widget(form.login_email, { attr: { 'style' : 'ime-mode: disabled;', placeholder: 'common.mail_address'|trans, 'autofocus': true }}) }}
                                {{ form_widget(form.login_pass, { attr: { placeholder: 'common.password'|trans }}) }}
                            </div>
                            {% if BaseInfo.option_remember_me %}
                            <div class="ec-checkbox">
                                <label>
                                    {% if is_granted('IS_AUTHENTICATED_REMEMBERED') %}
                                        <input type="hidden" name="login_memory" value="1">
                                    {% else %}
                                        {{ form_widget(form.login_memory, { 'label': 'common.remember_me'|trans }) }}
                                    {% endif %}
                                </label>
                            </div>
                            {% endif %}
                        </div>
                        {% if error %}
                            <p class="ec-errorMessage">{{ error.messageKey|trans(error.messageData, 'validators')|nl2br }}</p>
                        {% endif %}
                        <div class="ec-grid2">
                            <div class="ec-grid2__cell">
                                <div class="ec-login__actions">
                                    <button type="submit" class="ec-blockBtn--cancel">{{ 'common.login'|trans}}</button>
                                </div>
                            </div>
                            <div class="ec-grid2__cell">
                                <div class="ec-login__link"><a class="ec-link" href="{{ url('forgot') }}">{{ 'common.forgot_login'|trans}}</a>
                                </div>
                                <div class="ec-login__link"><a class="ec-link" href="{{ url('entry') }}">{{ 'common.signup'|trans}}</a>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
{# ←ここから、コメントアウト
            {% if is_granted('IS_AUTHENTICATED_REMEMBERED') == false %}
                <div class="ec-grid3__cell">
                    <div class="ec-guest">
                        <div class="ec-guest__inner">
                            <p>{{ 'front.shopping.guest_purchase_message'|trans }}</p>
                            <div class="ec-guest__actions"><a class="ec-blockBtn--cancel" href="{{ url('shopping_nonmember') }}">{{ 'front.shopping.guest_purchase'|trans }}</a>
                            </div>
                        </div>
                    </div>
                </div>
            {% endif %}
#} ←ここまで、コメントアウト
        </div>
    </div>
{% endblock %}
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?