fbpx

Shopify会員フォームの「姓名」「住所」の並び順を日本仕様にカスタマイズする

定期購買アプリのCSを担当しています田口です!

この頃、近所を散歩していると梅の花が咲いていて、
春の訪れにいつもよりちょっと浮かれた毎日を過ごしております。
ただ、気持ちは春に向けて全速力なのに、服装は厚手のコートなんか着ていつまでも凍えているので、なかなかアンバランスでむずがゆいですね。。。

弊社へのお問合せも、4月頭を目安にオンラインストアを始めるストアさまからのお問合せが増えている今日この頃。
今回は、そんなこれからShopifyでストア構築を始められる方向けに、Shopifyカスタマイズのキホンのキである「Shopify会員フォームの「姓名」「住所」の並び順を日本仕様にカスタマイズする」ことについてお話していきます!

 

はじめに:この記事は次のような方におすすめです

  • これからShopifyでストア構築を行う事業者の方
  • Shopify構築を始めたばかりの方
  • Shopifyのカスタマイズを勉強中の方

 

目次

  • Shopifyは海外製のECプラットフォーム
  • カスタマイズbefore・after
  • 会員フォームを日本仕様にカスタマイズする
    1. 「姓名」の並び順を変更する
    2. 「住所」の並び順を変更する
  • まとめ

 

Shopifyは海外製のECプラットフォーム

Shopify(ショピファイ)は、世界各国で最も利用されているECプラットフォームですね。

インフラが強いことから日本の大手企業も続々とShopifyでEC構築を行なっており、近年は日本でもメジャーなプラットフォームの選択肢となりました。

そんなShopifyですが、グローバル向けのシステムになっているため日本の商習慣に合わせてユーザーに購入体験をしてもらうためには、ちょっとした工夫が必要だったりします。

 

今回カスタマイズを行う部分は以下の2点です。

  • 会員登録時のお客様姓名の並び順を変更する
  • 住所登録フォームの「姓名」、「住所」の並び順を変更する

 

カスタマイズBefore・After

カスタマイズのBefore・Afterは以下の通りです。

会員フォームを日本仕様にカスタマイズする

会員登録時のお客様「姓名」の並び順を変更する

1.まずは、現状の設定を確認しましょう。ストアヘッダー部分の人型アイコンをクリックしてください。

※人型アイコンが表示されていない場合は、下記の手順で表示させてください。

Shopify管理画面>設定>お客様アカウント>「オンラインストアのヘッダーとチェックアウト時にログインリンクを表示する」をチェックオン

 

2.「アカウントを作成する」をクリックします。

 

3.この「名」と「姓」の並び順をコードの編集にて変えていきます。

4.Shopify管理画面>オンラインストア>テーマ>「・・・」>コードを編集を開きます。

 

※今回はDawnのバージョン13.0.1を使います。テーマによってこの後出てくるファイル名が異なる場合がありますので、ご注意ください。

 

5.変更箇所のファイル(パーツ)を特定するために、コードを「theme.liquid」に追加します。

レイアウト>theme.liquidを選択して開きます。

 

6.theme.liquidの</body>の内側に下記のスクリプトを追加します。

<!-- theme.liquid最下部 -->
<script>console.log("{{ template }}");</script>
</body>

 

7.アカウント作成画面を開き、デベロッパーツール>Consoleを開きます。「customers/register」と表示されています。

 

8.コード編集画面を開き、「register」を検索します。ファイルが見つかりました。「customers/register.json」の中を確認すると「main-register」というセクションファイルを呼び出していることがわかります。

 

 


<div class="field">
  <input
    type="text"
    name="customer[first_name]"
    id="RegisterForm-FirstName"
    {% if form.first_name %}
      value="{{ form.first_name }}"
    {% endif %}
    autocomplete="given-name"
    placeholder="{{ 'customer.register.first_name' | t }}"
  >
  <label for="RegisterForm-FirstName">
    {{ 'customer.register.first_name' | t }}
  </label>
</div>
<div class="field">
  <input
    type="text"
    name="customer[last_name]"
    id="RegisterForm-LastName"
    {% if form.last_name %}
      value="{{ form.last_name }}"
    {% endif %}
    autocomplete="family-name"
    placeholder="{{ 'customer.register.last_name' | t }}"
  >
  <label for="RegisterForm-LastName">
    {{ 'customer.register.last_name' | t }}
  </label>
