35歳で会社を辞めて独立したまめのブログ

現役Webデザイナーがお答えします

【MTS Simple Booking-C】管理画面の予約詳細と予約の編集に追加項目を表示させる方法

※当サイトはWeb広告を利用しています


WordPressに予約システムを簡単に導入できるプラグイン「MTS Simple Booking-C」のカスタマイズについてです。

予約時に取得できる項目(例えば、コース名や名前、住所など)は、カスタマイズにより増やすことができます。

参考:WordPressプラグイン「MTS Simple Booking C」をカスタマイズして、コース選択が可能な予約システムを作成する|西沢直木のIT講座

しかし、上記方法だけでは、管理画面の「予約詳細」と「予約の編集」にデータを表示できません。

このページでは、それを表示させる方法を紹介します。

スポンサードリンク

予約詳細に表示させる

プラグインフォルダ内(wp-content/plugins/mts-simple-booking-c/)のmtssb-calendar-admin.phpを開いて編集します。

編集箇所は、482行目のテーブルに新しく追加した項目を追加するだけです。

<table class="form-table booking-detail">
<tr>
<th><?php _e('Article Name', $this->domain) ?></th>
<td><?php echo $article['name'] ?></td>
</tr>
<tr>
<th><?php _e('Date Time', $this->domain) ?></th>
<td><?php echo $datestr . date(' H:i', $this->booking['booking_time']) ?></td>
</tr>
<tr>
<th><?php _e('Number', $this->domain) ?></th>
<td><?php echo $this->booking['number'] ?></td>
</tr>
<tr>
<th><?php _e('Name') ?></th>
<td><?php echo empty($this->booking['client']['name']) ? __('No Name', $this->domain) : esc_html($this->booking['client']['name']) ?></td>
</tr>
<tr>
<th><?php _e('Furigana', $this->domain) ?></th>
<td><?php echo esc_html($this->booking['client']['furigana']) ?></td>
</tr>
<tr>
<th><?php _e('E-Mail', $this->domain) ?></th>
<td><?php echo esc_html($this->booking['client']['email']) ?></td>
</tr>
<tr>
<th><?php _e('Postcode', $this->domain) ?></th>
<td><?php echo esc_html($this->booking['client']['postcode']) ?></td>
</tr>
<tr>
<th><?php _e('Address', $this->domain) ?></th>
<td><?php echo esc_html($this->booking['client']['address1']) . '<br />' . esc_html($this->booking['client']['address2']) ?></td>
</tr>
<tr>
<th><?php _e('TEL', $this->domain) ?></th>
<td><?php echo esc_html($this->booking['client']['tel']) ?></td>
</tr>
<tr>
<th><?php _e('Number', $this->domain) ?></th>
<td><?php foreach ($count as $key => $val) {
echo '<div class="number-person">' . __(ucwords($key), $this->domain) . '<br />'
. $this->booking['client'][$key] . '</div>';
} ?></td>
</td>
</tr>
<tr>
<th><?php _e('Message', $this->domain) ?></th>
<td><?php echo nl2br(esc_html($this->booking['note'])) ?></td>
</tr>
<tr>
<th><?php _e('Created', $this->domain) ?></th>
<td><?php echo $booking['created'] ?></td>
</tr>
</table>

編集方法

どこでもいいので、<tr>〜</tr>をコピー、挿入したい位置にペーストしてパラメーターを変更します。

<tr>
<th><?php _e('Name') ?></th>
<td><?php echo empty($this->booking['client']['name']) ? __('No Name', $this->domain) : esc_html($this->booking['client']['name']) ?></td>
</tr>

例えば、上記なら「Name」「name」となっているところを新しく追加した項目のパラメーターに変更してください。

予約の編集

プラグインフォルダ内(wp-content/plugins/mts-simple-booking-c/)のmtssb-booking-admin.phpを開いて編集します。

編集箇所は、280行目のテーブルに新しく追加した項目を追加するだけです。

<table class="form-table" style="width: 100%">
<tr>
<th>
<label for="booking-company"><?php _e('Company', $this->domain) ?></label>
</th>
<td>
<input id="booking-company" class="mts-fat" type="text" name="booking[client][company]" value="<?php echo esc_attr($client['company']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-name"><?php _e('Name') ?></label>
</th>
<td>
<input id="booking-name" class="mts-fat" type="text" name="booking[client][name]" value="<?php echo esc_attr($client['name']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-furigana"><?php _e('Furigana', $this->domain) ?></label>
</th>
<td>
<input id="booking-furigana" class="mts-fat" type="text" name="booking[client][furigana]" value="<?php echo esc_attr($client['furigana']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-email">E-Mail</label>
</th>
<td>
<input id="booking-email" type="text" name="booking[client][email]" value="<?php echo esc_attr($client['email']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-postcode"><?php _e('Postcode', $this->domain) ?></label>
</th>
<td>
<input id="booking-postcode" class="mts-small" type="text" name="booking[client][postcode]" value="<?php echo esc_attr($client['postcode']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-address1"><?php _e('Address', $this->domain) ?></label>
</th>
<td>
<input id="booking-address1" type="text" name="booking[client][address1]" value="<?php echo esc_attr($client['address1']) ?>" /><br />
<input id="booking-address2" type="text" name="booking[client][address2]" value="<?php echo esc_attr($client['address2']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-tel"><?php _e('Phone number', $this->domain) ?></label>
</th>
<td>
<input id="booking-tel" class="mts-middle" type="text" name="booking[client][tel]" value="<?php echo esc_attr($client['tel']) ?>" />
</td>
</tr>
<tr>
<th>
<label for="booking-adult"><?php _e('Numbers', $this->domain) ?></label>
</th>
<td>
0<input id="booking-adult" class="small-text" type="text" name="booking[client][adult]" value="<?php echo esc_attr($client['adult']) ?>" />人 
子供<input class="small-text" type="text" name="booking[client][child]" value="<?php echo esc_attr($client['child']) ?>" />人 
幼児<input class="small-text" type="text" name="booking[client][baby]" value="<?php echo esc_attr($client['baby']) ?>" />人 
車<input class="small-text" type="text" name="booking[client][car]" value="<?php echo esc_attr($client['car']) ?>" />台
</td>
</tr>
</table>

編集方法

どこでもいいので、<tr>〜</tr>をコピー、挿入したい位置にペーストしてパラメーターを変更します。

<tr>
<th>
<label for="booking-name"><?php _e('Name') ?></label>
</th>
<td>
<input id="booking-name" class="mts-fat" type="text" name="booking[client][name]" value="<?php echo esc_attr($client['name']) ?>" />
</td>
</tr>

例えば、上記なら「Name」「name」となっているところを新しく追加した項目のパラメーターに変更してください。

スポンサードリンク

まとめ

これで、管理画面でも取得したデータを参照できるようになります。

ちなみに、mts-simple-booking-cプラグインフォルダ内の○○○-admin.phpというようにadmin.phpになっているのが管理画面系のファイルです。管理画面に変更を加えたい人は、それらのファイルを探ってみましょう。