Drupal Commerceの住所関係は、日本風にはなっていません。
請求情報、配送情報の入力フォームや表示を日本的(郵便番号、都道府県、市区町村、住所、、、)にすには、どうしたら良いですか?
Drupal Commerceの請求情報、配送情報の住所を日本的(郵便番号、都道府県、市区町村、住所、、、)
OTHER FAQ
カテゴリ | Core Ver. | 関連モジュール | タイトル |
---|---|---|---|
言語 | 6.22 | URLエイリアスを使った場合に、翻訳したページで同じURLエイリアスが使えないという不具合 | |
コンテンツの作成 | 6.x | Insert Block | ブロックの内容を本文中に表示するには? |
言語 | 6.x | i18n | 多言語対応サイトのサイト名やスローガン/ミッションなどを多言語化する方法を教えてください |
コンテンツの作成 | 6.x | Views | カルーセルのように回転するコンテンツを作りたい |
コンテンツの管理 | 6.x | Views Flag Calendar | 空き室予約のような仕組みは実現できますか? |
ダウンロード | 6.x | Views Bonus Pack | Viewsで表示した内容をCSVダウンロード |
コンテンツの管理 | 7,51 | Views Data Export | Views Data ExportでCSVデータが欠けてしまう |
言語 | 7.14 | Entity Translation | 各フィールドのラベルの多言語切り替え漏れ(接頭子、接尾子) |
言語 | 7.15 | Entity Translation | デフォルトの言語 - Entity Translation |
タクソノミー | 7.15 | Taxonomy manager | タクソノミーを効率よく管理したい |
テーマ | 7.15 | CSS Injector | 簡単にCSSを追加したい |
見栄え | 7.15 | js Injector | 簡単にJavascriptを追加する方法は? |
アップデート | 7.15 | Webform Backup_and_Migrate | drupal7.12 -> drupal7.14アップデートメモ |
コンテンツの管理 | 7.15 | Content Access | 簡単に閲覧制限を行うには? |
ユーザの管理 | 7.15 | Devel | 簡単に指定ユーザにログインしなおす方法 |
フォーム | 7.15 | Webform Template | Webformを複写したい |
権限 | 7.15 | Path_Access Content_Access | 特定のページ(パス)をアクセス制限したい |
コンテンツの作成 | 7.15 | Automatic_Nodetitles Automatic_Entity_Label | ノード投稿フォームにタイトル入力フォームを表示しない方法 |
コンテンツの作成 | 7.15 | Mailhandler | メールを通じてnodeの投稿をするには |
言語 | 7.15 | Entity Translation | 各フィールドのラベルの多言語切り替え漏れ(フィールド・ラベル) |
コメント
Drupal Commerceにおいて
パーマリンク Submitted by actbrain on 2015/01/09 14:23.
Drupal Commerceにおいて、住所を制御しているのはAddressfieldフィールドです。
Addressfieldには、入力フォームや表示に手を加えるAPIが用意されています。
サーバー内:/path/to//addressfield/addressfield.api.php
〜
8 /**
9 * Format generation callback.
10 *
11 * @param $format
12 * The address format being generated.
13 * @param $address
14 * The address this format is generated for.
15 * @param $context
16 * An associative array of context information pertaining to how the address
17 * format should be generated. If no mode is given, it will initialize to the
18 * default value. The remaining context keys should only be present when the
19 * address format is being generated for a field:
20 * - mode: either 'form' or 'render'; defaults to 'render'.
21 * - field: the field info array.
22 * - instance: the field instance array.
23 * - langcode: the langcode of the language the field is being rendered in.
24 * - delta: the delta value of the given address.
25 *
26 * @ingroup addressfield_format
27 */
28 function CALLBACK_addressfield_format_callback(&$format, $address, $context = array()) {
29 // No example.
30 }
〜
こちら、説明がないので解りにくいのですが、以下の方法で実現できます。
1./path/to/your-module/your-module.module内でAddressfieldプラグイン登録を行います。
〜
36 /**
37 * Implements hook_ctools_plugin_directory().
38 */
39 function or_commerce_ctools_plugin_directory($module, $plugin) {
40 if ($module == 'addressfield') {
41 return "$plugin/$module"; // この場合、'/your-module/format/addressfield'になります。
42 }
43 }
〜
2.プラグインファイルを用意します(/path/to/your-module/format/addressfield/japanese.inc)
〜
1 <?php
2
3 /**
4 * @file
5 * Generates Japanese format.
6 */
7
8 $plugin = array(
9 'title' => t('Ajustment Japanese format'),
10 'format callback' => 'your-module_format_japanese_ajustment',
11 'type' => 'name',
12 'weight' => 100,
13 );
14
15 /**
16 * Format callback.
17 *
18 * @see CALLBACK_addressfield_format_callback()
19 */
20 function your-module_format_japanese_ajustment(&$format, $address) {
21
22 // 住所:入力フォーム表示順調整
23 $weight = $format['country']['#weight'];
24 $format['locality_block']['#weight'] = ++$weight;
25 $format['street_block']['#weight'] = ++$weight;
26 $format['organisation_block']['#weight'] = ++$weight;
27 $format['name_block']['#weight'] = ++$weight;
28
29 // 住所:入力フォームサイズ調整
30 $width = 30; // とか
31 foreach (array('locality_block', 'street_block', 'organisation_block', 'name_block') as $n) {
32 foreach ($format[$n] as $nam => &$ele) {
33 if (strpos($nam, '#') !== 0) {
34 if (isset($ele['#size'])) {
35 $ele['#size'] = $width;
36 }
37 }
38 }
39 }
40
41 // 住所:並びを「郵便番号・都道府県・市区町村」に調整
42 $locality = $format['locality_block']['locality'];
43 unset($format['locality_block']['locality']);
44 $format['locality_block']['locality'] = $locality;
45
46 // 住所:「郵便番号・都道府県・市区町村」の横配置(locality-block)を解除・・・クラス名変更
47 foreach ($format['locality_block']['#attributes']['class'] as &$class) {
48 if ($class == 'locality-block') {
49 $class .= '-your-module';
50 }
51 elseif ($class == 'addressfield-container-inline') {
52 $class .= '-your-module';
53 }
54 }
55 }
〜
Or
パーマリンク Submitted by actbrain on 2015/10/08 00:41.
Or CommerceモジュールをインストールしてDrupal Commerceの住所情報を日本風にする手順を公開しました。
http://www.act-brain.co.jp/howto/override-commerce-install
Or Commerceモジュールは https://support.cms-pr.com/download-module からダウンロードできます。
ページ