</div>

<div></div>タグで一括りになっているので順番を入れ替えて保存をすると下画像のようになります。

 

10.アカウントページをリロードして、変更が反映されていることを確認しましょう。「姓」と「名」の並び順が入れ替わっていますね。

 

住所登録フォームの「姓名」、「住所」の並び順を変更する

1.まずは、現在の表示を確認するためにアカウントページにログインしてください。ログイン後に、「住所を確認」をクリックします。新規で住所を追加できるフォームが表示されました。この「名」と「姓」、住所の並び順が海外仕様になっているのをコードの編集にて変えていきます。

 

2.住所登録フォームでデベロッパーツールを開き、Consoleを確認します。「customers/addresses」と表示されています。住所登録フォームはこちらのファイルを編集していきましょう。

 

3.コード編集画面で「address」と検索すると「customers/addresses.json」が表示されます。中を確認すると、「main-addresser」というセクションファイルを呼び出していることがわかります。

 

4.セクション内にある「main-register.liquid」ファイルを開き、まずは「姓」と「名」の順番を入れ替えましょう。下記コード部分の順番を入れ替えます。

<div class="field">
  <input
    type="text"
    id="AddressFirstNameNew"
    name="address[first_name]"
    value="{{ form.first_name }}"
    autocomplete="given-name"
    placeholder="{{ 'customer.addresses.first_name' | t }}"
  >
  <label for="AddressFirstNameNew">{{ 'customer.addresses.first_name' | t }}</label>
</div>
<div class="field">
  <input
    type="text"
    id="AddressLastNameNew"
    name="address[last_name]"
    value="{{ form.last_name }}"
    autocomplete="family-name"
    placeholder="{{ 'customer.addresses.last_name' | t }}"
  >
  <label for="AddressLastNameNew">{{ 'customer.addresses.last_name' | t }}</label>
</div>

<div></div>タグで一括りになっているので順番を入れ替えて保存をすると下画像のようになります。

 

 

5.住所登録フォームをリロードして、変更が反映されていることを確認しましょう。「姓」と「名」の並び順が入れ替わっていますね。

 

6.次に住所の順番を海外仕様から日本仕様に入れ替えましょう。下記コード部分の順番を入れ替えます。

<div class="field">
  <input
    type="text"
    id="AddressCompanyNew"
    name="address[company]"
    value="{{ form.company }}"
    autocomplete="organization"
    placeholder="{{ 'customer.addresses.company' | t }}"
  >
  <label for="AddressCompanyNew">{{ 'customer.addresses.company' | t }}</label>
</div>
<div class="field">
  <input
    type="text"
    id="AddressAddress1New"
    name="address[address1]"
    value="{{ form.address1 }}"
    autocomplete="address-line1"
    placeholder="{{ 'customer.addresses.address1' | t }}"
  >
  <label for="AddressAddress1New">{{ 'customer.addresses.address1' | t }}</label>
</div>
<div class="field">
  <input
    type="text"
    id="AddressAddress2New"
    name="address[address2]"
    value="{{ form.address2 }}"
    autocomplete="address-line2"
    placeholder="{{ 'customer.addresses.address2' | t }}"
  >
  <label for="AddressAddress2New">{{ 'customer.addresses.address2' | t }}</label>
</div>
<div class="field">
  <input
    type="text"
    id="AddressCityNew"
    name="address[city]"
    value="{{ form.city }}"
    autocomplete="address-level2"
    placeholder="{{ 'customer.addresses.city' | t }}"
  >
  <label for="AddressCityNew">{{ 'customer.addresses.city' | t }}</label>
</div>
<div>
  <label for="AddressCountryNew">{{ 'customer.addresses.country' | t }}</label>
  <div class="select">
    <select
      id="AddressCountryNew"
      name="address[country]"
      data-default="{{ form.country }}"
      autocomplete="country"
    >
      {{ all_country_option_tags }}
    </select>
    <svg aria-hidden="true" focusable="false" viewBox="0 0 10 6">
      <use href="#icon-caret" />
    </svg>
  </div>
</div>
<div id="AddressProvinceContainerNew" style="display: none">
  <label for="AddressProvinceNew">{{ 'customer.addresses.province' | t }}</label>
 <div class="select">
   <select
      id="AddressProvinceNew"
      name="address[province]"
      data-default="{{ form.province }}"
      autocomplete="address-level1"
    >
    </select>
    <svg aria-hidden="true" focusable="false" viewBox="0 0 10 6">
      <use href="#icon-caret" />
    </svg>
  </div>
</div>
<div class="field">
  <input
    type="text"
    id="AddressZipNew"
    name="address[zip]"
    value="{{ form.zip }}"
    autocapitalize="characters"
    autocomplete="postal-code"
    placeholder="{{ 'customer.addresses.zip' | t }}"
  >
  <label for="AddressZipNew">{{ 'customer.addresses.zip' | t }}</label>
</div> 

<div></div>タグで一括りになっているので順番を入れ替えて保存をすると下画像のようになります。

 

※今回は並び順を変更するだけですが、フォームの形式を整えたりすることも可能です。また、都道府県のプルダウンの並び順がデフォルトのままになっているので北海道→沖縄県の順番に変更することも可能です。

 

💡ちょっと得する豆知識

都道府県のプルダウンの順番をデフォルトではなく、北海道から沖縄県の順番い変更するには下記の手順を行なってください。

1.sections/main-addresses.liquidを開きます。
2.{{ all_country_option_tags }}の位置を探します。
(2箇所あります)
3.{{ all_country_option_tags }}部分を下記のコードに変更してください。

{{ all_country_option_tags | replace: '[&quot;Aichi&quot;,&quot;愛知県&quot;],[&quot;Akita&quot;,&quot;秋田県&quot;],[&quot;Aomori&quot;,&quot;青森県&quot;],[&quot;Chiba&quot;,&quot;千葉県&quot;],[&quot;Ehime&quot;,&quot;愛媛県&quot;],[&quot;Fukui&quot;,&quot;福井県&quot;],[&quot;Fukuoka&quot;,&quot;福岡県&quot;],[&quot;Fukushima&quot;,&quot;福島県&quot;],[&quot;Gifu&quot;,&quot;岐阜県&quot;],[&quot;Gunma&quot;,&quot;群馬県&quot;],[&quot;Hiroshima&quot;,&quot;広島県&quot;],[&quot;Hokkaidō&quot;,&quot;北海道&quot;],[&quot;Hyōgo&quot;,&quot;兵庫県&quot;],[&quot;Ibaraki&quot;,&quot;茨城県&quot;],[&quot;Ishikawa&quot;,&quot;石川県&quot;],[&quot;Iwate&quot;,&quot;岩手県&quot;],[&quot;Kagawa&quot;,&quot;香川県&quot;],[&quot;Kagoshima&quot;,&quot;鹿児島県&quot;],[&quot;Kanagawa&quot;,&quot;神奈川県&quot;],[&quot;Kumamoto&quot;,&quot;熊本県&quot;],[&quot;Kyōto&quot;,&quot;京都府&quot;],[&quot;Kōchi&quot;,&quot;高知県&quot;],[&quot;Mie&quot;,&quot;三重県&quot;],[&quot;Miyagi&quot;,&quot;宮城県&quot;],[&quot;Miyazaki&quot;,&quot;宮崎県&quot;],[&quot;Nagano&quot;,&quot;長野県&quot;],[&quot;Nagasaki&quot;,&quot;長崎県&quot;],[&quot;Nara&quot;,&quot;奈良県&quot;],[&quot;Niigata&quot;,&quot;新潟県&quot;],[&quot;Okayama&quot;,&quot;岡山県&quot;],[&quot;Okinawa&quot;,&quot;沖縄県&quot;],[&quot;Saga&quot;,&quot;佐賀県&quot;],[&quot;Saitama&quot;,&quot;埼玉県&quot;],[&quot;Shiga&quot;,&quot;滋賀県&quot;],[&quot;Shimane&quot;,&quot;島根県&quot;],[&quot;Shizuoka&quot;,&quot;静岡県&quot;],[&quot;Tochigi&quot;,&quot;栃木県&quot;],[&quot;Tokushima&quot;,&quot;徳島県&quot;],[&quot;Tottori&quot;,&quot;鳥取県&quot;],[&quot;Toyama&quot;,&quot;富山県&quot;],[&quot;Tōkyō&quot;,&quot;東京都&quot;],[&quot;Wakayama&quot;,&quot;和歌山県&quot;],[&quot;Yamagata&quot;,&quot;山形県&quot;],[&quot;Yamaguchi&quot;,&quot;山口県&quot;],[&quot;Yamanashi&quot;,&quot;山梨県&quot;],[&quot;Ōita&quot;,&quot;大分県&quot;],[&quot;Ōsaka&quot;,&quot;大阪府&quot;]', '[&quot;Hokkaidō&quot;,&quot;北海道&quot;],[&quot;Aomori&quot;,&quot;青森県&quot;],[&quot;Iwate&quot;,&quot;岩手県&quot;],[&quot;Miyagi&quot;,&quot;宮城県&quot;],[&quot;Akita&quot;,&quot;秋田県&quot;],[&quot;Yamagata&quot;,&quot;山形県&quot;],[&quot;Fukushima&quot;,&quot;福島県&quot;],[&quot;Ibaraki&quot;,&quot;茨城県&quot;],[&quot;Tochigi&quot;,&quot;栃木県&quot;],[&quot;Gunma&quot;,&quot;群馬県&quot;],[&quot;Saitama&quot;,&quot;埼玉県&quot;],[&quot;Chiba&quot;,&quot;千葉県&quot;],[&quot;Tōkyō&quot;,&quot;東京都&quot;],[&quot;Kanagawa&quot;,&quot;神奈川県&quot;],[&quot;Niigata&quot;,&quot;新潟県&quot;],[&quot;Toyama&quot;,&quot;富山県&quot;],[&quot;Ishikawa&quot;,&quot;石川県&quot;],[&quot;Fukui&quot;,&quot;福井県&quot;],[&quot;Yamanashi&quot;,&quot;山梨県&quot;],[&quot;Nagano&quot;,&quot;長野県&quot;],[&quot;Gifu&quot;,&quot;岐阜県&quot;],[&quot;Shizuoka&quot;,&quot;静岡県&quot;],[&quot;Aichi&quot;,&quot;愛知県&quot;],[&quot;Mie&quot;,&quot;三重県&quot;],[&quot;Shiga&quot;,&quot;滋賀県&quot;],[&quot;Kyōto&quot;,&quot;京都府&quot;],[&quot;Ōsaka&quot;,&quot;大阪府&quot;],[&quot;Hyōgo&quot;,&quot;兵庫県&quot;],[&quot;Nara&quot;,&quot;奈良県&quot;],[&quot;Wakayama&quot;,&quot;和歌山県&quot;],[&quot;Tottori&quot;,&quot;鳥取県&quot;],[&quot;Shimane&quot;,&quot;島根県&quot;],[&quot;Okayama&quot;,&quot;岡山県&quot;],[&quot;Hiroshima&quot;,&quot;広島県&quot;],[&quot;Yamaguchi&quot;,&quot;山口県&quot;],[&quot;Tokushima&quot;,&quot;徳島県&quot;],[&quot;Kagawa&quot;,&quot;香川県&quot;],[&quot;Ehime&quot;,&quot;愛媛県&quot;],[&quot;Kōchi&quot;,&quot;高知県&quot;],[&quot;Fukuoka&quot;,&quot;福岡県&quot;],[&quot;Saga&quot;,&quot;佐賀県&quot;],[&quot;Nagasaki&quot;,&quot;長崎県&quot;],[&quot;Kumamoto&quot;,&quot;熊本県&quot;],[&quot;Ōita&quot;,&quot;大分県&quot;],[&quot;Miyazaki&quot;,&quot;宮崎県&quot;],[&quot;Kagoshima&quot;,&quot;鹿児島県&quot;],[&quot;Okinawa&quot;,&quot;沖縄県&quot;]'}}

 

4.保存を行い住所登録フォームの都道府県のプルダウンを確認してください。北海道→沖縄県の並び順になっていますね。

 

=========================================

6.住所登録フォームをリロードして、変更が反映されていることを確認しましょう。住所の並び順が入れ替わっていますね。

 

まとめ

今回はShopifyの無料テーマの中で人気があるDawnでのカスタマイズを行いました。

海外仕様のフォームを日本仕様に変えることは、ユーザーの利便性だけでなくストアへの安心感にも繋がる部分になりますので必須でカスタマイズしてしまいましょう!

※テーマによってコードの内容やファイル名が異なります。

※本記事で実装の保証は出来ませんので、実装する際はご自身で調べていただきながら実装後のテストも必ず行うようにしてください。