Welcartの納品書に会員IDが出力されるようにする
こんにちは、福田です。
ジメジメした日が続いてますね~早く梅雨明けて欲しいです。
先日、wordpressのショッピングカート用プラグインwelcartをご利用中のクライアントからのご要望。
「納品書の注文者様の名前のところに会員IDが印刷されるようにして欲しい」
早速いろいろと調べてみるとどうやら
納品書PDFの内容を記述しているファイルはplugins/usc-e-shop/includes/order_print.php
という事が分かり、編集していく事に。
が!その前に!!
そのまま編集してしまうと、プラグインの更新がかかった時に編集したファイルが、更新ファイルで上書きされてしまうので、まずはこのファイルをアップデートに影響しないディレクトリに移動させるところから始めます。
①order_print.phpを別の場所にコピー
plugins/usc-e-shop/includes/order_print.php をコピーしアップデートに影響しないテンプレートディレクトリにペースト。
②コピーしたorder_print.phpを編集
●984行目あたりに会員IDを取得する関数を追記
1 2 3 4 5 6 |
function usces_get_memberID( $data ){ if($data->customer['mem_id'] != 0){ $name = " (".$data->customer['mem_id'].")"; return $name; } } |
●477行目あたりに会員IDを出力するように追記(おそらく他にも記述が必要な箇所あるがひとまず)
1 |
$pdf->MultiCell($width, $lineheight, usces_conv_euc(usces_get_pdf_name( $data )).usces_conv_euc(usces_get_memberID( $data )), $border, 'L'); |
③コピーしたorder_print.phpを読み込むようにfunctions.phpに追記
1 2 3 4 5 |
function my_usces_filter_orderpdf_path() { $path = get_template_directory().'/inc/order_print.php'; return $path; } add_filter('usces_filter_orderpdf_path','my_usces_filter_orderpdf_path' ); |
これでひとまず会員IDが出力されるようになりました。