Help us understand the problem. What is going on with this article?

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

概要

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

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

対象画面

https://site4.ec-cube.net/shopping/login

対応前 → 対応後

対応前

スクリーンショット 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 %}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした