返信先: 自動送信メールの本文の順序入れ替え

フォーラム 使い方全般 自動送信メールの本文の順序入れ替え 返信先: 自動送信メールの本文の順序入れ替え

#73433
not
参加者

yskysmr 様
お返事ありがとうございます。

実は、お恥ずかしながら、タイムリミットが来てしまいまして
完全に希望通りにはいかなかったのですが、打ち切らざるを得ませんでした。

ご注文日時を上に移動することと、商品名・単価・数量をテーブル形式にすることは叶わなかったのですが、未完全な解決法がこちらです。

add_filter(‘usces_filter_send_order_mail_first’, ‘my_filter_send_order_mail_first’, 10, 6);
function my_filter_send_order_mail_first($meisai, $payment, $data, $cart, $entry, $order_id){
global $usces;
$args = func_get_args();
$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;
$meisai .= “\r\n”;
$meisai .= __(‘お支払い方法’,’usces’) . ” : ” . $payment[‘name’] . usces_payment_detail($entry) . “\r\n\r\n”;
$meisai .= __(‘Payment amount’,’usces’) . ” : ” . usces_crform( $entry[‘order’][‘total_full_price’], true, false, ‘return’ ) . “\r\n”;
$meisai .= __(‘Order number’,’usces’) . ” : ” . usces_get_deco_order_id( $order_id ) . “\r\n”;
$meisai .= “\r\n”;
$meisai .= usces_mail_line( 3, $entry[‘customer’][‘mailaddress1’] );//====================
$meisai .= “\r\n”;
$meisai .= __(‘Items’,’usces’) . “\r\n”;
$meisai .= usces_mail_line( 2, $entry[‘customer’][‘mailaddress1’] );//——————–
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’];
if (!empty($options)) {
// $optstr = implode(‘,’, $options);
} else {
$optstr = ”;
$options = array();
}
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 .= “$cartItemName \r\n”;
$meisai .= usces_crform( $skuPrice, true, false, ‘return’ ) . __(‘ * ‘,’usces’) . $cart_row[‘quantity’] . “\r\n”;
$meisai .= usces_mail_line( 2, $entry[‘customer’][‘mailaddress1’] );//——————–
}
$meisai .= __(‘total items’,’usces’) . ” : ” . usces_crform( $entry[‘order’][‘total_items_price’], true, false, ‘return’ ) . “\r\n”;
$meisai .= usces_mail_line( 3, $entry[‘customer’][‘mailaddress1’] );//====================
$meisai .= __(‘Shipping’,’usces’) . ” : ” . 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’)) . ” : ” . usces_crform( $entry[‘order’][‘cod_fee’], true, false, ‘return’ ) . “\r\n”;
if ( !empty($usces->options[‘tax_rate’]) )
$meisai .= __(‘consumption tax’,’usces’) . ” : ” . usces_crform( $entry[‘order’][‘tax’], true, false, ‘return’ ) . “\r\n”;
$meisai .= usces_mail_line( 3, $entry[‘customer’][‘mailaddress1’] );//====================
$meisai .= __(‘Payment amount’,’usces’) . ” : ” . usces_crform( $entry[‘order’][‘total_full_price’], true, false, ‘return’ ) . “\r\n”;
$meisai .= usces_mail_line( 3, $entry[‘customer’][‘mailaddress1’] );//====================
$meisai .= “\r\n\r\n” . __(‘【ご注文者情報】’,’usces’) . “\r\n”;
$meisai .= usces_mail_line( 1, $entry[‘customer’][‘mailaddress1’] );//********************
return $meisai;
}
add_filter(“usces_filter_apply_mail_addressform”, “my_filter_apply_mail_addressform”, 10, 4);
function my_filter_apply_mail_addressform($formtag, $type, $data, $order_id){
if($type === “order_mail_customer”){
$formtag .= “”;
}
return $formtag;
}
add_filter(“usces_filter_send_order_mail_meisai”, “my_filter_send_order_mail_meisai”, 10, 4);
function my_filter_send_order_mail_meisai($meisai, $data, $cart, $entry){
$msg_body .= usces_get_deco_order_id( ‘order_mail_customer’, $entry, $order_id );
$meisai = “”;
$meisai = “\r\n\r\n”;
return $meisai;
}
add_filter(“usces_filter_send_order_mail_shipping”, “my_filter_send_order_mail_shipping”, 10, 3);
function my_filter_send_order_mail_shipping($msg_shipping, $data, $entry){
$msg_body .= uesces_get_mail_addressform( ‘order_mail_customer’, $entry, $order_id );
$msg_shipping .= “”;
return $msg_shipping;
}

他の方のトピックにあった、他の方の回答を使用させていただいております。
ごめんなさい。

冒頭部分用のフックに詰め込む、という、恐らくかなり乱暴な方法にしました。

PHP初心者(それ以下かも)なので、かなり厳しかったです。
精進あるのみ、ですね。

ありがとうございました。
お騒がせいたしました。

  • この返信は9年、 2ヶ月前にnotが編集しました。