返信先: 自動送信メールの本文変更

2015 年 1 月 26 日

ホーム フォーラム 使い方全般 自動送信メールの本文変更 返信先: 自動送信メールの本文変更

#73337

JunichiK
参加者

いつもお世話になります。
希望するサンキューメール本文は下記の通りです。
ここから——————–
【ご注文内容】
******************************************************
注文番号 : 00001234
注文日時 : 2015-01-26 00:24:41
商品 :
——————————————————————
(商品名) (商品コード)
単価 ¥10,000 × 1
=============================================
商品合計 : ¥10,000
代引手数料 : ¥0
——————————————————————
お支払い金額 : ¥10,000
——————————————————————
(通貨 : 円)

【お支払方法】
******************************************************
代金引換

【その他】
******************************************************
——————–ここまで

上記の件につきまして、plugins/usc-e-shop/functionsのfunction.phpを下記のようにコメントアウトしますと、希望通りのサンキューメールになります(コメントアウト部分は///でマークしております)。

function usces_send_ordermail($order_id) {
	global $usces, $wpdb;
	
	$tableName = $wpdb->prefix . "usces_order";
	$query = $wpdb->prepare("SELECT * FROM $tableName WHERE ID = %d", $order_id);
	$data = $wpdb->get_row( $query, ARRAY_A );

	$cart = $usces->cart->get_cart();
	$entry = $usces->cart->get_entry();
	$mail_data = $usces->options['mail_data'];
	$payment = $usces->getPayments( $entry['order']['payment_name'] );
	$res = false;

	$msg_body = "\r\n\r\n\r\n" . __('** content of ordered items **','usces') . "\r\n";
	$msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
	$msg_body .= apply_filters('usces_filter_send_order_mail_first', NULL, $data);
///	$msg_body .= uesces_get_mail_addressform( 'order_mail_customer', $entry, $order_id );
	$msg_body .= __('Order number','usces') . "\t: " . usces_get_deco_order_id( $order_id ) . "\r\n";
	$msg_body .= __( 'order date','usces' ) . "\t: " . $data['order_date'] . "\r\n";
	
	$meisai = __('Items','usces') . "\t\t: \r\n";
	foreach ( $cart as $cart_row ) {
		$post_id = $cart_row['post_id'];
		$sku = urldecode($cart_row['sku']);
		$quantity = $cart_row['quantity'];
		$options = $cart_row['options'];
		$itemCode = $usces->getItemCode($post_id);
		$itemName = $usces->getItemName($post_id);
		$cartItemName = $usces->getCartItemName($post_id, $sku);
		$skuPrice = $cart_row['price'];
//		$pictids = $usces->get_pictids($itemCode);
		if (!empty($options)) {
//			$optstr = implode(',', $options);
		} else { 
			$optstr =  '';
			$options =  array();
		}
		
		$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
		$meisai .= "$cartItemName \r\n";
		if( is_array($options) && count($options) > 0 ){
			$optstr = '';
			foreach($options as $key => $value){
				if( !empty($key) ) {
					$key = urldecode($key);
					if(is_array($value)) {
						$c = '';
						$optstr .= $key. ' : ';
						foreach($value as $v) {
							$optstr .= $c.urldecode($v);
							$c = ', ';
						}
						$optstr .= "\r\n"; 
					} else {
						$optstr .= $key . ' : ' . urldecode($value) . "\r\n"; 
					}
				}
			}
			$meisai .= apply_filters( 'usces_filter_option_ordermail', $optstr, $options);
		}
		$meisai .= __('Unit price','usces') . " ".usces_crform( $skuPrice, true, false, 'return' ) . __(' * ','usces') . $cart_row['quantity'] . "\r\n";
	}
	$meisai .= usces_mail_line( 3, $entry['customer']['mailaddress1'] );//====================
	$meisai .= __('total items','usces') . "\t: " . usces_crform( $entry['order']['total_items_price'], true, false, 'return' ) . "\r\n";

	if ( $entry['order']['discount'] != 0 )
		$meisai .= apply_filters('usces_confirm_discount_label', __('Campaign disnount', 'usces'), $order_id) . " : " . usces_crform( $entry['order']['discount'], true, false, 'return' ) . "\r\n";

	if ( 0.00 < (float)$entry['order']['tax'] && 'products' == usces_get_tax_target() )
		$meisai .= usces_tax_label($data, 'return') . "\t: " . usces_crform( $entry['order']['tax'], true, false, 'return' ) . "\r\n";

///	$meisai .= "\r\n" . __('Shipping','usces') . "\t\t: " . usces_crform( $entry['order']['shipping_charge'], true, false, 'return' ) . "\r\n";

	if ( $payment['settlement'] == 'COD' )
		$meisai .= apply_filters('usces_filter_cod_label', __('COD fee', 'usces')) . "\t: " . usces_crform( $entry['order']['cod_fee'], true, false, 'return' ) . "\r\n";

	if ( 0.00 < (float)$entry['order']['tax'] && 'all' == usces_get_tax_target() )
		$meisai .= usces_tax_label($data, 'return') . "\t: " . usces_crform( $entry['order']['tax'], true, false, 'return' ) . "\r\n";

	if ( $entry['order']['usedpoint'] != 0 )
		$meisai .= __('use of points','usces') . " : " . number_format($entry['order']['usedpoint']) . __('Points','usces') . "\r\n";

	$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
	$meisai .= __('Payment amount','usces') . " : " . usces_crform( $entry['order']['total_full_price'], true, false, 'return' ) . "\r\n";
	$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] );//--------------------
	$meisai .= "(" . __('Currency', 'usces') . ' : ' . __(usces_crcode( 'return' ), 'usces') . ")\r\n\r\n";

	$msg_body .= apply_filters('usces_filter_send_order_mail_meisai', $meisai, $data, $cart, $entry);

