CS-Cart: 通知関数fn_set_notificationの使い方


CS-Cartでは、処理の成功・失敗などをUIにフィードバックできる通知(notification)の機構がある。Ruby on Railsなどのフレームワークでよく見かけるflash的なものだ。

この通知は、fn_set_notificationを実行すると使うことができる。

fn_set_notification

通知関数の引数などは次のようになっている。

/**
 * Sets notification message
 *
 * @param string $type notification type (E - error, W - warning, N - notice, O - order error on checkout, I - information)
 * @param string $title notification title
 * @param string $message notification message
 * @param string $message_state (S - notification will be displayed unless it's closed, K - only once, I - will be closed by timer)
 * @param mixed $extra extra data to save with notification
 * @param bool $init_message $title and $message will be processed by __ function if true
 * @return boolean always true
 */
function fn_set_notification($type, $title, $message, $message_state = '', $extra = '', $init_message = false)

サンプル

fn_set_notification('E', __('error'), '失敗しました');
fn_set_notification('W', __('important'), '注意してください');
fn_set_notification('W', __('warning'), '注意してください');
fn_set_notification('N', __('notice'), '成功しました');
fn_set_notification('N', __('congratulations'), 'ついに成功しました');
fn_set_notification('S', __('notice'), 'アップデートがあります');
fn_set_notification('W', __('warning'), '問題が有ります。<a href="#">詳しく</a>');