///	$msg_shipping = __('** A shipping address **','usces') . "\r\n";
///	$msg_shipping .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
	
///	$msg_shipping .= uesces_get_mail_addressform( 'order_mail', $entry, $order_id );

///	$deli_meth = (int)$entry['order']['delivery_method'];
///	if( 0 <= $deli_meth ){
///		$deli_index = $usces->get_delivery_method_index($deli_meth);
///		if( 0 <= $deli_index ) $msg_shipping .= __('Delivery Method','usces') . "\t: " . $usces->options['delivery_method'][$deli_index]['name'] . "\r\n";
///	}
///	$msg_shipping .= __('Delivery date','usces') . " : " . $entry['order']['delivery_date'] . "\r\n";
///	$msg_shipping .= __('Delivery Time','usces') . " : " . $entry['order']['delivery_time'] . "\r\n";
///	$msg_shipping .= "\r\n";
///	$msg_body .= apply_filters('usces_filter_send_order_mail_shipping', $msg_shipping, $data, $entry );

	$msg_payment = __('** Payment method **','usces') . "\r\n";
	$msg_payment .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
	$msg_payment .= $payment['name'] . usces_payment_detail($entry) . "\r\n\r\n";
	if ( $payment['settlement'] == 'transferAdvance' || $payment['settlement'] == 'transferDeferred' ) {
		$transferee = __('Transfer','usces') . " : \r\n";
		$transferee .= $usces->options['transferee'] . "\r\n";
		$msg_payment .= apply_filters('usces_filter_mail_transferee', $transferee, $payment);
		$msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
	} elseif($payment['settlement'] == 'acting_jpayment_conv') {
		$args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
		$msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
		$msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
		$msg_payment .= __('お支払先', 'usces').' : '.usces_get_conv_name($args['cv'])."\r\n";
		$msg_payment .= __('コンビニ受付番号','usces').' : '.$args['no']."\r\n";
		if($args['cv'] != '030') {//ファミリーマート以外
			$msg_payment .= __('コンビニ受付番号情報URL', 'usces').' : '.$args['cu']."\r\n";
		}
		$msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
	} elseif($payment['settlement'] == 'acting_jpayment_bank') {
		$args = maybe_unserialize($usces->get_order_meta_value($payment['settlement'], $order_id));
		$msg_payment .= __('決済番号', 'usces').' : '.$args['gid']."\r\n";
		$msg_payment .= __('決済金額', 'usces').' : '.number_format($args['ta']).__('dollars','usces')."\r\n";
		$bank = explode('.', $args['bank']);
		$msg_payment .= __('銀行コード','usces').' : '.$bank[0]."\r\n";
		$msg_payment .= __('銀行名','usces').' : '.$bank[1]."\r\n";
		$msg_payment .= __('支店コード','usces').' : '.$bank[2]."\r\n";
		$msg_payment .= __('支店名','usces').' : '.$bank[3]."\r\n";
		$msg_payment .= __('口座種別','usces').' : '.$bank[4]."\r\n";
		$msg_payment .= __('口座番号','usces').' : '.$bank[5]."\r\n";
		$msg_payment .= __('口座名義','usces').' : '.$bank[6]."\r\n";
		$msg_payment .= __('支払期限','usces').' : '.substr($args['exp'], 0, 4).'年'.substr($args['exp'], 4, 2).'月'.substr($args['exp'], 6, 2)."日\r\n";
		$msg_payment .= "\r\n".usces_mail_line( 2, $entry['customer']['mailaddress1'] )."\r\n";//--------------------
	}
	
	$msg_body .= apply_filters('usces_filter_send_order_mail_payment', $msg_payment, $order_id, $payment, $cart, $entry, $data);

	$msg_body .= usces_mail_custom_field_info( 'order', '', $order_id );

	$msg_body .= "\r\n";
	$msg_body .= __('** Others / a demand **','usces') . "\r\n";
	$msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] );//********************
	$msg_body .= $entry['order']['note'] . "\r\n\r\n";

しかし、これを、テーマの functions.php にて ‘usces_filter_send_order_mail_bodyall’ フックを使って行うと、注文番号と注文日時が取得出来なくて困っております。
関数の引数に$dataを入れたり、
$msg_body .= __('Order number','usces') . "\t: " . usces_get_deco_order_id( $order_id ) . "\r\n";
の $order_id を $data に変更してみたりしましたが、思うようにいきませんでした。
何かヒントだけでも良いので、ご教示願います。
よろしくお願いいたします。