| 1 |
<?php |
| 2 |
/** |
| 3 |
* Transaction of Emails |
| 4 |
* |
| 5 |
* Process all emails involved in the transaction using email templates. |
| 6 |
* |
| 7 |
* @package Welcart |
| 8 |
* @version 2.3.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
/** |
| 16 |
* Management Mail |
| 17 |
* Generate the full text of the email sent from the management screen |
| 18 |
* |
| 19 |
* @param int $order_id Order ID. |
| 20 |
* @return text : mail ful text |
| 21 |
*/ |
| 22 |
function usces_order_confirm_message( $order_id ) { |
| 23 |
global $usces; |
| 24 |
|
| 25 |
$data = $usces->get_order_data( $order_id, 'direct' ); |
| 26 |
if ( empty( $data ) ) { |
| 27 |
return ''; |
| 28 |
} |
| 29 |
|
| 30 |
$deli = wel_safe_unserialize( $data['order_delivery'] ); |
| 31 |
$cart = usces_get_ordercartdata( $order_id ); |
| 32 |
|
| 33 |
$country = $usces->get_order_meta_value( 'customer_country', $order_id ); |
| 34 |
$customer = array( |
| 35 |
'name1' => $data['order_name1'], |
| 36 |
'name2' => $data['order_name2'], |
| 37 |
'name3' => $data['order_name3'], |
| 38 |
'name4' => $data['order_name4'], |
| 39 |
'zipcode' => $data['order_zip'], |
| 40 |
'country' => $country, |
| 41 |
'pref' => $data['order_pref'], |
| 42 |
'address1' => $data['order_address1'], |
| 43 |
'address2' => $data['order_address2'], |
| 44 |
'address3' => $data['order_address3'], |
| 45 |
'tel' => $data['order_tel'], |
| 46 |
'fax' => $data['order_fax'], |
| 47 |
); |
| 48 |
|
| 49 |
$condition = wel_safe_unserialize( $data['order_condition'] ); |
| 50 |
$tax_display = ( isset( $condition['tax_display'] ) ) ? $condition['tax_display'] : usces_get_tax_display(); |
| 51 |
$reduced_taxrate = ( isset( $condition['applicable_taxrate'] ) && 'reduced' === $condition['applicable_taxrate'] ) ? true : false; |
| 52 |
$usces_tax = null; |
| 53 |
if ( 'activate' === $tax_display && $reduced_taxrate ) { |
| 54 |
$usces_tax = Welcart_Tax::get_instance(); |
| 55 |
} |
| 56 |
$member_system = ( isset( $condition['membersystem_state'] ) ) ? $condition['membersystem_state'] : $usces->options['membersystem_state']; |
| 57 |
$member_system_point = ( isset( $condition['membersystem_point'] ) ) ? $condition['membersystem_point'] : $usces->options['membersystem_point']; |
| 58 |
$tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : usces_get_tax_mode(); |
| 59 |
$tax_target = ( isset( $condition['tax_target'] ) ) ? $condition['tax_target'] : usces_get_tax_target(); |
| 60 |
$point_coverage = ( isset( $condition['point_coverage'] ) ) ? $condition['point_coverage'] : usces_point_coverage(); |
| 61 |
|
| 62 |
$total_full_price = $data['order_item_total_price'] - $data['order_usedpoint'] + $data['order_discount'] + $data['order_shipping_charge'] + $data['order_cod_fee'] + $data['order_tax']; |
| 63 |
if ( $total_full_price < 0 ) { |
| 64 |
$total_full_price = 0; |
| 65 |
} |
| 66 |
|
| 67 |
$mail_data = usces_mail_data(); |
| 68 |
$payment = $usces->getPayments( $data['order_payment_name'] ); |
| 69 |
|
| 70 |
switch ( $_POST['mode'] ) { |
| 71 |
case 'completionMail': |
| 72 |
$mail_mode = 'completionmail'; |
| 73 |
break; |
| 74 |
case 'orderConfirmMail': |
| 75 |
$mail_mode = 'ordermail'; |
| 76 |
break; |
| 77 |
case 'changeConfirmMail': |
| 78 |
$mail_mode = 'changemail'; |
| 79 |
break; |
| 80 |
case 'receiptConfirmMail': |
| 81 |
$mail_mode = 'receiptmail'; |
| 82 |
break; |
| 83 |
case 'mitumoriConfirmMail': |
| 84 |
$mail_mode = 'mitumorimail'; |
| 85 |
break; |
| 86 |
case 'cancelConfirmMail': |
| 87 |
$mail_mode = 'cancelmail'; |
| 88 |
break; |
| 89 |
case 'otherConfirmMail': |
| 90 |
$mail_mode = 'othermail'; |
| 91 |
break; |
| 92 |
default: |
| 93 |
$mail_mode = ''; |
| 94 |
} |
| 95 |
|
| 96 |
$hook_args = compact( 'order_id', 'data', 'deli', 'cart', 'country', 'customer', 'condition', 'total_full_price', 'mail_data', 'payment', 'tax_display', 'reduced_taxrate', 'tax_mode', 'tax_target', 'usces_tax', 'point_coverage', 'member_system', 'member_system_point' ); |
| 97 |
|
| 98 |
if ( usces_is_html_mail() ) { |
| 99 |
|
| 100 |
$msg_body = usces_get_adminmail_htmlbody( $hook_args ); |
| 101 |
$msg_body = apply_filters( 'usces_filter_order_confirm_mail_bodyall', $msg_body, $data ); |
| 102 |
|
| 103 |
$message = '<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tbody><tr><td>'; |
| 104 |
$message .= '<table style="font-size:15px; margin:30px auto;" border="0" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody>'; |
| 105 |
|
| 106 |
if ( '' === $mail_mode ) { |
| 107 |
// add body. |
| 108 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 109 |
$message .= apply_filters( 'usces_filter_order_confirm_mail_body_after', $msg_body, $data ); |
| 110 |
$message .= '</td></tr>'; |
| 111 |
} else { |
| 112 |
// add header. |
| 113 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 114 |
$m_header = $mail_data['header'][ $mail_mode ]; |
| 115 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 116 |
// translators: %s: name of user. |
| 117 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $data['order_name1'] ), trim( $data['order_name2'] ), 'return' ) ); |
| 118 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 119 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 120 |
} else { |
| 121 |
$message .= $dear_name . '<br>'; |
| 122 |
} |
| 123 |
} |
| 124 |
$message .= do_shortcode( wpautop( $m_header ) ); |
| 125 |
$message .= '</td></tr>'; |
| 126 |
// add body. |
| 127 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 128 |
$message .= apply_filters( 'usces_filter_order_confirm_mail_body_after', $msg_body, $data ); |
| 129 |
$message .= '</td></tr>'; |
| 130 |
// add footer. |
| 131 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 132 |
$message .= do_shortcode( wpautop( $mail_data['footer'][ $mail_mode ] ) ); |
| 133 |
$message .= '</td></tr>'; |
| 134 |
$message .= '</tbody></table></td></tr></tbody></table>'; |
| 135 |
} |
| 136 |
} else { |
| 137 |
$msg_body = usces_get_adminmail_textbody( $hook_args ); |
| 138 |
$msg_body = apply_filters( 'usces_filter_order_confirm_mail_bodyall', $msg_body, $data ); |
| 139 |
|
| 140 |
$message = ''; |
| 141 |
$m_header = $mail_data['header'][ $mail_mode ]; |
| 142 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 143 |
// translators: %s: name of user. |
| 144 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $data['order_name1'] ), trim( $data['order_name2'] ), 'return' ) ); |
| 145 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 146 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 147 |
} else { |
| 148 |
$message = $dear_name . "\r\n\r\n"; |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
if ( '' === $mail_mode ) { |
| 153 |
$message .= apply_filters( 'usces_filter_order_confirm_mail_body_after', $msg_body, $data ); |
| 154 |
} else { |
| 155 |
$message .= do_shortcode( $m_header ) . apply_filters( 'usces_filter_order_confirm_mail_body_after', $msg_body, $data ) . do_shortcode( $mail_data['footer'][ $mail_mode ] ); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
return apply_filters( 'usces_filter_order_confirm_mail_message', $message, $data ); |
| 160 |
} |
| 161 |
|
| 162 |
/** |
| 163 |
* Thanks Mail |
| 164 |
* Generate the full text of the email sent from the front checkout. |
| 165 |
* |
| 166 |
* @param int $order_id Order ID. |
| 167 |
* @return text : mail ful text |
| 168 |
*/ |
| 169 |
function usces_send_ordermail( $order_id ) { |
| 170 |
global $usces; |
| 171 |
|
| 172 |
$data = $usces->get_order_data( $order_id, 'direct' ); |
| 173 |
|
| 174 |
$newcart = usces_get_ordercartdata( $order_id ); |
| 175 |
$cart = $usces->cart->get_cart(); |
| 176 |
|
| 177 |
$entry = $usces->cart->get_entry(); |
| 178 |
$mail_data = usces_mail_data(); |
| 179 |
$payment = $usces->getPayments( $entry['order']['payment_name'] ); |
| 180 |
|
| 181 |
$hook_args = compact( 'order_id', 'cart', 'newcart', 'entry', 'payment', 'data' ); |
| 182 |
$headers = ''; |
| 183 |
|
| 184 |
if ( usces_is_html_mail() ) { |
| 185 |
$headers = "Content-Type: text/html\r\n"; |
| 186 |
|
| 187 |
$msg_body = usces_get_thanksmail_htmlbody( $hook_args ); |
| 188 |
$message = '<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tbody><tr><td>'; |
| 189 |
$message .= '<table style="font-size:15px; margin:30px auto;" border="0" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody>'; |
| 190 |
|
| 191 |
// add header. |
| 192 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 193 |
$m_header = apply_filters( 'usces_filter_send_order_mail_header_thankyou', $mail_data['header']['thankyou'], $data ); |
| 194 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 195 |
// translators: %s: name of user. |
| 196 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $data['order_name1'] ), trim( $data['order_name2'] ), 'return' ) ); |
| 197 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 198 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 199 |
} else { |
| 200 |
$message .= $dear_name . '<br>'; |
| 201 |
} |
| 202 |
} |
| 203 |
$message .= do_shortcode( wpautop( $m_header ) ); |
| 204 |
$message .= '</td></tr>'; |
| 205 |
// add body. |
| 206 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 207 |
$msg_body = apply_filters( 'usces_filter_send_order_mail_bodyall', $msg_body, $data ); |
| 208 |
$message .= $msg_body . '</td></tr>'; |
| 209 |
// add footer. |
| 210 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 211 |
$m_footer = apply_filters( 'usces_filter_send_order_mail_footer_thankyou', $mail_data['footer']['thankyou'], $data ); |
| 212 |
$message .= do_shortcode( wpautop( $m_footer ) ); |
| 213 |
$message .= '</td></tr>'; |
| 214 |
$message .= '</tbody></table> |
| 215 |
</td></tr></tbody></table>'; |
| 216 |
} else { |
| 217 |
$msg_body = usces_get_thanksmail_textbody( $hook_args ); |
| 218 |
$message = ''; |
| 219 |
$m_header = apply_filters( 'usces_filter_send_order_mail_header_thankyou', $mail_data['header']['thankyou'], $data ); |
| 220 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 221 |
// translators: %s: name of user. |
| 222 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $data['order_name1'] ), trim( $data['order_name2'] ), 'return' ) ); |
| 223 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 224 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 225 |
} else { |
| 226 |
$message .= $dear_name . "\r\n\r\n"; |
| 227 |
} |
| 228 |
} |
| 229 |
$m_footer = apply_filters( 'usces_filter_send_order_mail_footer_thankyou', $mail_data['footer']['thankyou'], $data ); |
| 230 |
$msg_body = apply_filters( 'usces_filter_send_order_mail_bodyall', $msg_body, $data ); |
| 231 |
$message .= do_shortcode( $m_header ) . $msg_body . do_shortcode( $m_footer ); |
| 232 |
} |
| 233 |
|
| 234 |
// translators: %s: name of user. |
| 235 |
$name = sprintf( _x( '%s', 'honorific', 'usces' ), usces_localized_name( trim( $entry['customer']['name1'] ), trim( $entry['customer']['name2'] ), 'return' ) ); |
| 236 |
$subject = apply_filters( 'usces_filter_send_order_mail_subject_thankyou', $mail_data['title']['thankyou'], $data ); |
| 237 |
|
| 238 |
$confirm_para = array( |
| 239 |
'to_name' => $name, |
| 240 |
'to_address' => $entry['customer']['mailaddress1'], |
| 241 |
'from_name' => get_option( 'blogname' ), |
| 242 |
'from_address' => $usces->options['sender_mail'], |
| 243 |
'reply_name' => get_option( 'blogname' ), |
| 244 |
'reply_to' => usces_get_first_order_mail(), |
| 245 |
'return_path' => $usces->options['error_mail'], |
| 246 |
'subject' => $subject, |
| 247 |
'message' => $message, |
| 248 |
'headers' => $headers, |
| 249 |
); |
| 250 |
$confirm_para = apply_filters( 'usces_send_ordermail_para_to_customer', $confirm_para, $entry, $data ); |
| 251 |
|
| 252 |
$res1 = usces_send_mail( $confirm_para ); |
| 253 |
|
| 254 |
do_action( 'usces_action_after_send_ordermail_to_customer', $res1, $confirm_para, $entry, $data ); |
| 255 |
|
| 256 |
$subject = apply_filters( 'usces_filter_send_order_mail_subject_order', ( $mail_data['title']['order'] . ' [' . $order_id . '] ' . $name ), $data ); |
| 257 |
if ( usces_is_html_mail() ) { |
| 258 |
|
| 259 |
$message = '<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tbody><tr><td>'; |
| 260 |
$message .= '<table style="font-size:15px; margin:30px auto;" border="0" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody>'; |
| 261 |
|
| 262 |
// add header. |
| 263 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 264 |
$message .= do_shortcode( wpautop( $mail_data['header']['order'] ) ); |
| 265 |
$message .= '</td></tr>'; |
| 266 |
// add body. |
| 267 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 268 |
$message .= $msg_body; |
| 269 |
$message .= '</td></tr>'; |
| 270 |
// add footer. |
| 271 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 272 |
$message .= do_shortcode( wpautop( $mail_data['footer']['order'] ) ); |
| 273 |
$message .= '<p>'; |
| 274 |
$message .= '----------------------------------------------------<br>'; |
| 275 |
$message .= 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] . '<br>'; |
| 276 |
$message .= '----------------------------------------------------<br>'; |
| 277 |
$message .= '</p>'; |
| 278 |
$message .= '</td></tr>'; |
| 279 |
$message .= '</tbody></table></td></tr></tbody></table>'; |
| 280 |
} else { |
| 281 |
$message = do_shortcode( $mail_data['header']['order'] ) . $msg_body |
| 282 |
. $mail_data['footer']['order'] |
| 283 |
. "\r\n----------------------------------------------------\r\n" |
| 284 |
. 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] |
| 285 |
. "\r\n----------------------------------------------------\r\n"; |
| 286 |
} |
| 287 |
|
| 288 |
$order_para = array( |
| 289 |
'to_name' => __( 'An order email', 'usces' ), |
| 290 |
'to_address' => $usces->options['order_mail'], |
| 291 |
'from_name' => get_option( 'blogname' ), |
| 292 |
'from_address' => $usces->options['sender_mail'], |
| 293 |
'reply_name' => get_option( 'blogname' ), |
| 294 |
'reply_to' => usces_get_first_order_mail(), |
| 295 |
'return_path' => $usces->options['error_mail'], |
| 296 |
'subject' => $subject, |
| 297 |
'message' => $message, |
| 298 |
'headers' => $headers, |
| 299 |
); |
| 300 |
|
| 301 |
$order_para = apply_filters( 'usces_send_ordermail_para_to_manager', $order_para, $entry, $data ); |
| 302 |
|
| 303 |
$res2 = usces_send_mail( $order_para ); |
| 304 |
|
| 305 |
do_action( 'usces_action_after_send_ordermail_to_manager', $res2, $order_para, $entry, $data ); |
| 306 |
|
| 307 |
return $res2; |
| 308 |
} |
| 309 |
|
| 310 |
/** |
| 311 |
* Generate html for the body of the thanks mail |
| 312 |
* |
| 313 |
* @param array $args { |
| 314 |
* The array of mail data. |
| 315 |
* @type int $order_id Order ID. |
| 316 |
* @type array $cart Cart data. |
| 317 |
* @type array $newcart New cart data. |
| 318 |
* @type array $entry Entry data. |
| 319 |
* @type array $payment Payment data. |
| 320 |
* @type array $data Order data. |
| 321 |
* } |
| 322 |
* @return text : mail body |
| 323 |
*/ |
| 324 |
function usces_get_thanksmail_htmlbody( $args ) { |
| 325 |
global $usces; |
| 326 |
extract( $args ); |
| 327 |
|
| 328 |
$reduced_taxrate = usces_is_reduced_taxrate(); |
| 329 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 330 |
$usces_tax = Welcart_Tax::get_instance(); |
| 331 |
} |
| 332 |
|
| 333 |
$msg_body = ''; |
| 334 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_body_top', '', $args ); |
| 335 |
|
| 336 |
$msg_body .= '<hr style="margin: 0 0 50px; border-style: none; border-top: 3px solid #777;" />'; |
| 337 |
|
| 338 |
// Title and order number. |
| 339 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 340 |
$msg_body .= '<caption style="background-color: #111; margin-bottom: 40px; padding: 15px; color: #fff; font-size: 15px; font-weight: 700; text-align: left;">' . __( '** Article order contents **', 'usces' ) . '</caption>'; |
| 341 |
$msg_body .= '<tbody>'; |
| 342 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_first', '', $data ); |
| 343 |
$msg_body .= '<tr>'; |
| 344 |
$msg_body .= '<td style="background-color: #f9f9f9; padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'order date', 'usces' ) . '</td>'; |
| 345 |
$msg_body .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . $data['order_date'] . '</td>'; |
| 346 |
$msg_body .= '</tr>'; |
| 347 |
$msg_body .= '<tr>'; |
| 348 |
$msg_body .= '<td style="background-color: #f9f9f9; padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'Order number', 'usces' ) . '</td>'; |
| 349 |
$msg_body .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . usces_get_deco_order_id( $order_id ) . '</td>'; |
| 350 |
$msg_body .= '</tr>'; |
| 351 |
$msg_body .= '</tbody>'; |
| 352 |
$msg_body .= '</table>'; |
| 353 |
|
| 354 |
// Purchase details. |
| 355 |
$meisai = '<table style="font-size: 14px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 356 |
$meisai .= '<thead>'; |
| 357 |
$meisai .= '<tr>'; |
| 358 |
$meisai .= '<td style="text-align: center; width: 50%; padding: 12px; border: 1px solid #ddd;">' . __( 'Items', 'usces' ) . '</td>'; |
| 359 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd;">' . __( 'Unit price', 'usces' ) . '</td>'; |
| 360 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd;">' . __( 'Quantity', 'usces' ) . '</td>'; |
| 361 |
$meisai .= '</tr>'; |
| 362 |
$meisai .= '</thead>'; |
| 363 |
$meisai .= '<tbody>'; |
| 364 |
|
| 365 |
foreach ( $cart as $cart_key => $cart_row ) { |
| 366 |
$cart_row['cart_id'] = $newcart[ $cart_key ]['cart_id']; |
| 367 |
$post_id = $cart_row['post_id']; |
| 368 |
$sku = urldecode( $cart_row['sku'] ); |
| 369 |
$quantity = $cart_row['quantity']; |
| 370 |
$options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array(); |
| 371 |
$cart_item_name = esc_html( $usces->getCartItemName( $post_id, $sku ) ); |
| 372 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 373 |
$applicable_taxrate = $usces_tax->get_sku_applicable_taxrate( $post_id, $sku ); |
| 374 |
if ( 'reduced' === $applicable_taxrate ) { |
| 375 |
$cart_item_name .= $usces_tax->reduced_taxrate_mark; |
| 376 |
} |
| 377 |
} |
| 378 |
$sku_price = $cart_row['price']; |
| 379 |
$args = compact( 'cart', 'cart_row', 'post_id', 'sku' ); |
| 380 |
$meisai .= '<tr>'; |
| 381 |
$meisai .= '<td style="width: 50%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">'; |
| 382 |
$meisai .= apply_filters( 'usces_filter_cart_item_name_nl', $cart_item_name, $args ) . '<br>'; |
| 383 |
if ( is_array( $options ) && count( $options ) > 0 ) { |
| 384 |
$optstr = ''; |
| 385 |
foreach ( $options as $key => $value ) { |
| 386 |
if ( ! empty( $key ) ) { |
| 387 |
$key = urldecode( $key ); |
| 388 |
if ( is_array( $value ) ) { |
| 389 |
$c = ''; |
| 390 |
$optstr .= esc_html( $key ) . ' : '; |
| 391 |
foreach ( $value as $v ) { |
| 392 |
$optstr .= $c . esc_html( urldecode( $v ) ); |
| 393 |
$c = ', '; |
| 394 |
} |
| 395 |
$optstr .= '<br>'; |
| 396 |
} else { |
| 397 |
$optstr .= esc_html( $key ) . ' : ' . esc_html( urldecode( $value ) ) . '<br>'; |
| 398 |
} |
| 399 |
} |
| 400 |
} |
| 401 |
$meisai .= apply_filters( 'usces_filter_option_ordermail', $optstr, $options, $newcart[ $cart_key ] ); |
| 402 |
} |
| 403 |
$meisai .= apply_filters( 'usces_filter_advance_ordermail', '', $newcart[ $cart_key ], $data ); |
| 404 |
$meisai .= '</td>'; |
| 405 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $sku_price, true, false, 'return' ) . '</td>'; |
| 406 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . $cart_row['quantity'] . '</td>'; |
| 407 |
$meisai .= '</tr>'; |
| 408 |
} |
| 409 |
|
| 410 |
$meisai .= '</tbody><tfoot>'; |
| 411 |
$meisai .= '<tr>'; |
| 412 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'total items', 'usces' ) . '</td>'; |
| 413 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $entry['order']['total_items_price'], true, false, 'return' ) . '</td>'; |
| 414 |
$meisai .= '</tr>'; |
| 415 |
|
| 416 |
if ( 0.0 !== (float) $entry['order']['discount'] ) { |
| 417 |
$meisai .= '<tr>'; |
| 418 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ), $order_id ) . '</td>'; |
| 419 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $entry['order']['discount'], true, false, 'return' ) . '</td>'; |
| 420 |
$meisai .= '</tr>'; |
| 421 |
} |
| 422 |
|
| 423 |
if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) { |
| 424 |
$meisai .= '<tr>'; |
| 425 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax_label( $data ) . '</td>'; |
| 426 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax( $entry ) . '</td>'; |
| 427 |
$meisai .= '</tr>'; |
| 428 |
} |
| 429 |
|
| 430 |
if ( usces_is_member_system() && usces_is_member_system_point() && 0 === (int) usces_point_coverage() && 0 !== (int) $entry['order']['usedpoint'] ) { |
| 431 |
$meisai .= '<tr>'; |
| 432 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'use of points', 'usces' ) . '</td>'; |
| 433 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . number_format( $entry['order']['usedpoint'] ) . __( 'Points', 'usces' ) . '</td>'; |
| 434 |
$meisai .= '</tr>'; |
| 435 |
} |
| 436 |
|
| 437 |
if ( usces_have_shipped( $cart ) ) { |
| 438 |
$meisai .= '<tr>'; |
| 439 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'Shipping', 'usces' ) . '</td>'; |
| 440 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $entry['order']['shipping_charge'], true, false, 'return' ) . '</td>'; |
| 441 |
$meisai .= '</tr>'; |
| 442 |
} |
| 443 |
|
| 444 |
if ( 0 < $entry['order']['cod_fee'] ) { |
| 445 |
$meisai .= '<tr>'; |
| 446 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $order_id ) . '</td>'; |
| 447 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $entry['order']['cod_fee'], true, false, 'return' ) . '</td>'; |
| 448 |
$meisai .= '</tr>'; |
| 449 |
} |
| 450 |
|
| 451 |
if ( usces_is_tax_display() && 'all' === usces_get_tax_target() ) { |
| 452 |
$meisai .= '<tr>'; |
| 453 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax_label( $data ) . '</td>'; |
| 454 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax( $entry ) . '</td>'; |
| 455 |
$meisai .= '</tr>'; |
| 456 |
} |
| 457 |
|
| 458 |
if ( usces_is_member_system() && usces_is_member_system_point() && 1 === (int) usces_point_coverage() && 0 !== (int) $entry['order']['usedpoint'] ) { |
| 459 |
$meisai .= '<tr>'; |
| 460 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'use of points', 'usces' ) . '</td>'; |
| 461 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . number_format( $entry['order']['usedpoint'] ) . __( 'Points', 'usces' ) . '</td>'; |
| 462 |
$meisai .= '</tr>'; |
| 463 |
} |
| 464 |
|
| 465 |
$meisai .= '<tr>'; |
| 466 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'Payment amount', 'usces' ) . '</td>'; |
| 467 |
$meisai .= '<td style="text-align: right; width: 75%; font-weight: 700; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $entry['order']['total_full_price'], true, false, 'return' ) . '</td>'; |
| 468 |
$meisai .= '</tr>'; |
| 469 |
$meisai .= '</tfoot></table>'; |
| 470 |
$meisai .= '<p style="margin-top: 10px; font-size: 13px;">(' . __( 'Currency', 'usces' ) . ' : ' . __( usces_crcode( 'return' ), 'usces' ) . ')</p>'; |
| 471 |
|
| 472 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 473 |
$condition = $usces->get_condition(); |
| 474 |
if ( 'include' === $condition['tax_mode'] ) { |
| 475 |
$po = '('; |
| 476 |
$pc = ')'; |
| 477 |
} else { |
| 478 |
$po = ''; |
| 479 |
$pc = ''; |
| 480 |
} |
| 481 |
$meisai .= '<p style="margin-top: 10px; font-size: 13px;">'; |
| 482 |
$reduced_output_even_empty = apply_filters( 'usces_filter_mail_reduced_output_even_empty', false, $usces_tax, $condition['tax_mode'] ); |
| 483 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 484 |
$meisai .= $usces_tax->reduced_taxrate_mark . __( ' is reduced tax rate', 'usces' ) . '<br>'; |
| 485 |
} |
| 486 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . usces_crform( $usces_tax->subtotal_standard + $usces_tax->discount_standard, true, false, 'return' ) . '<br>'; /* translators: %s is replaced with "string" */ |
| 487 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . $po . usces_crform( $usces_tax->tax_standard, true, false, 'return' ) . $pc . '<br>'; /* translators: %s is replaced with "string" */ |
| 488 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 489 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . usces_crform( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced, true, false, 'return' ) . '<br>'; /* translators: %s is replaced with "string" */ |
| 490 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . $po . usces_crform( $usces_tax->tax_reduced, true, false, 'return' ) . $pc . '<br>'; /* translators: %s is replaced with "string" */ |
| 491 |
} |
| 492 |
$meisai .= '</p>'; |
| 493 |
} |
| 494 |
|
| 495 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_meisai', $meisai, $data, $cart, $entry ); |
| 496 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />' . "\r\n"; |
| 497 |
|
| 498 |
// Buyer information. |
| 499 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 500 |
$msg_body .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Customer information **', 'usces' ) . '</caption>'; |
| 501 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 502 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 503 |
|
| 504 |
$msg_body .= uesces_get_mail_addressform( 'order_mail_customer', $entry, $order_id ); |
| 505 |
|
| 506 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 507 |
|
| 508 |
// Payment information. |
| 509 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 510 |
$msg_body .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Payment method **', 'usces' ) . '</caption>'; |
| 511 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 512 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 513 |
|
| 514 |
$msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">' . $payment['name'] . usces_payment_detail( $entry ) . '</td></tr>'; |
| 515 |
if ( 'transferAdvance' === $payment['settlement'] && ! empty( $usces->options['transferee'] ) ) { |
| 516 |
$transferee = '<td style="padding: 30px 0 10px; text-align: left; width: 100px; font-weight: normal; border-top: 1px dotted #ccc; vertical-align: text-top;">' . __( 'Transfer', 'usces' ) . '</td>'; |
| 517 |
$transferee .= '<td style="padding: 30px 0 10px 50px; width: calc( 100% - 100px ); border-top: 1px dotted #ccc; vertical-align: text-top;">' . wpautop( $usces->options['transferee'] ) . '</td>'; |
| 518 |
$msg_payment .= '<tr>'; |
| 519 |
$msg_payment .= apply_filters( 'usces_filter_mail_transferee', $transferee, $payment, $order_id ); |
| 520 |
$msg_payment .= '</tr>'; |
| 521 |
} |
| 522 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_payment', $msg_payment, $order_id, $payment, $cart, $entry, $data ); |
| 523 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 524 |
|
| 525 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 526 |
|
| 527 |
// Delivery information. |
| 528 |
$msg_shipping = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 529 |
$msg_shipping .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Shipping information **', 'usces' ) . '</caption>'; |
| 530 |
$msg_shipping .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 531 |
|
| 532 |
$msg_shipping .= '<table style="width: 100%;"><tbody>'; |
| 533 |
|
| 534 |
$deli_meth = (int) $entry['order']['delivery_method']; |
| 535 |
if ( 0 <= $deli_meth ) { |
| 536 |
$deli_index = $usces->get_delivery_method_index( $deli_meth ); |
| 537 |
if ( 0 <= $deli_index ) { |
| 538 |
$msg_shipping .= '<tr>'; |
| 539 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery Method', 'usces' ) . '</td>'; |
| 540 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $usces->options['delivery_method'][ $deli_index ]['name'] . '</td>'; |
| 541 |
$msg_shipping .= '</tr>'; |
| 542 |
} |
| 543 |
} |
| 544 |
$msg_shipping .= '<tr>'; |
| 545 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery date', 'usces' ) . '</td>'; |
| 546 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $entry['order']['delivery_date'] . '</td>'; |
| 547 |
$msg_shipping .= '</tr>'; |
| 548 |
$msg_shipping .= '<tr>'; |
| 549 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery Time', 'usces' ) . '</td>'; |
| 550 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $entry['order']['delivery_time'] . '</td>'; |
| 551 |
$msg_shipping .= '</tr>'; |
| 552 |
|
| 553 |
$msg_shipping .= '</tbody></table>'; |
| 554 |
|
| 555 |
$msg_shipping .= '<hr style="margin: 30px 0 30px; border-style: none; border-top: 1px dotted #ccc;" />'; |
| 556 |
|
| 557 |
$msg_shipping .= '<table style="width: 100%;"><tbody>'; |
| 558 |
$msg_shipping .= uesces_get_mail_addressform( 'order_mail', $entry, $order_id ); |
| 559 |
$msg_shipping .= '</tbody></table></td></tr></tbody></table>'; |
| 560 |
$msg_shipping .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 561 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_shipping', $msg_shipping, $data, $entry ); |
| 562 |
|
| 563 |
$csod_meta = usces_has_custom_field_meta( 'order' ); |
| 564 |
if ( ! empty( $csod_meta ) ) { |
| 565 |
$msg_body .= '<table style="font-size: 14px; width: 100%; border-collapse: collapse;">'; |
| 566 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 567 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 568 |
$msg_body .= usces_mail_custom_field_info( 'order', '', $order_id, $entry['customer']['mailaddress1'] ); |
| 569 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 570 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 571 |
} |
| 572 |
|
| 573 |
$msg_others = '<table style="font-size: 14px; width: 100%; border-collapse: collapse;">'; |
| 574 |
$msg_others .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Others / a demand **', 'usces' ) . '</caption>'; |
| 575 |
$msg_others .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 576 |
$msg_others .= '<table style="width: 100%;"><tbody>'; |
| 577 |
$msg_others .= '<tr><td colspan="2" style="padding: 0;">' . wpautop( esc_html( $entry['order']['note'] ) ) . '</td></tr>'; |
| 578 |
$msg_others .= '</tbody></table></td></tr></tbody></table>'; |
| 579 |
|
| 580 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_others', $msg_others, $data ); |
| 581 |
|
| 582 |
$msg_body .= '<hr style="margin: 50px 0 0; border-style: none; border-top: 3px solid #777;" />'; |
| 583 |
|
| 584 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_body', null, $data ); |
| 585 |
|
| 586 |
return $msg_body; |
| 587 |
} |
| 588 |
|
| 589 |
/** |
| 590 |
* Generate text for the body of the thanks mail |
| 591 |
* |
| 592 |
* @param array $args { |
| 593 |
* The array of mail data. |
| 594 |
* @type int $order_id Order ID. |
| 595 |
* @type array $cart Cart data. |
| 596 |
* @type array $newcart New cart data. |
| 597 |
* @type array $entry Entry data. |
| 598 |
* @type array $payment Payment data. |
| 599 |
* @type array $data Order data. |
| 600 |
* } |
| 601 |
* @return text : mail body |
| 602 |
*/ |
| 603 |
function usces_get_thanksmail_textbody( $args ) { |
| 604 |
global $usces; |
| 605 |
extract( $args ); |
| 606 |
|
| 607 |
$reduced_taxrate = usces_is_reduced_taxrate(); |
| 608 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 609 |
$usces_tax = Welcart_Tax::get_instance(); |
| 610 |
} |
| 611 |
|
| 612 |
$msg_body = ''; |
| 613 |
$msg_body = "\r\n\r\n\r\n" . __( '** content of ordered items **', 'usces' ) . "\r\n"; |
| 614 |
$msg_body .= usces_mail_line( 1, $entry['customer']['mailaddress1'] ); // ******************** |
| 615 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_first', null, $data ); |
| 616 |
$msg_body .= uesces_get_mail_addressform( 'order_mail_customer', $entry, $order_id ); |
| 617 |
$msg_body .= __( 'Order number', 'usces' ) . ' : ' . usces_get_deco_order_id( $order_id ) . "\r\n"; |
| 618 |
$msg_body .= __( 'order date', 'usces' ) . ' : ' . $data['order_date'] . "\r\n"; |
| 619 |
|
| 620 |
$meisai = __( 'Items', 'usces' ) . " :\r\n"; |
| 621 |
foreach ( $cart as $cart_key => $cart_row ) { |
| 622 |
$cart_row['cart_id'] = $newcart[ $cart_key ]['cart_id']; |
| 623 |
$post_id = $cart_row['post_id']; |
| 624 |
$sku = urldecode( $cart_row['sku'] ); |
| 625 |
$quantity = $cart_row['quantity']; |
| 626 |
$options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array(); |
| 627 |
$cart_item_name = $usces->getCartItemName( $post_id, $sku ); |
| 628 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 629 |
$applicable_taxrate = $usces_tax->get_sku_applicable_taxrate( $post_id, $sku ); |
| 630 |
if ( 'reduced' === $applicable_taxrate ) { |
| 631 |
$cart_item_name .= $usces_tax->reduced_taxrate_mark; |
| 632 |
} |
| 633 |
} |
| 634 |
$sku_price = $cart_row['price']; |
| 635 |
$args = compact( 'cart', 'cart_row', 'post_id', 'sku' ); |
| 636 |
$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] ); // -------------------- |
| 637 |
$meisai .= apply_filters( 'usces_filter_cart_item_name_nl', $cart_item_name, $args ) . "\r\n"; |
| 638 |
if ( is_array( $options ) && count( $options ) > 0 ) { |
| 639 |
$optstr = ''; |
| 640 |
foreach ( $options as $key => $value ) { |
| 641 |
if ( ! empty( $key ) ) { |
| 642 |
$key = urldecode( $key ); |
| 643 |
if ( is_array( $value ) ) { |
| 644 |
$c = ''; |
| 645 |
$optstr .= $key . ' : '; |
| 646 |
foreach ( $value as $v ) { |
| 647 |
$optstr .= $c . urldecode( $v ); |
| 648 |
$c = ', '; |
| 649 |
} |
| 650 |
$optstr .= "\r\n"; |
| 651 |
} else { |
| 652 |
$optstr .= $key . ' : ' . urldecode( $value ) . "\r\n"; |
| 653 |
} |
| 654 |
} |
| 655 |
} |
| 656 |
$meisai .= apply_filters( 'usces_filter_option_ordermail', $optstr, $options, $newcart[ $cart_key ] ); |
| 657 |
} |
| 658 |
$meisai .= apply_filters( 'usces_filter_advance_ordermail', '', $newcart[ $cart_key ], $data ); |
| 659 |
$meisai .= __( 'Unit price', 'usces' ) . ' ' . usces_crform( $sku_price, true, false, 'return' ) . __( ' * ', 'usces' ) . $cart_row['quantity'] . "\r\n"; |
| 660 |
} |
| 661 |
$meisai .= usces_mail_line( 3, $entry['customer']['mailaddress1'] ); // ==================== |
| 662 |
$meisai .= __( 'total items', 'usces' ) . ' : ' . usces_crform( $entry['order']['total_items_price'], true, false, 'return' ) . "\r\n"; |
| 663 |
|
| 664 |
if ( 0.0 !== (float) $entry['order']['discount'] ) { |
| 665 |
$meisai .= apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ), $order_id ) . ' : ' . usces_crform( $entry['order']['discount'], true, false, 'return' ) . "\r\n"; |
| 666 |
} |
| 667 |
|
| 668 |
if ( usces_is_tax_display() && 'products' === usces_get_tax_target() ) { |
| 669 |
$meisai .= usces_mail_tax_label( $data ); |
| 670 |
if ( 'exclude' === usces_get_tax_mode() ) { |
| 671 |
$meisai .= ' : ' . usces_mail_tax( $entry ); |
| 672 |
} |
| 673 |
$meisai .= "\r\n"; |
| 674 |
} |
| 675 |
|
| 676 |
if ( usces_is_member_system() && usces_is_member_system_point() && 0 === (int) usces_point_coverage() && 0 !== (int) $entry['order']['usedpoint'] ) { |
| 677 |
$meisai .= __( 'use of points', 'usces' ) . ' : ' . number_format( $entry['order']['usedpoint'] ) . __( 'Points', 'usces' ) . "\r\n"; |
| 678 |
} |
| 679 |
|
| 680 |
if ( usces_have_shipped( $cart ) ) { |
| 681 |
$meisai .= __( 'Shipping', 'usces' ) . ' : ' . usces_crform( $entry['order']['shipping_charge'], true, false, 'return' ) . "\r\n"; |
| 682 |
} |
| 683 |
|
| 684 |
if ( 0 < $entry['order']['cod_fee'] ) { |
| 685 |
$meisai .= apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $order_id ) . ' : ' . usces_crform( $entry['order']['cod_fee'], true, false, 'return' ) . "\r\n"; |
| 686 |
} |
| 687 |
|
| 688 |
if ( usces_is_tax_display() && 'all' === usces_get_tax_target() ) { |
| 689 |
$meisai .= usces_mail_tax_label( $data ); |
| 690 |
if ( 'exclude' === usces_get_tax_mode() ) { |
| 691 |
$meisai .= ' : ' . usces_mail_tax( $entry ); |
| 692 |
} |
| 693 |
$meisai .= "\r\n"; |
| 694 |
} |
| 695 |
|
| 696 |
if ( usces_is_member_system() && usces_is_member_system_point() && 1 === (int) usces_point_coverage() && 0 !== (int) $entry['order']['usedpoint'] ) { |
| 697 |
$meisai .= __( 'use of points', 'usces' ) . ' : ' . number_format( $entry['order']['usedpoint'] ) . __( 'Points', 'usces' ) . "\r\n"; |
| 698 |
} |
| 699 |
|
| 700 |
$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] ); // -------------------- |
| 701 |
$meisai .= __( 'Payment amount', 'usces' ) . ' : ' . usces_crform( $entry['order']['total_full_price'], true, false, 'return' ) . "\r\n"; |
| 702 |
$meisai .= usces_mail_line( 2, $entry['customer']['mailaddress1'] ); // -------------------- |
| 703 |
if ( usces_is_tax_display() && $reduced_taxrate ) { |
| 704 |
$condition = $usces->get_condition(); |
| 705 |
if ( 'include' === $condition['tax_mode'] ) { |
| 706 |
$po = '('; |
| 707 |
$pc = ')'; |
| 708 |
} else { |
| 709 |
$po = ''; |
| 710 |
$pc = ''; |
| 711 |
} |
| 712 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . usces_crform( $usces_tax->subtotal_standard + $usces_tax->discount_standard, true, false, 'return' ) . "\r\n"; /* translators: %s is replaced with "string" */ |
| 713 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . $po . usces_crform( $usces_tax->tax_standard, true, false, 'return' ) . $pc . "\r\n"; /* translators: %s is replaced with "string" */ |
| 714 |
$reduced_output_even_empty = apply_filters( 'usces_filter_mail_reduced_output_even_empty', false, $usces_tax, $condition['tax_mode'] ); |
| 715 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 716 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . usces_crform( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced, true, false, 'return' ) . "\r\n"; /* translators: %s is replaced with "string" */ |
| 717 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . $po . usces_crform( $usces_tax->tax_reduced, true, false, 'return' ) . $pc . "\r\n"; /* translators: %s is replaced with "string" */ |
| 718 |
} |
| 719 |
$meisai .= usces_mail_line( 2, $data['order_email'] ); // -------------------- |
| 720 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 721 |
$meisai .= $usces_tax->reduced_taxrate_mark . __( ' is reduced tax rate', 'usces' ) . "\r\n"; |
| 722 |
} |
| 723 |
} |
| 724 |
$meisai .= '(' . __( 'Currency', 'usces' ) . ' : ' . __( usces_crcode( 'return' ), 'usces' ) . ")\r\n\r\n"; |
| 725 |
|
| 726 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_meisai', $meisai, $data, $cart, $entry ); |
| 727 |
|
| 728 |
$msg_shipping = __( '** Shipping information **', 'usces' ) . "\r\n"; |
| 729 |
$msg_shipping .= usces_mail_line( 1, $entry['customer']['mailaddress1'] ); // ******************** |
| 730 |
|
| 731 |
$msg_shipping .= uesces_get_mail_addressform( 'order_mail', $entry, $order_id ); |
| 732 |
|
| 733 |
$deli_meth = (int) $entry['order']['delivery_method']; |
| 734 |
if ( 0 <= $deli_meth ) { |
| 735 |
$deli_index = $usces->get_delivery_method_index( $deli_meth ); |
| 736 |
if ( 0 <= $deli_index ) { |
| 737 |
$msg_shipping .= __( 'Delivery Method', 'usces' ) . ' : ' . $usces->options['delivery_method'][ $deli_index ]['name'] . "\r\n"; |
| 738 |
} |
| 739 |
} |
| 740 |
$msg_shipping .= __( 'Delivery date', 'usces' ) . ' : ' . $entry['order']['delivery_date'] . "\r\n"; |
| 741 |
$msg_shipping .= __( 'Delivery Time', 'usces' ) . ' : ' . $entry['order']['delivery_time'] . "\r\n"; |
| 742 |
$msg_shipping .= "\r\n"; |
| 743 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_shipping', $msg_shipping, $data, $entry ); |
| 744 |
|
| 745 |
$msg_payment = __( '** Payment method **', 'usces' ) . "\r\n"; |
| 746 |
$msg_payment .= usces_mail_line( 1, $entry['customer']['mailaddress1'] ); // ******************** |
| 747 |
$msg_payment .= $payment['name'] . usces_payment_detail( $entry ) . "\r\n\r\n"; |
| 748 |
if ( 'transferAdvance' === $payment['settlement'] && ! empty( $usces->options['transferee'] ) ) { |
| 749 |
$transferee = __( 'Transfer', 'usces' ) . " : \r\n"; |
| 750 |
$transferee .= $usces->options['transferee'] . "\r\n"; |
| 751 |
$msg_payment .= apply_filters( 'usces_filter_mail_transferee', $transferee, $payment, $order_id ); |
| 752 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $entry['customer']['mailaddress1'] ) . "\r\n"; // -------------------- |
| 753 |
} |
| 754 |
|
| 755 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_payment', $msg_payment, $order_id, $payment, $cart, $entry, $data ); |
| 756 |
|
| 757 |
$msg_body .= usces_mail_custom_field_info( 'order', '', $order_id ); |
| 758 |
|
| 759 |
$msg_others = "\r\n"; |
| 760 |
$msg_others .= __( '** Others / a demand **', 'usces' ) . "\r\n"; |
| 761 |
$msg_others .= usces_mail_line( 1, $entry['customer']['mailaddress1'] ); // ******************** |
| 762 |
$msg_others .= esc_html( $entry['order']['note'] ) . "\r\n\r\n"; |
| 763 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_others', $msg_others, $data ); |
| 764 |
|
| 765 |
$msg_body .= apply_filters( 'usces_filter_send_order_mail_body', null, $data ); |
| 766 |
|
| 767 |
return $msg_body; |
| 768 |
} |
| 769 |
|
| 770 |
/** |
| 771 |
* Generate html for the body of the admin mail |
| 772 |
* |
| 773 |
* @param array $args { |
| 774 |
* The array of mail data. |
| 775 |
* @type int $order_id Order ID. |
| 776 |
* @type array $data Order data. |
| 777 |
* @type array $deli Delivery data. |
| 778 |
* @type array $cart Cart data. |
| 779 |
* @type string $country Country. |
| 780 |
* @type array $customer Customer data. |
| 781 |
* @type array $condition Condition data. |
| 782 |
* @type float $total_full_price Total amount. |
| 783 |
* @type array $mail_data Mail data. |
| 784 |
* @type array $payment Payment data. |
| 785 |
* @type bool $tax_display Is tax display. |
| 786 |
* @type bool $reduced_taxrate Is reduced taxrate. |
| 787 |
* @type string $tax_mode Tax mode. |
| 788 |
* @type string $tax_target Tax target. |
| 789 |
* @type object $usces_tax Tax class. |
| 790 |
* @type int $point_coverage Point coverage. |
| 791 |
* @type string $member_system Use member system. |
| 792 |
* @type string $member_system_point Use member point. |
| 793 |
* } |
| 794 |
* @return text : mail body |
| 795 |
*/ |
| 796 |
function usces_get_adminmail_htmlbody( $args ) { |
| 797 |
global $usces; |
| 798 |
extract( $args ); |
| 799 |
|
| 800 |
$mail_mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : ''; |
| 801 |
|
| 802 |
$msg_body = ''; |
| 803 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_body_top', $msg_body, $args ); |
| 804 |
|
| 805 |
$msg_body .= '<hr style="margin: 0 0 50px; border-style: none; border-top: 3px solid #777;" />'; |
| 806 |
|
| 807 |
// Tilt and order number. |
| 808 |
|
| 809 |
if ( 'mitumoriConfirmMail' === $mail_mode ) { |
| 810 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 811 |
$msg_body .= '<caption style="background-color: #111; margin-bottom: 40px; padding: 15px; color: #fff; font-size: 15px; font-weight: 700; text-align: left;">' . __( 'Estimate', 'usces' ) . '</caption>'; |
| 812 |
$msg_body .= '<tbody>'; |
| 813 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_first', null, $data ); |
| 814 |
$msg_body .= '<tr>'; |
| 815 |
$msg_body .= '<td style="background-color: #f9f9f9; padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'estimate number', 'usces' ) . '</td>'; |
| 816 |
$msg_body .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . usces_get_deco_order_id( $order_id ) . '</td>'; |
| 817 |
$msg_body .= '</tr>'; |
| 818 |
$msg_body .= '</tbody>'; |
| 819 |
$msg_body .= '</table>'; |
| 820 |
} else { |
| 821 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 822 |
$msg_body .= '<caption style="background-color: #111; margin-bottom: 40px; padding: 15px; color: #fff; font-size: 15px; font-weight: 700; text-align: left;">' . __( '** Article order contents **', 'usces' ) . '</caption>'; |
| 823 |
$msg_body .= '<tbody>'; |
| 824 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_first', null, $data ); |
| 825 |
$msg_body .= '<tr>'; |
| 826 |
$msg_body .= '<td style="background-color: #f9f9f9; padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'order date', 'usces' ) . '</td>'; |
| 827 |
$msg_body .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . $data['order_date'] . '</td>'; |
| 828 |
$msg_body .= '</tr>'; |
| 829 |
$msg_body .= '<tr>'; |
| 830 |
$msg_body .= '<td style="background-color: #f9f9f9; padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'Order number', 'usces' ) . '</td>'; |
| 831 |
$msg_body .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . usces_get_deco_order_id( $order_id ) . '</td>'; |
| 832 |
$msg_body .= '</tr>'; |
| 833 |
$msg_body .= '</tbody>'; |
| 834 |
$msg_body .= '</table>'; |
| 835 |
} |
| 836 |
|
| 837 |
// Purchase details. |
| 838 |
$meisai = '<table style="font-size: 14px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 839 |
$meisai .= '<thead>'; |
| 840 |
$meisai .= '<tr>'; |
| 841 |
$meisai .= '<td style="text-align: center; width: 50%; padding: 12px; border: 1px solid #ddd;">' . __( 'Items', 'usces' ) . '</td>'; |
| 842 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd;">' . __( 'Unit price', 'usces' ) . '</td>'; |
| 843 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd;">' . __( 'Quantity', 'usces' ) . '</td>'; |
| 844 |
$meisai .= '</tr>'; |
| 845 |
$meisai .= '</thead>'; |
| 846 |
$meisai .= '<tbody>'; |
| 847 |
|
| 848 |
foreach ( (array) $cart as $cart_row ) { |
| 849 |
$post_id = $cart_row['post_id']; |
| 850 |
$sku = urldecode( $cart_row['sku'] ); |
| 851 |
$quantity = $cart_row['quantity']; |
| 852 |
$options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array(); |
| 853 |
$cart_item_name = esc_html( $usces->getCartItemName_byOrder( $cart_row ) ); |
| 854 |
if ( 'activate' === $tax_display && $reduced_taxrate ) { |
| 855 |
$applicable_taxrate = $usces_tax->get_ordercart_applicable_taxrate( $cart_row['cart_id'], $post_id, $sku ); |
| 856 |
if ( 'reduced' === $applicable_taxrate ) { |
| 857 |
$cart_item_name .= $usces_tax->reduced_taxrate_mark; |
| 858 |
} |
| 859 |
} |
| 860 |
$sku_price = $cart_row['price']; |
| 861 |
$args = compact( 'cart', 'cart_row', 'post_id', 'sku' ); |
| 862 |
|
| 863 |
$meisai .= '<tr>'; |
| 864 |
$meisai .= '<td style="width: 50%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">'; |
| 865 |
$meisai .= apply_filters( 'usces_filter_cart_item_name_nl', $cart_item_name, $args ) . '<br>'; |
| 866 |
if ( is_array( $options ) && count( $options ) > 0 ) { |
| 867 |
$optstr = ''; |
| 868 |
foreach ( $options as $key => $value ) { |
| 869 |
if ( ! empty( $key ) ) { |
| 870 |
$key = urldecode( $key ); |
| 871 |
$value = wel_safe_maybe_unserialize( $value ); |
| 872 |
if ( is_array( $value ) ) { |
| 873 |
$c = ''; |
| 874 |
$optstr .= esc_html( $key ) . ' : '; |
| 875 |
foreach ( $value as $v ) { |
| 876 |
$optstr .= $c . esc_html( rawurldecode( $v ) ); |
| 877 |
$c = ', '; |
| 878 |
} |
| 879 |
$optstr .= '<br>'; |
| 880 |
} else { |
| 881 |
$optstr .= esc_html( $key ) . ' : ' . esc_html( rawurldecode( $value ) ) . '<br>'; |
| 882 |
} |
| 883 |
} |
| 884 |
} |
| 885 |
$meisai .= apply_filters( 'usces_filter_option_adminmail', $optstr, $options, $cart_row ); |
| 886 |
} |
| 887 |
$meisai .= apply_filters( 'usces_filter_advance_adminmail', '', $cart_row, $data ); |
| 888 |
$meisai .= '</td>'; |
| 889 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $sku_price, true, false, 'return' ) . '</td>'; |
| 890 |
$meisai .= '<td style="text-align: center; width: 25%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . $cart_row['quantity'] . '</td>'; |
| 891 |
$meisai .= '</tr>'; |
| 892 |
} |
| 893 |
|
| 894 |
$meisai .= '</tbody><tfoot>'; |
| 895 |
$meisai .= '<tr>'; |
| 896 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'total items', 'usces' ) . '</td>'; |
| 897 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $data['order_item_total_price'], true, false, 'return' ) . '</td>'; |
| 898 |
$meisai .= '</tr>'; |
| 899 |
|
| 900 |
if ( 0.0 !== (float) $data['order_discount'] ) { |
| 901 |
$meisai .= '<tr>'; |
| 902 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ), $order_id ) . '</td>'; |
| 903 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $data['order_discount'], true, false, 'return' ) . '</td>'; |
| 904 |
$meisai .= '</tr>'; |
| 905 |
} |
| 906 |
|
| 907 |
if ( 'activate' === $tax_display && 'products' === $tax_target ) { |
| 908 |
$meisai .= '<tr>'; |
| 909 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax_label( $data ) . '</td>'; |
| 910 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax( $data ) . '</td>'; |
| 911 |
$meisai .= '</tr>'; |
| 912 |
} |
| 913 |
|
| 914 |
if ( 'activate' === $member_system && 'activate' === $member_system_point && 0 === (int) $point_coverage && 0 !== (int) $data['order_usedpoint'] ) { |
| 915 |
$meisai .= '<tr>'; |
| 916 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'use of points', 'usces' ) . '</td>'; |
| 917 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . number_format( $data['order_usedpoint'] ) . __( 'Points', 'usces' ) . '</td>'; |
| 918 |
$meisai .= '</tr>'; |
| 919 |
} |
| 920 |
|
| 921 |
if ( usces_have_shipped( $cart ) ) { |
| 922 |
$meisai .= '<tr>'; |
| 923 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'Shipping', 'usces' ) . '</td>'; |
| 924 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $data['order_shipping_charge'], true, false, 'return' ) . '</td>'; |
| 925 |
$meisai .= '</tr>'; |
| 926 |
} |
| 927 |
|
| 928 |
if ( 0 < $data['order_cod_fee'] ) { |
| 929 |
$meisai .= '<tr>'; |
| 930 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $order_id ) . '</td>'; |
| 931 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $data['order_cod_fee'], true, false, 'return' ) . '</td>'; |
| 932 |
$meisai .= '</tr>'; |
| 933 |
} |
| 934 |
|
| 935 |
if ( 'activate' === $tax_display && 'all' === $tax_target ) { |
| 936 |
$meisai .= '<tr>'; |
| 937 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax_label( $data ) . '</td>'; |
| 938 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_mail_tax( $data ) . '</td>'; |
| 939 |
$meisai .= '</tr>'; |
| 940 |
} |
| 941 |
|
| 942 |
if ( 'activate' === $member_system && 'activate' === $member_system_point && 1 === (int) $point_coverage && 0 !== (int) $data['order_usedpoint'] ) { |
| 943 |
$meisai .= '<tr>'; |
| 944 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'use of points', 'usces' ) . '</td>'; |
| 945 |
$meisai .= '<td style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . number_format( $data['order_usedpoint'] ) . __( 'Points', 'usces' ) . '</td>'; |
| 946 |
$meisai .= '</tr>'; |
| 947 |
} |
| 948 |
|
| 949 |
$meisai .= '<tr>'; |
| 950 |
$meisai .= '<td colspan="2" style="text-align: right; width: 75%; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . __( 'Payment amount', 'usces' ) . '</td>'; |
| 951 |
$meisai .= '<td style="text-align: right; width: 75%; font-weight: 700; padding: 12px; border: 1px solid #ddd; vertical-align: middle;">' . usces_crform( $total_full_price, true, false, 'return' ) . '</td>'; |
| 952 |
$meisai .= '</tr>'; |
| 953 |
$meisai .= '</tfoot></table>'; |
| 954 |
$meisai .= '<p style="margin-top: 10px; font-size: 13px;">(' . __( 'Currency', 'usces' ) . ' : ' . __( usces_crcode( 'return' ), 'usces' ) . ')</p>'; |
| 955 |
|
| 956 |
if ( 'activate' === $tax_display && $reduced_taxrate ) { |
| 957 |
$materials = array( |
| 958 |
'total_items_price' => $data['order_item_total_price'], |
| 959 |
'discount' => $data['order_discount'], |
| 960 |
'shipping_charge' => $data['order_shipping_charge'], |
| 961 |
'cod_fee' => $data['order_cod_fee'], |
| 962 |
'use_point' => $data['order_usedpoint'], |
| 963 |
'carts' => $cart, |
| 964 |
'condition' => $condition, |
| 965 |
'order_id' => $order_id, |
| 966 |
); |
| 967 |
$usces_tax->get_order_tax( $materials ); |
| 968 |
if ( 'include' === $condition['tax_mode'] ) { |
| 969 |
$po = '('; |
| 970 |
$pc = ')'; |
| 971 |
} else { |
| 972 |
$po = ''; |
| 973 |
$pc = ''; |
| 974 |
} |
| 975 |
$meisai .= '<p style="margin-top: 10px; font-size: 13px;">'; |
| 976 |
$reduced_output_even_empty = apply_filters( 'usces_filter_mail_reduced_output_even_empty', false, $usces_tax, $condition['tax_mode'] ); |
| 977 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 978 |
$meisai .= $usces_tax->reduced_taxrate_mark . __( ' is reduced tax rate', 'usces' ) . '<br>'; |
| 979 |
} |
| 980 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . usces_crform( $usces_tax->subtotal_standard + $usces_tax->discount_standard, true, false, 'return' ) . '<br>'; /* translators: %s is replaced with "string" */ |
| 981 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . $po . usces_crform( $usces_tax->tax_standard, true, false, 'return' ) . $pc . '<br>'; /* translators: %s is replaced with "string" */ |
| 982 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 983 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . usces_crform( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced, true, false, 'return' ) . '<br>'; /* translators: %s is replaced with "string" */ |
| 984 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . $po . usces_crform( $usces_tax->tax_reduced, true, false, 'return' ) . $pc . '<br>'; /* translators: %s is replaced with "string" */ |
| 985 |
} |
| 986 |
$meisai .= '</p>'; |
| 987 |
} |
| 988 |
|
| 989 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_meisai', $meisai, $data, $cart ); |
| 990 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />' . "\r\n"; |
| 991 |
|
| 992 |
// Buyer information. |
| 993 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 994 |
$msg_body .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Customer information **', 'usces' ) . '</caption>'; |
| 995 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 996 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 997 |
|
| 998 |
$msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id ); |
| 999 |
|
| 1000 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 1001 |
|
| 1002 |
// Payment information. |
| 1003 |
$msg_body .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 1004 |
$msg_body .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Payment method **', 'usces' ) . '</caption>'; |
| 1005 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 1006 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 1007 |
|
| 1008 |
$msg_payment = '<tr><td colspan="2" style="padding: 0 0 25px 0;">' . $payment['name'] . usces_payment_detail_confirm( $data ) . '</td></tr>'; |
| 1009 |
if ( 'orderConfirmMail' === $mail_mode || 'changeConfirmMail' === $mail_mode || 'mitumoriConfirmMail' === $mail_mode || 'otherConfirmMail' === $mail_mode ) { |
| 1010 |
if ( 'transferAdvance' === $payment['settlement'] && ! empty( $usces->options['transferee'] ) ) { |
| 1011 |
$transferee = '<td style="padding: 30px 0 10px; text-align: left; width: 100px; font-weight: normal; border-top: 1px dotted #ccc; vertical-align: text-top;">' . __( 'Transfer', 'usces' ) . '</td>'; |
| 1012 |
$transferee .= '<td style="padding: 30px 0 10px 50px; width: calc( 100% - 100px ); border-top: 1px dotted #ccc; vertical-align: text-top;">' . wpautop( $usces->options['transferee'] ) . '</td>'; |
| 1013 |
$msg_payment .= '<tr>'; |
| 1014 |
$msg_payment .= apply_filters( 'usces_filter_mail_transferee', $transferee, $payment, $order_id ); |
| 1015 |
$msg_payment .= '</tr>'; |
| 1016 |
} |
| 1017 |
} |
| 1018 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_payment', $msg_payment, $order_id, $payment, $cart, $data ); |
| 1019 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 1020 |
|
| 1021 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 1022 |
|
| 1023 |
// Delivery information. |
| 1024 |
$msg_shipping = '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse;">'; |
| 1025 |
$msg_shipping .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Shipping information **', 'usces' ) . '</caption>'; |
| 1026 |
$msg_shipping .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 1027 |
|
| 1028 |
$msg_shipping .= '<table style="width: 100%;"><tbody>'; |
| 1029 |
|
| 1030 |
$deli_meth = (int) $data['order_delivery_method']; |
| 1031 |
if ( 0 <= $deli_meth ) { |
| 1032 |
$deli_index = $usces->get_delivery_method_index( $deli_meth ); |
| 1033 |
if ( 0 <= $deli_index ) { |
| 1034 |
$msg_shipping .= '<tr>'; |
| 1035 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery Method', 'usces' ) . '</td>'; |
| 1036 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $usces->options['delivery_method'][ $deli_index ]['name'] . '</td>'; |
| 1037 |
$msg_shipping .= '</tr>'; |
| 1038 |
} |
| 1039 |
} |
| 1040 |
$msg_shipping .= '<tr>'; |
| 1041 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery date', 'usces' ) . '</td>'; |
| 1042 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $data['order_delivery_date'] . '</td>'; |
| 1043 |
$msg_shipping .= '</tr>'; |
| 1044 |
$msg_shipping .= '<tr>'; |
| 1045 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery Time', 'usces' ) . '</td>'; |
| 1046 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $data['order_delivery_time'] . '</td>'; |
| 1047 |
$msg_shipping .= '</tr>'; |
| 1048 |
|
| 1049 |
if ( ! empty( $data['order_delidue_date'] ) && '#none#' !== $data['order_delidue_date'] ) { |
| 1050 |
$msg_shipping .= '<tr>'; |
| 1051 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Shipping date', 'usces' ) . '</td>'; |
| 1052 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $data['order_delidue_date'] . '<p>' . __( "* A shipment due date is a day to ship an article, and it's not the arrival day.", 'usces' ) . '</p>' . '</td>'; |
| 1053 |
$msg_shipping .= '</tr>'; |
| 1054 |
} |
| 1055 |
|
| 1056 |
if ( 'completionMail' === $mail_mode ) { |
| 1057 |
$tracking_number = $usces->get_order_meta_value( apply_filters( 'usces_filter_tracking_meta_key', 'tracking_number' ), $order_id ); |
| 1058 |
$delivery_company = $usces->get_order_meta_value( 'delivery_company', $order_id ); |
| 1059 |
if ( ! empty( $delivery_company ) ) { |
| 1060 |
$msg_shipping .= '<tr>'; |
| 1061 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Delivery company', 'usces' ) . '</td>'; |
| 1062 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $delivery_company . '</td>'; |
| 1063 |
$msg_shipping .= '</tr>'; |
| 1064 |
if ( ! empty( $tracking_number ) ) { |
| 1065 |
$msg_shipping .= '<tr>'; |
| 1066 |
$msg_shipping .= '<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Tracking number', 'usces' ) . '</td>'; |
| 1067 |
$msg_shipping .= '<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px ); overflow-wrap: anywhere;">' . $tracking_number . '<p>' . __( '[*]', 'usces' ) . __( 'You can check delivery situation from the following URL.', 'usces' ) . '</p>'; |
| 1068 |
$msg_shipping .= '<p style="word-break: break-all;">' . usces_get_delivery_company_url( $delivery_company, $tracking_number ) . '</p>' . '</td>'; |
| 1069 |
$msg_shipping .= '</tr>'; |
| 1070 |
} |
| 1071 |
} |
| 1072 |
} |
| 1073 |
$msg_shipping .= '</tbody></table>'; |
| 1074 |
|
| 1075 |
$msg_shipping .= '<hr style="margin: 30px 0 30px; border-style: none; border-top: 1px dotted #ccc;" />'; |
| 1076 |
|
| 1077 |
$msg_shipping .= '<table style="width: 100%;"><tbody>'; |
| 1078 |
$msg_shipping .= uesces_get_mail_addressform( 'admin_mail', $deli, $order_id ); |
| 1079 |
$msg_shipping .= '</tbody></table></td></tr></tbody></table>'; |
| 1080 |
$msg_shipping .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 1081 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_shipping', $msg_shipping, $data ); |
| 1082 |
|
| 1083 |
$csod_meta = usces_has_custom_field_meta( 'order' ); |
| 1084 |
if ( ! empty( $csod_meta ) ) { |
| 1085 |
$msg_body .= '<table style="font-size: 14px; width: 100%; border-collapse: collapse;">'; |
| 1086 |
$msg_body .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 1087 |
$msg_body .= '<table style="width: 100%;"><tbody>'; |
| 1088 |
$msg_body .= usces_mail_custom_field_info( 'order', '', $order_id, $data['order_email'] ); |
| 1089 |
$msg_body .= '</tbody></table></td></tr></tbody></table>'; |
| 1090 |
$msg_body .= '<hr style="margin: 40px 0 30px; border-style: none; border-top: 1px solid #ddd;" />'; |
| 1091 |
} |
| 1092 |
|
| 1093 |
$msg_others = '<table style="font-size: 14px; width: 100%; border-collapse: collapse;">'; |
| 1094 |
$msg_others .= '<caption style="font-size: 15px; font-weight: 700; text-align: left; margin-bottom: 15px;">' . __( '** Others / a demand **', 'usces' ) . '</caption>'; |
| 1095 |
$msg_others .= '<tbody><tr><td style="background-color: #f9f9f9; padding: 30px;">'; |
| 1096 |
$msg_others .= '<table style="width: 100%;"><tbody>'; |
| 1097 |
$msg_others .= '<tr><td colspan="2" style="padding: 0;">' . wpautop( esc_html( $data['order_note'] ) ) . '</td></tr>'; |
| 1098 |
$msg_others .= '</tbody></table></td></tr></tbody></table>'; |
| 1099 |
|
| 1100 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_others', $msg_others, $data ); |
| 1101 |
|
| 1102 |
$msg_body .= '<hr style="margin: 50px 0 0; border-style: none; border-top: 3px solid #777;" />'; |
| 1103 |
|
| 1104 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_body', null, $data ); |
| 1105 |
|
| 1106 |
return $msg_body; |
| 1107 |
} |
| 1108 |
|
| 1109 |
/** |
| 1110 |
* Generate text for the body of the admin mail |
| 1111 |
* |
| 1112 |
* @param array $args { |
| 1113 |
* The array of mail data. |
| 1114 |
* @type int $order_id Order ID. |
| 1115 |
* @type array $data Order data. |
| 1116 |
* @type array $deli Delivery data. |
| 1117 |
* @type array $cart Cart data. |
| 1118 |
* @type string $country Country. |
| 1119 |
* @type array $customer Customer data. |
| 1120 |
* @type array $condition Condition data. |
| 1121 |
* @type float $total_full_price Total amount. |
| 1122 |
* @type array $mail_data Mail data. |
| 1123 |
* @type array $payment Payment data. |
| 1124 |
* @type bool $tax_display Is tax display. |
| 1125 |
* @type bool $reduced_taxrate Is reduced taxrate. |
| 1126 |
* @type string $tax_mode Tax mode. |
| 1127 |
* @type string $tax_target Tax target. |
| 1128 |
* @type object $usces_tax Tax class. |
| 1129 |
* @type int $point_coverage Point coverage. |
| 1130 |
* @type string $member_system Use member system. |
| 1131 |
* @type string $member_system_point Use member point. |
| 1132 |
* } |
| 1133 |
* @return text : mail body |
| 1134 |
*/ |
| 1135 |
function usces_get_adminmail_textbody( $args ) { |
| 1136 |
global $usces; |
| 1137 |
extract( $args ); |
| 1138 |
|
| 1139 |
$mail_mode = ( isset( $_POST['mode'] ) ) ? wp_unslash( $_POST['mode'] ) : ''; |
| 1140 |
|
| 1141 |
$msg_body = ''; |
| 1142 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_body_top', $msg_body, $args ); |
| 1143 |
|
| 1144 |
if ( 'mitumoriConfirmMail' === $mail_mode ) { |
| 1145 |
$msg_body .= "\r\n\r\n\r\n" . __( 'Estimate', 'usces' ) . "\r\n"; |
| 1146 |
$msg_body .= usces_mail_line( 1, $data['order_email'] ); // ******************** |
| 1147 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_first', null, $data ); |
| 1148 |
$msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id ); |
| 1149 |
$msg_body .= __( 'estimate number', 'usces' ) . ' : ' . $order_id . "\r\n"; |
| 1150 |
} else { |
| 1151 |
$msg_body .= "\r\n\r\n\r\n" . __( '** Article order contents **', 'usces' ) . "\r\n"; |
| 1152 |
$msg_body .= usces_mail_line( 1, $data['order_email'] ); // ******************** |
| 1153 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_first', null, $data ); |
| 1154 |
$msg_body .= uesces_get_mail_addressform( 'admin_mail_customer', $customer, $order_id ); |
| 1155 |
$msg_body .= __( 'Order number', 'usces' ) . ' : ' . usces_get_deco_order_id( $order_id ) . "\r\n"; |
| 1156 |
$msg_body .= __( 'order date', 'usces' ) . ' : ' . $data['order_date'] . "\r\n"; |
| 1157 |
} |
| 1158 |
|
| 1159 |
$meisai = __( 'Items', 'usces' ) . " :\r\n"; |
| 1160 |
foreach ( (array) $cart as $cart_row ) { |
| 1161 |
$post_id = $cart_row['post_id']; |
| 1162 |
$sku = urldecode( $cart_row['sku'] ); |
| 1163 |
$quantity = $cart_row['quantity']; |
| 1164 |
$options = ( ! empty( $cart_row['options'] ) ) ? $cart_row['options'] : array(); |
| 1165 |
$cart_item_name = $usces->getCartItemName_byOrder( $cart_row ); |
| 1166 |
if ( 'activate' === $tax_display && $reduced_taxrate ) { |
| 1167 |
$applicable_taxrate = $usces_tax->get_ordercart_applicable_taxrate( $cart_row['cart_id'], $post_id, $sku ); |
| 1168 |
if ( 'reduced' === $applicable_taxrate ) { |
| 1169 |
$cart_item_name .= $usces_tax->reduced_taxrate_mark; |
| 1170 |
} |
| 1171 |
} |
| 1172 |
$sku_price = $cart_row['price']; |
| 1173 |
$args = compact( 'cart', 'cart_row', 'post_id', 'sku' ); |
| 1174 |
$meisai .= usces_mail_line( 2, $data['order_email'] ); // -------------------- |
| 1175 |
$meisai .= apply_filters( 'usces_filter_cart_item_name_nl', $cart_item_name, $args ) . "\r\n"; |
| 1176 |
if ( is_array( $options ) && count( $options ) > 0 ) { |
| 1177 |
$optstr = ''; |
| 1178 |
foreach ( $options as $key => $value ) { |
| 1179 |
if ( ! empty( $key ) ) { |
| 1180 |
$key = urldecode( $key ); |
| 1181 |
$value = wel_safe_maybe_unserialize( $value ); |
| 1182 |
if ( is_array( $value ) ) { |
| 1183 |
$c = ''; |
| 1184 |
$optstr .= $key . ' : '; |
| 1185 |
foreach ( $value as $v ) { |
| 1186 |
$optstr .= $c . rawurldecode( $v ); |
| 1187 |
$c = ', '; |
| 1188 |
} |
| 1189 |
$optstr .= "\r\n"; |
| 1190 |
} else { |
| 1191 |
$optstr .= $key . ' : ' . rawurldecode( $value ) . "\r\n"; |
| 1192 |
} |
| 1193 |
} |
| 1194 |
} |
| 1195 |
$meisai .= apply_filters( 'usces_filter_option_adminmail', $optstr, $options, $cart_row ); |
| 1196 |
} |
| 1197 |
$meisai .= apply_filters( 'usces_filter_advance_adminmail', '', $cart_row, $data ); |
| 1198 |
$meisai .= __( 'Unit price', 'usces' ) . ' ' . usces_crform( $sku_price, true, false, 'return' ) . __( ' * ', 'usces' ) . $cart_row['quantity'] . "\r\n"; |
| 1199 |
} |
| 1200 |
|
| 1201 |
$meisai .= usces_mail_line( 3, $data['order_email'] ); // ==================== |
| 1202 |
$meisai .= __( 'total items', 'usces' ) . ' : ' . usces_crform( $data['order_item_total_price'], true, false, 'return' ) . "\r\n"; |
| 1203 |
|
| 1204 |
if ( 0 !== (int) $data['order_discount'] ) { |
| 1205 |
$meisai .= apply_filters( 'usces_confirm_discount_label', __( 'Campaign discount', 'usces' ), $order_id ) . ' : ' . usces_crform( $data['order_discount'], true, false, 'return' ) . "\r\n"; |
| 1206 |
} |
| 1207 |
if ( 'activate' === $tax_display && 'products' === $tax_target ) { |
| 1208 |
$meisai .= usces_mail_tax_label( $data ); |
| 1209 |
if ( 'exclude' === $tax_mode ) { |
| 1210 |
$meisai .= ' : ' . usces_mail_tax( $data ); |
| 1211 |
} |
| 1212 |
$meisai .= "\r\n"; |
| 1213 |
} |
| 1214 |
|
| 1215 |
if ( 'activate' === $member_system && 'activate' === $member_system_point && 0 === (int) $point_coverage && 0 !== (int) $data['order_usedpoint'] ) { |
| 1216 |
$meisai .= __( 'use of points', 'usces' ) . ' : ' . number_format( $data['order_usedpoint'] ) . __( 'Points', 'usces' ) . "\r\n"; |
| 1217 |
} |
| 1218 |
|
| 1219 |
if ( usces_have_shipped( $cart ) ) { |
| 1220 |
$meisai .= __( 'Shipping', 'usces' ) . ' : ' . usces_crform( $data['order_shipping_charge'], true, false, 'return' ) . "\r\n"; |
| 1221 |
} |
| 1222 |
|
| 1223 |
if ( 0 < $data['order_cod_fee'] ) { |
| 1224 |
$meisai .= apply_filters( 'usces_filter_cod_label', __( 'COD fee', 'usces' ), $order_id ) . ' : ' . usces_crform( $data['order_cod_fee'], true, false, 'return' ) . "\r\n"; |
| 1225 |
} |
| 1226 |
|
| 1227 |
if ( 'activate' === $tax_display && 'all' === $tax_target ) { |
| 1228 |
$meisai .= usces_mail_tax_label( $data ); |
| 1229 |
if ( 'exclude' === $tax_mode ) { |
| 1230 |
$meisai .= ' : ' . usces_mail_tax( $data ); |
| 1231 |
} |
| 1232 |
$meisai .= "\r\n"; |
| 1233 |
} |
| 1234 |
|
| 1235 |
if ( 'activate' === $member_system && 'activate' === $member_system_point && 1 === (int) $point_coverage && 0 !== (int) $data['order_usedpoint'] ) { |
| 1236 |
$meisai .= __( 'use of points', 'usces' ) . ' : ' . number_format( $data['order_usedpoint'] ) . __( 'Points', 'usces' ) . "\r\n"; |
| 1237 |
} |
| 1238 |
|
| 1239 |
$meisai .= usces_mail_line( 2, $data['order_email'] ); // -------------------- |
| 1240 |
$meisai .= __( 'Payment amount', 'usces' ) . ' : ' . usces_crform( $total_full_price, true, false, 'return' ) . "\r\n"; |
| 1241 |
$meisai .= usces_mail_line( 2, $data['order_email'] ); // -------------------- |
| 1242 |
if ( 'activate' === $tax_display && $reduced_taxrate ) { |
| 1243 |
$materials = array( |
| 1244 |
'total_items_price' => $data['order_item_total_price'], |
| 1245 |
'discount' => $data['order_discount'], |
| 1246 |
'shipping_charge' => $data['order_shipping_charge'], |
| 1247 |
'cod_fee' => $data['order_cod_fee'], |
| 1248 |
'use_point' => $data['order_usedpoint'], |
| 1249 |
'carts' => $cart, |
| 1250 |
'condition' => $condition, |
| 1251 |
'order_id' => $order_id, |
| 1252 |
); |
| 1253 |
$usces_tax->get_order_tax( $materials ); |
| 1254 |
if ( 'include' === $condition['tax_mode'] ) { |
| 1255 |
$po = '('; |
| 1256 |
$pc = ')'; |
| 1257 |
} else { |
| 1258 |
$po = ''; |
| 1259 |
$pc = ''; |
| 1260 |
} |
| 1261 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . usces_crform( $usces_tax->subtotal_standard + $usces_tax->discount_standard, true, false, 'return' ) . "\r\n"; /* translators: %s is replaced with "string" */ |
| 1262 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_standard ) . ' : ' . $po . usces_crform( $usces_tax->tax_standard, true, false, 'return' ) . $pc . "\r\n"; /* translators: %s is replaced with "string" */ |
| 1263 |
$reduced_output_even_empty = apply_filters( 'usces_filter_mail_reduced_output_even_empty', false, $usces_tax, $condition['tax_mode'] ); |
| 1264 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 1265 |
$meisai .= sprintf( __( 'Applies to %s%%', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . usces_crform( $usces_tax->subtotal_reduced + $usces_tax->discount_reduced, true, false, 'return' ) . "\r\n"; /* translators: %s is replaced with "string" */ |
| 1266 |
$meisai .= sprintf( __( '%s%% consumption tax', 'usces' ), $usces_tax->tax_rate_reduced ) . ' : ' . $po . usces_crform( $usces_tax->tax_reduced, true, false, 'return' ) . $pc . "\r\n"; /* translators: %s is replaced with "string" */ |
| 1267 |
} |
| 1268 |
$meisai .= usces_mail_line( 2, $data['order_email'] ); // -------------------- |
| 1269 |
if ( 0 < $usces_tax->tax_rate_reduced || $reduced_output_even_empty ) { |
| 1270 |
$meisai .= $usces_tax->reduced_taxrate_mark . __( ' is reduced tax rate', 'usces' ) . "\r\n"; |
| 1271 |
} |
| 1272 |
} |
| 1273 |
$meisai .= '(' . __( 'Currency', 'usces' ) . ' : ' . __( usces_crcode( 'return' ), 'usces' ) . ")\r\n\r\n"; |
| 1274 |
|
| 1275 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_meisai', $meisai, $data, $cart ); |
| 1276 |
|
| 1277 |
$msg_shipping = __( '** Shipping information **', 'usces' ) . "\r\n"; |
| 1278 |
$msg_shipping .= usces_mail_line( 1, $data['order_email'] ); // ******************** |
| 1279 |
|
| 1280 |
$msg_shipping .= uesces_get_mail_addressform( 'admin_mail', $deli, $order_id ); |
| 1281 |
|
| 1282 |
if ( ! empty( $data['order_delidue_date'] ) && '#none#' !== $data['order_delidue_date'] ) { |
| 1283 |
$msg_shipping .= __( 'Shipping date', 'usces' ) . ' : ' . $data['order_delidue_date'] . "\r\n"; |
| 1284 |
$msg_shipping .= __( "* A shipment due date is a day to ship an article, and it's not the arrival day.", 'usces' ) . "\r\n"; |
| 1285 |
} |
| 1286 |
$msg_shipping .= "\r\n"; |
| 1287 |
|
| 1288 |
$deli_meth = (int) $data['order_delivery_method']; |
| 1289 |
if ( 0 <= $deli_meth ) { |
| 1290 |
$deli_index = $usces->get_delivery_method_index( $deli_meth ); |
| 1291 |
if ( 0 <= $deli_index ) { |
| 1292 |
$msg_shipping .= __( 'Delivery Method', 'usces' ) . ' : ' . $usces->options['delivery_method'][ $deli_index ]['name'] . "\r\n"; |
| 1293 |
} |
| 1294 |
} |
| 1295 |
$msg_shipping .= __( 'Delivery date', 'usces' ) . ' : ' . $data['order_delivery_date'] . "\r\n"; |
| 1296 |
$msg_shipping .= __( 'Delivery Time', 'usces' ) . ' : ' . $data['order_delivery_time'] . "\r\n"; |
| 1297 |
|
| 1298 |
if ( 'completionMail' === $mail_mode ) { |
| 1299 |
$tracking_number = $usces->get_order_meta_value( apply_filters( 'usces_filter_tracking_meta_key', 'tracking_number' ), $order_id ); |
| 1300 |
$delivery_company = $usces->get_order_meta_value( 'delivery_company', $order_id ); |
| 1301 |
if ( ! empty( $delivery_company ) ) { |
| 1302 |
$msg_shipping .= __( 'Delivery company', 'usces' ) . ' : ' . $delivery_company . "\r\n"; |
| 1303 |
if ( ! empty( $tracking_number ) ) { |
| 1304 |
$msg_shipping .= __( 'Tracking number', 'usces' ) . ' : ' . $tracking_number . "\r\n\r\n"; |
| 1305 |
$msg_shipping .= __( '[*]', 'usces' ) . __( 'You can check delivery situation from the following URL.', 'usces' ) . "\r\n"; |
| 1306 |
$msg_shipping .= usces_get_delivery_company_url( $delivery_company, $tracking_number ) . " \r\n\r\n"; |
| 1307 |
} |
| 1308 |
} |
| 1309 |
} |
| 1310 |
$msg_shipping .= "\r\n"; |
| 1311 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_shipping', $msg_shipping, $data ); |
| 1312 |
|
| 1313 |
$msg_payment = __( '** Payment method **', 'usces' ) . "\r\n"; |
| 1314 |
$msg_payment .= usces_mail_line( 1, $data['order_email'] ); // ******************** |
| 1315 |
$msg_payment .= $payment['name'] . usces_payment_detail_confirm( $data ) . "\r\n\r\n"; |
| 1316 |
if ( 'orderConfirmMail' === $mail_mode || 'changeConfirmMail' === $mail_mode || 'mitumoriConfirmMail' === $mail_mode || 'otherConfirmMail' === $mail_mode ) { |
| 1317 |
if ( 'transferAdvance' === $payment['settlement'] && ! empty( $usces->options['transferee'] ) ) { |
| 1318 |
$transferee = __( 'Transfer', 'usces' ) . " :\r\n"; |
| 1319 |
$transferee .= $usces->options['transferee'] . "\r\n"; |
| 1320 |
$msg_payment .= apply_filters( 'usces_filter_mail_transferee', $transferee, $payment, $order_id ); |
| 1321 |
$msg_payment .= "\r\n" . usces_mail_line( 2, $data['order_email'] ) . "\r\n"; // -------------------- |
| 1322 |
} |
| 1323 |
} |
| 1324 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_payment', $msg_payment, $order_id, $payment, $cart, $data ); |
| 1325 |
$msg_body .= usces_mail_custom_field_info( 'order', '', $order_id, $data['order_email'] ); |
| 1326 |
|
| 1327 |
$msg_others = "\r\n"; |
| 1328 |
$msg_others .= __( '** Others / a demand **', 'usces' ) . "\r\n"; |
| 1329 |
$msg_others .= usces_mail_line( 1, $data['order_email'] ); // ******************** |
| 1330 |
$msg_others .= esc_html( $data['order_note'] ) . "\r\n\r\n"; |
| 1331 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_others', $msg_others, $data ); |
| 1332 |
|
| 1333 |
$msg_body .= apply_filters( 'usces_filter_order_confirm_mail_body', null, $data ); |
| 1334 |
|
| 1335 |
return $msg_body; |
| 1336 |
} |
| 1337 |
|
| 1338 |
/** |
| 1339 |
* Ajax for sending emails from the admin screen |
| 1340 |
* |
| 1341 |
* @return string processing result. |
| 1342 |
*/ |
| 1343 |
function usces_ajax_send_mail() { |
| 1344 |
global $wpdb, $usces; |
| 1345 |
|
| 1346 |
$nonce = isset( $_POST['wc_nonce'] ) ? filter_var( wp_unslash( $_POST['wc_nonce'] ), FILTER_SANITIZE_FULL_SPECIAL_CHARS ) : null; |
| 1347 |
$message = isset( $_POST['message'] ) ? filter_var( wp_unslash( $_POST['message'] ) ) : null; |
| 1348 |
$name = isset( $_POST['name'] ) ? filter_var( wp_unslash( $_POST['name'] ) ) : null; |
| 1349 |
$mailaddress = isset( $_POST['mailaddress'] ) ? filter_var( wp_unslash( $_POST['mailaddress'] ), FILTER_SANITIZE_EMAIL ) : null; |
| 1350 |
$subject = isset( $_POST['subject'] ) ? filter_var( wp_unslash( $_POST['subject'] ) ) : null; |
| 1351 |
$order_id = isset( $_POST['order_id'] ) ? filter_var( wp_unslash( $_POST['order_id'] ) ) : null; |
| 1352 |
$checked = isset( $_POST['checked'] ) ? filter_var( wp_unslash( $_POST['checked'] ) ) : null; |
| 1353 |
|
| 1354 |
if ( ! wp_verify_nonce( $nonce, 'wc_send_mail_order_nonce' ) ) { |
| 1355 |
$error_msg = array( 'message' => 'Your request is not valid.' ); |
| 1356 |
wp_send_json_error( $error_msg, 403 ); |
| 1357 |
} |
| 1358 |
|
| 1359 |
$attachments = ''; |
| 1360 |
if ( 1 === (int) $usces->options['email_attach_feature'] && isset( $_FILES['attachFile'] ) ) { |
| 1361 |
$attach_file = wp_unslash( $_FILES['attachFile'] ); |
| 1362 |
$url_attach_file = $attach_file['tmp_name']; |
| 1363 |
if ( is_uploaded_file( $url_attach_file ) ) { |
| 1364 |
// check validate file with current E-mail config. |
| 1365 |
$result_check_file = usces_check_validate_attach_file( $attach_file ); |
| 1366 |
if ( $result_check_file ) { |
| 1367 |
// upload file to folder. |
| 1368 |
$attachments = usces_upload_file_attach( $attach_file, 'usces_logs' ); |
| 1369 |
} else { |
| 1370 |
return 'attachFileError'; |
| 1371 |
} |
| 1372 |
} |
| 1373 |
} |
| 1374 |
$headers = ''; |
| 1375 |
$message = trim( urldecode( $message ) ); |
| 1376 |
if ( usces_is_html_mail() ) { |
| 1377 |
$headers = "Content-Type: text/html\r\n"; |
| 1378 |
$message = wpautop( $message ); |
| 1379 |
} |
| 1380 |
$order_para = array( |
| 1381 |
'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), trim( urldecode( $name ) ) ), |
| 1382 |
'to_address' => trim( urldecode( $mailaddress ) ), |
| 1383 |
'from_name' => get_option( 'blogname' ), |
| 1384 |
'from_address' => $usces->options['sender_mail'], |
| 1385 |
'reply_name' => get_option( 'blogname' ), |
| 1386 |
'reply_to' => usces_get_first_order_mail(), |
| 1387 |
'return_path' => $usces->options['error_mail'], |
| 1388 |
'subject' => trim( urldecode( $subject ) ), |
| 1389 |
'message' => $message, |
| 1390 |
'headers' => $headers, |
| 1391 |
'attachments' => $attachments, |
| 1392 |
); |
| 1393 |
|
| 1394 |
$order_para = apply_filters( 'usces_ajax_send_mail_para_to_customer', $order_para ); |
| 1395 |
|
| 1396 |
$res = usces_send_mail( $order_para ); |
| 1397 |
|
| 1398 |
do_action( 'usces_action_ajax_after_send_mail_to_customer', $res, $order_para ); |
| 1399 |
|
| 1400 |
if ( $res ) { |
| 1401 |
if ( $order_id ) { |
| 1402 |
$table_name = $wpdb->prefix . 'usces_order'; |
| 1403 |
$checked = wp_unslash( $checked ); |
| 1404 |
|
| 1405 |
$query = $wpdb->prepare( "SELECT `order_check` FROM $table_name WHERE ID = %d", $order_id ); |
| 1406 |
$res = $wpdb->get_var( $query ); |
| 1407 |
|
| 1408 |
$checkfield = is_serialized( $res ) ? wel_safe_unserialize( $res ) : array(); |
| 1409 |
if ( ! isset( $checkfield[ $checked ] ) ) { |
| 1410 |
$checkfield[ $checked ] = $checked; |
| 1411 |
} |
| 1412 |
$logger = Logger::start( $order_id, 'orderedit', 'update' ); |
| 1413 |
$query = $wpdb->prepare( "UPDATE $table_name SET `order_check`=%s WHERE ID = %d", serialize( $checkfield ), $order_id ); |
| 1414 |
$order_checked = $wpdb->query( $query ); |
| 1415 |
if ( $order_checked ) { |
| 1416 |
$logger->flush(); |
| 1417 |
} |
| 1418 |
} |
| 1419 |
|
| 1420 |
if ( 'ja' !== $usces->options['system']['front_lang'] ) { |
| 1421 |
// translators: %s: name of user. |
| 1422 |
$bcc_subject = trim( urldecode( $subject ) ) . ' to ' . sprintf( _x( '%s', 'usces' ), trim( urldecode( $name ) ) ); |
| 1423 |
} else { |
| 1424 |
// translators: %s: name of user. |
| 1425 |
$bcc_subject = trim( urldecode( $subject ) ) . ' to ' . sprintf( _x( '%s', 'honorific', 'usces' ), trim( urldecode( $name ) ) ); |
| 1426 |
} |
| 1427 |
|
| 1428 |
$bcc_para = array( |
| 1429 |
'to_name' => apply_filters( 'usces_filter_bccmail_to_admin_name', 'Shop Admin' ), |
| 1430 |
'to_address' => $usces->options['order_mail'], |
| 1431 |
'from_name' => apply_filters( 'usces_filter_bccmail_from_admin_name', 'Welcart Auto BCC' ), |
| 1432 |
'from_address' => $usces->options['sender_mail'], |
| 1433 |
'reply_name' => get_option( 'blogname' ), |
| 1434 |
'reply_to' => usces_get_first_order_mail(), |
| 1435 |
'return_path' => $usces->options['error_mail'], |
| 1436 |
'subject' => $bcc_subject, |
| 1437 |
'message' => $message, |
| 1438 |
'headers' => $headers, |
| 1439 |
'attachments' => $attachments, |
| 1440 |
); |
| 1441 |
|
| 1442 |
$bcc_para = apply_filters( 'usces_ajax_send_mail_para_to_manager', $bcc_para ); |
| 1443 |
|
| 1444 |
$res2 = usces_send_mail( $bcc_para ); |
| 1445 |
|
| 1446 |
do_action( 'usces_action_ajax_after_send_mail_to_manager', $res2, $bcc_para ); |
| 1447 |
|
| 1448 |
// delete file attach. |
| 1449 |
if ( $attachments ) { |
| 1450 |
wp_delete_file( $attachments ); |
| 1451 |
} |
| 1452 |
return 'success'; |
| 1453 |
} else { |
| 1454 |
// delete file attach. |
| 1455 |
if ( $attachments ) { |
| 1456 |
wp_delete_file( $attachments ); |
| 1457 |
} |
| 1458 |
return 'error'; |
| 1459 |
} |
| 1460 |
} |
| 1461 |
|
| 1462 |
/** |
| 1463 |
* Handle get file upload move to folder |
| 1464 |
* |
| 1465 |
* @param array $file the array file information. |
| 1466 |
* @param array $folder_move the folder file need move to. |
| 1467 |
* @return string|null file path after move. |
| 1468 |
*/ |
| 1469 |
function usces_upload_file_attach( $file, $folder_move ) { |
| 1470 |
$upload_dir = wp_upload_dir(); |
| 1471 |
if ( ! empty( $upload_dir['basedir'] ) ) { |
| 1472 |
$user_dirname = $upload_dir['basedir'] . '/' . $folder_move; |
| 1473 |
if ( ! file_exists( $user_dirname ) ) { |
| 1474 |
wp_mkdir_p( $user_dirname ); |
| 1475 |
} |
| 1476 |
|
| 1477 |
$filename = wp_unique_filename( $user_dirname, $file['name'] ); |
| 1478 |
$filepath = $user_dirname . '/' . $filename; |
| 1479 |
$is_move = move_uploaded_file( $file['tmp_name'], $filepath ); |
| 1480 |
if ( $is_move ) { |
| 1481 |
return $filepath; |
| 1482 |
} |
| 1483 |
} |
| 1484 |
return null; |
| 1485 |
} |
| 1486 |
|
| 1487 |
/** |
| 1488 |
* Check email attach file matching with rule option (File extension, File size) setting on page E-mail Setting |
| 1489 |
* |
| 1490 |
* @param array $file the array file information. |
| 1491 |
* @return boolean type of outputters. |
| 1492 |
*/ |
| 1493 |
function usces_check_validate_attach_file( $file ) { |
| 1494 |
global $usces; |
| 1495 |
|
| 1496 |
$email_attach_file_extension = wel_email_attach_file_extension( explode( ',', strtolower( $usces->options['email_attach_file_extension'] ) ) ); |
| 1497 |
$email_attach_file_size = (int) $usces->options['email_attach_file_size']; |
| 1498 |
$err_max_file_size = false; |
| 1499 |
$err_max_file_extension = false; |
| 1500 |
// check max file size. |
| 1501 |
if ( $email_attach_file_size > 0 && isset( $file['size'] ) && $file['size'] > ( $email_attach_file_size * 1000000 ) ) { |
| 1502 |
$err_max_file_size = true; |
| 1503 |
} |
| 1504 |
// check file extension. |
| 1505 |
if ( count( $email_attach_file_extension ) > 0 && isset( $file['name'] ) && ! empty( $file['name'] ) ) { |
| 1506 |
$arr_file_name = explode( '.', $file['name'] ); |
| 1507 |
$count_arr_file = count( $arr_file_name ); |
| 1508 |
if ( $count_arr_file > 1 ) { |
| 1509 |
$file_extention = strtolower( $arr_file_name[ $count_arr_file - 1 ] ); |
| 1510 |
if ( ! in_array( $file_extention, $email_attach_file_extension ) ) { |
| 1511 |
$err_max_file_extension = true; |
| 1512 |
} |
| 1513 |
} else { |
| 1514 |
$err_max_file_extension = true; |
| 1515 |
} |
| 1516 |
} |
| 1517 |
|
| 1518 |
if ( $err_max_file_size || $err_max_file_extension ) { |
| 1519 |
return false; |
| 1520 |
} |
| 1521 |
return true; |
| 1522 |
} |
| 1523 |
|
| 1524 |
/** |
| 1525 |
* Whether HTML email options are enabled |
| 1526 |
* |
| 1527 |
* @return boolean |
| 1528 |
*/ |
| 1529 |
function usces_is_html_mail() { |
| 1530 |
global $usces; |
| 1531 |
|
| 1532 |
if ( isset( $usces->options['add_html_email_option'] ) && 1 === (int) $usces->options['add_html_email_option'] ) { |
| 1533 |
return true; |
| 1534 |
} else { |
| 1535 |
return false; |
| 1536 |
} |
| 1537 |
} |
| 1538 |
|
| 1539 |
/** |
| 1540 |
* Send inquiry mail |
| 1541 |
* |
| 1542 |
* @return bool |
| 1543 |
*/ |
| 1544 |
function usces_send_inquirymail() { |
| 1545 |
global $usces; |
| 1546 |
|
| 1547 |
$_POST = $usces->stripslashes_deep_post( $_POST ); |
| 1548 |
$res = false; |
| 1549 |
$mail_data = usces_mail_data(); |
| 1550 |
$inq_name = trim( $_POST['inq_name'] ); |
| 1551 |
$inq_contents = trim( $_POST['inq_contents'] ); |
| 1552 |
$inq_mailaddress = trim( $_POST['inq_mailaddress'] ); |
| 1553 |
$reserve = ''; |
| 1554 |
if ( isset( $_POST['reserve'] ) ) { |
| 1555 |
foreach ( $_POST['reserve'] as $key => $value ) { |
| 1556 |
$reserve .= $key . ' : ' . $value . "\r\n"; |
| 1557 |
} |
| 1558 |
} |
| 1559 |
$mats = compact( 'inq_name', 'inq_contents', 'inq_mailaddress', 'reserve', 'mail_data' ); |
| 1560 |
$subject = apply_filters( 'usces_filter_inquiry_subject_to_customer', $mail_data['title']['inquiry'], $mats ); |
| 1561 |
$message = apply_filters( 'usces_filter_inquiry_header', $mail_data['header']['inquiry'], $inq_name, $inq_mailaddress ) . "\r\n\r\n"; |
| 1562 |
$message .= apply_filters( 'usces_filter_inquiry_reserve', $reserve, $inq_name, $inq_mailaddress ); |
| 1563 |
$message .= apply_filters( 'usces_filter_inq_contents', $inq_contents, $inq_name, $inq_mailaddress ) . "\r\n\r\n"; |
| 1564 |
$message .= apply_filters( 'usces_filter_inq_footer', $mail_data['footer']['inquiry'], $inq_name, $inq_mailaddress ); |
| 1565 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 1566 |
$message = sprintf( __( 'Dear %s', 'usces' ), $inq_name ) . "\r\n\r\n" . $message; |
| 1567 |
} |
| 1568 |
do_action( 'usces_action_presend_inquiry_mail', $message, $inq_name, $inq_mailaddress ); |
| 1569 |
$para1 = array( |
| 1570 |
'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $inq_name ), |
| 1571 |
'to_address' => $inq_mailaddress, |
| 1572 |
'from_name' => get_option( 'blogname' ), |
| 1573 |
'from_address' => $usces->options['sender_mail'], |
| 1574 |
'reply_name' => get_option( 'blogname' ), |
| 1575 |
'reply_to' => usces_get_first_order_mail(), |
| 1576 |
'return_path' => $usces->options['error_mail'], |
| 1577 |
'subject' => $subject, |
| 1578 |
'message' => do_shortcode( $message ), |
| 1579 |
); |
| 1580 |
$para1 = apply_filters( 'usces_send_inquirymail_para_to_customer', $para1, $mats ); |
| 1581 |
$res0 = usces_send_mail( $para1 ); |
| 1582 |
|
| 1583 |
if ( $res0 ) { |
| 1584 |
// translators: %s: name of user. |
| 1585 |
$subject = apply_filters( 'usces_filter_inquiry_subject_to_manager', __( '** An inquiry **', 'usces' ) . '(' . sprintf( _x( '%s', 'honorific', 'usces' ), $inq_name ) . ')', $mats ); |
| 1586 |
$message = $reserve . $_POST['inq_contents'] . "\r\n" |
| 1587 |
. "\r\n" . __( "Sender's e-mail address", 'usces' ) . ' : ' . $inq_mailaddress . "\r\n" |
| 1588 |
. "\r\n----------------------------------------------------\r\n" |
| 1589 |
. 'REMOTE_ADDR : ' . $_SERVER['REMOTE_ADDR'] |
| 1590 |
. "\r\n----------------------------------------------------\r\n"; |
| 1591 |
$para2 = array( |
| 1592 |
'to_name' => __( 'An inquiry email', 'usces' ), |
| 1593 |
'to_address' => $usces->options['inquiry_mail'], |
| 1594 |
'from_name' => get_option( 'blogname' ), |
| 1595 |
'from_address' => $usces->options['sender_mail'], |
| 1596 |
'reply_name' => get_option( 'blogname' ), |
| 1597 |
'reply_to' => usces_get_first_order_mail(), |
| 1598 |
'return_path' => $usces->options['error_mail'], |
| 1599 |
'subject' => $subject, |
| 1600 |
'message' => do_shortcode( $message ), |
| 1601 |
); |
| 1602 |
$para2 = apply_filters( 'usces_send_inquirymail_para_to_manager', $para2, $mats ); |
| 1603 |
// sleep( 1 ); |
| 1604 |
$res = usces_send_mail( $para2 ); |
| 1605 |
do_action( 'usces_action_aftersend_inquiry_mail', $message, $inq_name, $inq_mailaddress ); |
| 1606 |
} |
| 1607 |
|
| 1608 |
return $res; |
| 1609 |
} |
| 1610 |
|
| 1611 |
/** |
| 1612 |
* Notification email of enrollment completion. |
| 1613 |
* |
| 1614 |
* @param array $user info of user. |
| 1615 |
* @return text : mail ful text |
| 1616 |
*/ |
| 1617 |
function usces_send_regmembermail( $user ) { |
| 1618 |
global $usces; |
| 1619 |
|
| 1620 |
$res = false; |
| 1621 |
$mail_data = usces_mail_data(); |
| 1622 |
$newmem_admin_mail = $usces->options['newmem_admin_mail']; |
| 1623 |
|
| 1624 |
$user_id = isset( $user['ID'] ) ? $user['ID'] : 0; |
| 1625 |
// translators: %s: name of user. |
| 1626 |
$name = sprintf( _x( '%s', 'honorific', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1627 |
$mailaddress1 = isset( $user['mailaddress1'] ) ? trim( $user['mailaddress1'] ) : ''; |
| 1628 |
|
| 1629 |
$subject = $mail_data['title']['membercomp']; |
| 1630 |
$headers = ''; |
| 1631 |
$hook_args = array( |
| 1632 |
'user' => $user, |
| 1633 |
'name' => $name, |
| 1634 |
'mailaddress1' => $mailaddress1, |
| 1635 |
); |
| 1636 |
|
| 1637 |
if ( usces_is_html_mail() ) { |
| 1638 |
$headers = 'Content-Type: text/html'; |
| 1639 |
|
| 1640 |
$msg_body = usces_get_regmembermail_htmlbody( $hook_args ); |
| 1641 |
|
| 1642 |
$message = '<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tbody><tr><td>'; |
| 1643 |
$message .= '<table style="font-size:15px; margin:30px auto;" border="0" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody>'; |
| 1644 |
|
| 1645 |
// add header. |
| 1646 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1647 |
$m_header = $mail_data['header']['membercomp']; |
| 1648 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 1649 |
// translators: %s: name of user. |
| 1650 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1651 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 1652 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 1653 |
} else { |
| 1654 |
$message .= $dear_name . '<br>'; |
| 1655 |
} |
| 1656 |
} |
| 1657 |
$message .= do_shortcode( wpautop( $m_header ) ); |
| 1658 |
$message .= '</td></tr>'; |
| 1659 |
// add body. |
| 1660 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1661 |
$message .= $msg_body; |
| 1662 |
$message .= '</td></tr>'; |
| 1663 |
// add footer. |
| 1664 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1665 |
$message .= do_shortcode( wpautop( $mail_data['footer']['membercomp'] ) ); |
| 1666 |
$message .= '</td></tr>'; |
| 1667 |
$message .= '</tbody></table>'; |
| 1668 |
$message .= '</td></tr></tbody></table>'; |
| 1669 |
} else { |
| 1670 |
$msg_body = usces_get_regmembermail_textbody( $hook_args ); |
| 1671 |
$message = ''; |
| 1672 |
$m_header = $mail_data['header']['membercomp']; |
| 1673 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 1674 |
// translators: %s: name of user. |
| 1675 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1676 |
if ( false !== strpos( $m_header, '{customer_name}' ) ) { |
| 1677 |
$m_header = str_replace( '{customer_name}', $dear_name, $m_header ); |
| 1678 |
} else { |
| 1679 |
$message .= $dear_name . "\r\n\r\n"; |
| 1680 |
} |
| 1681 |
} |
| 1682 |
$message .= $m_header; |
| 1683 |
$message .= $msg_body; |
| 1684 |
$message .= $mail_data['footer']['membercomp']; |
| 1685 |
} |
| 1686 |
$message = apply_filters( 'usces_filter_send_regmembermail_message', $message, $user ); |
| 1687 |
|
| 1688 |
$para1 = array( |
| 1689 |
'to_name' => $name, |
| 1690 |
'to_address' => $mailaddress1, |
| 1691 |
'from_name' => get_option( 'blogname' ), |
| 1692 |
'from_address' => $usces->options['sender_mail'], |
| 1693 |
'reply_name' => get_option( 'blogname' ), |
| 1694 |
'reply_to' => usces_get_first_order_mail(), |
| 1695 |
'return_path' => $usces->options['error_mail'], |
| 1696 |
'subject' => $subject, |
| 1697 |
'message' => do_shortcode( $message ), |
| 1698 |
'headers' => $headers, |
| 1699 |
); |
| 1700 |
$para1 = apply_filters( 'usces_filter_send_regmembermail_para1', $para1 ); |
| 1701 |
$res = usces_send_mail( $para1 ); |
| 1702 |
|
| 1703 |
if ( $newmem_admin_mail ) { |
| 1704 |
$subject = __( 'New sign-in processing was completed.', 'usces' ); |
| 1705 |
|
| 1706 |
if ( usces_is_html_mail() ) { |
| 1707 |
$message = '<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#eeeeee"><tbody><tr><td>'; |
| 1708 |
$message .= '<table style="font-size:15px; margin:30px auto;" border="0" width="600" cellspacing="0" cellpadding="0" align="center" bgcolor="#ffffff"><tbody>'; |
| 1709 |
|
| 1710 |
// add header. |
| 1711 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1712 |
$message .= __( 'New sign-in processing was completed.', 'usces' ); |
| 1713 |
$message .= '</td></tr>'; |
| 1714 |
// add body. |
| 1715 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1716 |
$message .= $msg_body; |
| 1717 |
$message .= '</td></tr>'; |
| 1718 |
// add footer. |
| 1719 |
$message .= '<tr><td style="padding:20px 30px;">'; |
| 1720 |
$message .= do_shortcode( wpautop( $mail_data['footer']['membercomp'] ) ); |
| 1721 |
$message .= '</td></tr>'; |
| 1722 |
$message .= '</tbody></table>'; |
| 1723 |
$message .= '</td></tr></tbody></table>'; |
| 1724 |
} else { |
| 1725 |
$msg_body = usces_get_regmembermail_textbody( $hook_args ); |
| 1726 |
$message = __( 'New sign-in processing was completed.', 'usces' ) . "\r\n\r\n"; |
| 1727 |
$message .= $msg_body; |
| 1728 |
} |
| 1729 |
|
| 1730 |
$message = apply_filters( 'usces_filter_send_regmembermail_notice', $message, $user ); |
| 1731 |
|
| 1732 |
$para2 = array( |
| 1733 |
'to_name' => __( 'Notice of new sign-in', 'usces' ), |
| 1734 |
'to_address' => $usces->options['order_mail'], |
| 1735 |
'from_name' => get_option( 'blogname' ), |
| 1736 |
'from_address' => $usces->options['sender_mail'], |
| 1737 |
'reply_name' => get_option( 'blogname' ), |
| 1738 |
'reply_to' => usces_get_first_order_mail(), |
| 1739 |
'return_path' => $usces->options['error_mail'], |
| 1740 |
'subject' => $subject, |
| 1741 |
'message' => do_shortcode( $message ), |
| 1742 |
'headers' => $headers, |
| 1743 |
); |
| 1744 |
$para2 = apply_filters( 'usces_filter_send_regmembermail_para2', $para2 ); |
| 1745 |
usces_send_mail( $para2 ); |
| 1746 |
} |
| 1747 |
|
| 1748 |
return $res; |
| 1749 |
} |
| 1750 |
|
| 1751 |
/** |
| 1752 |
* Notification email html of enrollment completion. |
| 1753 |
* |
| 1754 |
* @param array $hook_args info data. |
| 1755 |
* @return text : mail full text |
| 1756 |
*/ |
| 1757 |
function usces_get_regmembermail_htmlbody( $hook_args ) { |
| 1758 |
$user = isset( $hook_args['user'] ) ? $hook_args['user'] : array(); |
| 1759 |
$name = isset( $hook_args['name'] ) ? $hook_args['name'] : ''; |
| 1760 |
$mailaddress1 = isset( $hook_args['mailaddress1'] ) ? $hook_args['mailaddress1'] : ''; |
| 1761 |
$user_id = isset( $user['ID'] ) ? $user['ID'] : 0; |
| 1762 |
|
| 1763 |
$message = '<hr style="margin: 0 0 50px; border-style: none; border-top: 3px solid #777;" />'; |
| 1764 |
$message .= '<table style="font-size: 14px; margin-bottom: 30px; width: 100%; border-collapse: collapse; border: 1px solid #ddd;">'; |
| 1765 |
$message .= '<caption style="background-color: #111; margin-bottom: 40px; padding: 15px; color: #fff; font-size: 15px; font-weight: 700; text-align: left;">'; |
| 1766 |
$message .= __( 'Registration contents', 'usces' ); |
| 1767 |
$message .= '</caption>'; |
| 1768 |
$message .= '<tbody><tr>'; |
| 1769 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'Member ID', 'usces' ) . '</td>'; |
| 1770 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . esc_attr( $user_id ) . '</td>'; |
| 1771 |
$message .= '</tr><tr>'; |
| 1772 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'Name', 'usces' ) . '</td>'; |
| 1773 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . esc_attr( $name ) . '</td>'; |
| 1774 |
$message .= '</tr><tr>'; |
| 1775 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . __( 'e-mail adress', 'usces' ) . '</td>'; |
| 1776 |
$message .= '<td style="padding: 12px; width: 50%; border: 1px solid #ddd;">' . esc_attr( $mailaddress1 ) . '</td>'; |
| 1777 |
$message .= '</tr></tbody>'; |
| 1778 |
$message .= '</table>'; |
| 1779 |
$message .= '<hr style="margin: 50px 0 0; border-style: none; border-top: 3px solid #777;" />'; |
| 1780 |
|
| 1781 |
return $message; |
| 1782 |
} |
| 1783 |
|
| 1784 |
/** |
| 1785 |
* Notification email text of enrollment completion. |
| 1786 |
* |
| 1787 |
* @param array $hook_args info data. |
| 1788 |
* @return text : mail full text |
| 1789 |
*/ |
| 1790 |
function usces_get_regmembermail_textbody( $hook_args ) { |
| 1791 |
$user = isset( $hook_args['user'] ) ? $hook_args['user'] : array(); |
| 1792 |
$name = isset( $hook_args['name'] ) ? $hook_args['name'] : ''; |
| 1793 |
$mailaddress1 = isset( $hook_args['mailaddress1'] ) ? $hook_args['mailaddress1'] : ''; |
| 1794 |
$user_id = isset( $user['ID'] ) ? $user['ID'] : 0; |
| 1795 |
|
| 1796 |
$message = __( 'Registration contents', 'usces' ) . "\r\n"; |
| 1797 |
$message .= '--------------------------------' . "\r\n"; |
| 1798 |
$message .= __( 'Member ID', 'usces' ) . ' : ' . esc_attr( $user_id ) . "\r\n"; |
| 1799 |
$message .= __( 'Name', 'usces' ) . ' : ' . esc_attr( $name ) . "\r\n"; |
| 1800 |
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . esc_attr( $mailaddress1 ) . "\r\n"; |
| 1801 |
$message .= '--------------------------------' . "\r\n\r\n"; |
| 1802 |
|
| 1803 |
return $message; |
| 1804 |
} |
| 1805 |
|
| 1806 |
/** |
| 1807 |
* Notification email text update info of user. |
| 1808 |
* |
| 1809 |
* @param array $user info data. |
| 1810 |
*/ |
| 1811 |
function usces_send_updmembermail( $user ) { |
| 1812 |
global $usces; |
| 1813 |
$updmem_admin_mail = $usces->options['updmem_admin_mail']; |
| 1814 |
$updmem_customer_mail = $usces->options['updmem_customer_mail']; |
| 1815 |
if ( ! $updmem_admin_mail && ! $updmem_customer_mail ) { |
| 1816 |
return; |
| 1817 |
} |
| 1818 |
|
| 1819 |
// $mail_data = usces_mail_data(); |
| 1820 |
// translators: %s: name of user. |
| 1821 |
$name = sprintf( _x( '%s', 'honorific', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1822 |
$mailaddress1 = trim( $user['mailaddress1'] ); |
| 1823 |
$subject = apply_filters( 'usces_filter_send_updmembermail_subject', __( 'Member update processing was completed.', 'usces' ), $user ); |
| 1824 |
|
| 1825 |
if ( $updmem_customer_mail ) { |
| 1826 |
$message = $subject . "\r\n\r\n"; |
| 1827 |
$message .= __( 'Registration contents', 'usces' ) . "\r\n"; |
| 1828 |
$message .= '--------------------------------' . "\r\n"; |
| 1829 |
$message .= __( 'Member ID', 'usces' ) . ' : ' . $user['ID'] . "\r\n"; |
| 1830 |
$message .= __( 'Name', 'usces' ) . ' : ' . $name . "\r\n"; |
| 1831 |
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . $mailaddress1 . "\r\n"; |
| 1832 |
$message .= '--------------------------------' . "\r\n\r\n"; |
| 1833 |
$message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n"; |
| 1834 |
$message .= html_entity_decode( get_option( 'blogname' ) ) . "\r\n"; |
| 1835 |
// $message .= $mail_data['footer']['membercomp']; |
| 1836 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 1837 |
// translators: %s: name of user. |
| 1838 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1839 |
$message = $dear_name . "\r\n\r\n" . $message; |
| 1840 |
} |
| 1841 |
$message = apply_filters( 'usces_filter_send_updmembermail_message', $message, $user ); |
| 1842 |
|
| 1843 |
$para1 = array( |
| 1844 |
'to_name' => $name, |
| 1845 |
'to_address' => $mailaddress1, |
| 1846 |
'from_name' => get_option( 'blogname' ), |
| 1847 |
'from_address' => $usces->options['sender_mail'], |
| 1848 |
'reply_name' => get_option( 'blogname' ), |
| 1849 |
'reply_to' => usces_get_first_order_mail(), |
| 1850 |
'return_path' => $usces->options['error_mail'], |
| 1851 |
'subject' => $subject, |
| 1852 |
'message' => do_shortcode( $message ), |
| 1853 |
); |
| 1854 |
$para1 = apply_filters( 'usces_filter_send_updmembermail_para1', $para1 ); |
| 1855 |
usces_send_mail( $para1 ); |
| 1856 |
} |
| 1857 |
|
| 1858 |
if ( $updmem_admin_mail ) { |
| 1859 |
$message = $subject . "\r\n\r\n"; |
| 1860 |
$message .= __( 'Registration contents', 'usces' ) . "\r\n"; |
| 1861 |
$message .= '--------------------------------' . "\r\n"; |
| 1862 |
$message .= __( 'Member ID', 'usces' ) . ' : ' . $user['ID'] . "\r\n"; |
| 1863 |
$message .= __( 'Name', 'usces' ) . ' : ' . $name . "\r\n"; |
| 1864 |
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . $mailaddress1 . "\r\n"; |
| 1865 |
$message .= '--------------------------------' . "\r\n\r\n"; |
| 1866 |
$message = apply_filters( 'usces_filter_send_updmembermail_notice', $message, $user ); |
| 1867 |
|
| 1868 |
$para2 = array( |
| 1869 |
'to_name' => __( 'Notice of new sign-in', 'usces' ), |
| 1870 |
'to_address' => $usces->options['order_mail'], |
| 1871 |
'from_name' => get_option( 'blogname' ), |
| 1872 |
'from_address' => $usces->options['sender_mail'], |
| 1873 |
'reply_name' => get_option( 'blogname' ), |
| 1874 |
'reply_to' => usces_get_first_order_mail(), |
| 1875 |
'return_path' => $usces->options['error_mail'], |
| 1876 |
'subject' => $subject, |
| 1877 |
'message' => do_shortcode( $message ), |
| 1878 |
); |
| 1879 |
$para2 = apply_filters( 'usces_filter_send_updmembermail_para2', $para2 ); |
| 1880 |
usces_send_mail( $para2 ); |
| 1881 |
} |
| 1882 |
} |
| 1883 |
|
| 1884 |
/** |
| 1885 |
* Notification email html of delete member. |
| 1886 |
* |
| 1887 |
* @param array $user info data. |
| 1888 |
*/ |
| 1889 |
function usces_send_delmembermail( $user ) { |
| 1890 |
global $usces; |
| 1891 |
$delmem_admin_mail = $usces->options['delmem_admin_mail']; |
| 1892 |
$delmem_customer_mail = $usces->options['delmem_customer_mail']; |
| 1893 |
if ( ! $delmem_admin_mail && ! $delmem_customer_mail ) { |
| 1894 |
return; |
| 1895 |
} |
| 1896 |
|
| 1897 |
// $mail_data = usces_mail_data(); |
| 1898 |
// translators: %s: name of user. |
| 1899 |
$name = sprintf( _x( '%s', 'honorific', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1900 |
$mailaddress1 = trim( $user['mailaddress1'] ); |
| 1901 |
$subject = apply_filters( 'usces_filter_send_delmembermail_subject', __( 'Member removal processing was completed.', 'usces' ), $user ); |
| 1902 |
|
| 1903 |
if ( $delmem_customer_mail ) { |
| 1904 |
$message = $subject . "\r\n\r\n"; |
| 1905 |
// $message .= __( 'Registration contents', 'usces' ) . "\r\n"; |
| 1906 |
$message .= '--------------------------------' . "\r\n"; |
| 1907 |
$message .= __( 'Member ID', 'usces' ) . ' : ' . $user['ID'] . "\r\n"; |
| 1908 |
$message .= __( 'Name', 'usces' ) . ' : ' . $name . "\r\n"; |
| 1909 |
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . $mailaddress1 . "\r\n"; |
| 1910 |
$message .= '--------------------------------' . "\r\n\r\n"; |
| 1911 |
$message .= __( 'If you have not requested this email, sorry to trouble you, but please contact us.', 'usces' ) . "\r\n\r\n"; |
| 1912 |
$message .= html_entity_decode( get_option( 'blogname' ) ) . "\r\n"; |
| 1913 |
// $message .= $mail_data['footer']['membercomp']; |
| 1914 |
if ( 1 === (int) $usces->options['put_customer_name'] ) { |
| 1915 |
// translators: %s: name of user. |
| 1916 |
$dear_name = sprintf( __( 'Dear %s', 'usces' ), usces_localized_name( trim( $user['name1'] ), trim( $user['name2'] ), 'return' ) ); |
| 1917 |
$message = $dear_name . "\r\n\r\n" . $message; |
| 1918 |
} |
| 1919 |
$message = apply_filters( 'usces_filter_send_delmembermail_message', $message, $user ); |
| 1920 |
|
| 1921 |
$para1 = array( |
| 1922 |
'to_name' => $name, |
| 1923 |
'to_address' => $mailaddress1, |
| 1924 |
'from_name' => get_option( 'blogname' ), |
| 1925 |
'from_address' => $usces->options['sender_mail'], |
| 1926 |
'reply_name' => get_option( 'blogname' ), |
| 1927 |
'reply_to' => usces_get_first_order_mail(), |
| 1928 |
'return_path' => $usces->options['error_mail'], |
| 1929 |
'subject' => $subject, |
| 1930 |
'message' => do_shortcode( $message ), |
| 1931 |
); |
| 1932 |
$para1 = apply_filters( 'usces_filter_send_delmembermail_para1', $para1 ); |
| 1933 |
usces_send_mail( $para1 ); |
| 1934 |
} |
| 1935 |
|
| 1936 |
if ( $delmem_admin_mail ) { |
| 1937 |
$message = $subject . "\r\n\r\n"; |
| 1938 |
// $message .= __( 'Registration contents', 'usces' ) . "\r\n"; |
| 1939 |
$message .= '--------------------------------' . "\r\n"; |
| 1940 |
$message .= __( 'Member ID', 'usces' ) . ' : ' . $user['ID'] . "\r\n"; |
| 1941 |
$message .= __( 'Name', 'usces' ) . ' : ' . $name . "\r\n"; |
| 1942 |
$message .= __( 'e-mail adress', 'usces' ) . ' : ' . $mailaddress1 . "\r\n"; |
| 1943 |
$message .= '--------------------------------' . "\r\n\r\n"; |
| 1944 |
$message = apply_filters( 'usces_filter_send_delmembermail_notice', $message, $user ); |
| 1945 |
|
| 1946 |
$para2 = array( |
| 1947 |
'to_name' => __( 'Notice of new sign-in', 'usces' ), |
| 1948 |
'to_address' => $usces->options['order_mail'], |
| 1949 |
'from_name' => get_option( 'blogname' ), |
| 1950 |
'from_address' => $usces->options['sender_mail'], |
| 1951 |
'reply_name' => get_option( 'blogname' ), |
| 1952 |
'reply_to' => usces_get_first_order_mail(), |
| 1953 |
'return_path' => $usces->options['error_mail'], |
| 1954 |
'subject' => $subject, |
| 1955 |
'message' => do_shortcode( $message ), |
| 1956 |
); |
| 1957 |
$para2 = apply_filters( 'usces_filter_send_delmembermail_para2', $para2 ); |
| 1958 |
usces_send_mail( $para2 ); |
| 1959 |
} |
| 1960 |
} |
| 1961 |
|
| 1962 |
/** |
| 1963 |
* Email template user lost mail. |
| 1964 |
* |
| 1965 |
* @param string $url change password. |
| 1966 |
* @return string Return page. |
| 1967 |
*/ |
| 1968 |
function usces_lostmail( $url ) { |
| 1969 |
global $usces; |
| 1970 |
$res = false; |
| 1971 |
|
| 1972 |
if ( isset( $_REQUEST['loginmail'] ) && ! empty( $_REQUEST['loginmail'] ) ) { |
| 1973 |
|
| 1974 |
$usces_lostmail = $_REQUEST['loginmail']; |
| 1975 |
// $mail_data = usces_mail_data(); |
| 1976 |
$subject = apply_filters( 'usces_filter_lostmail_subject', __( 'Change password', 'usces' ) ); |
| 1977 |
$message = __( 'Please, click the following URL, and please change a password.', 'usces' ) . "\r\n\r\n\r\n" |
| 1978 |
. $url . "\r\n\r\n\r\n" |
| 1979 |
. "-----------------------------------------------------\r\n" |
| 1980 |
. __( 'If you have not requested this email please kindly ignore and delete it.', 'usces' ) . "\r\n" |
| 1981 |
. "-----------------------------------------------------\r\n\r\n\r\n"; |
| 1982 |
$message = apply_filters( 'usces_filter_lostmail_message', $message, $url ); |
| 1983 |
$message .= apply_filters( 'usces_filter_lostmail_footer', get_option( 'blogname' ) . "\r\n" ); |
| 1984 |
|
| 1985 |
$para1 = array( |
| 1986 |
'to_name' => sprintf( _x( '%s', 'honorific', 'usces' ), $usces_lostmail ), |
| 1987 |
'to_address' => $usces_lostmail, |
| 1988 |
'from_name' => get_option( 'blogname' ), |
| 1989 |
'from_address' => $usces->options['sender_mail'], |
| 1990 |
'reply_name' => get_option( 'blogname' ), |
| 1991 |
'reply_to' => usces_get_first_order_mail(), |
| 1992 |
'return_path' => $usces->options['error_mail'], |
| 1993 |
'subject' => $subject, |
| 1994 |
'message' => do_shortcode( $message ), |
| 1995 |
); |
| 1996 |
|
| 1997 |
$para1 = apply_filters( 'usces_filter_send_lostmail_para1', $para1 ); |
| 1998 |
$res = usces_send_mail( $para1 ); |
| 1999 |
} |
| 2000 |
|
| 2001 |
if ( false === $res ) { |
| 2002 |
$usces->error_message = __( 'Error: I was not able to transmit an email.', 'usces' ); |
| 2003 |
$page = 'lostmemberpassword'; |
| 2004 |
} else { |
| 2005 |
$page = 'lostcompletion'; |
| 2006 |
} |
| 2007 |
|
| 2008 |
return $page; |
| 2009 |
} |
| 2010 |
|
| 2011 |
/** |
| 2012 |
* Custom field information |
| 2013 |
* |
| 2014 |
* @param string $custom_field Field type. |
| 2015 |
* @param string $position Field position. |
| 2016 |
* @param int $id Order ID. |
| 2017 |
* @param string $mailaddress Mail address. |
| 2018 |
* @return string |
| 2019 |
*/ |
| 2020 |
function usces_mail_custom_field_info( $custom_field, $position, $id, $mailaddress = '' ) { |
| 2021 |
global $usces; |
| 2022 |
|
| 2023 |
$msg_body = ''; |
| 2024 |
switch ( $custom_field ) { |
| 2025 |
case 'order': |
| 2026 |
$field = 'usces_custom_order_field'; |
| 2027 |
$cs = 'csod_'; |
| 2028 |
break; |
| 2029 |
case 'customer': |
| 2030 |
$field = 'usces_custom_customer_field'; |
| 2031 |
$cs = 'cscs_'; |
| 2032 |
break; |
| 2033 |
case 'delivery': |
| 2034 |
$field = 'usces_custom_delivery_field'; |
| 2035 |
$cs = 'csde_'; |
| 2036 |
break; |
| 2037 |
case 'member': |
| 2038 |
$field = 'usces_custom_member_field'; |
| 2039 |
$cs = 'csmb_'; |
| 2040 |
break; |
| 2041 |
default: |
| 2042 |
return $msg_body; |
| 2043 |
} |
| 2044 |
|
| 2045 |
$meta = usces_has_custom_field_meta( $custom_field ); |
| 2046 |
|
| 2047 |
if ( ! empty( $meta ) && is_array( $meta ) ) { |
| 2048 |
$keys = array_keys( $meta ); |
| 2049 |
|
| 2050 |
if ( usces_is_html_mail() ) { |
| 2051 |
|
| 2052 |
switch ( $custom_field ) { |
| 2053 |
case 'order': |
| 2054 |
foreach ( $keys as $key ) { |
| 2055 |
$value = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $cs . $key, $id ) ); |
| 2056 |
if ( is_array( $value ) ) { |
| 2057 |
$concatval = ''; |
| 2058 |
$c = ''; |
| 2059 |
foreach ( $value as $v ) { |
| 2060 |
$concatval .= $c . $v; |
| 2061 |
$c = ', '; |
| 2062 |
} |
| 2063 |
$value = $concatval; |
| 2064 |
} |
| 2065 |
$msg_body .= '<tr> |
| 2066 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . $meta[ $key ]['name'] . '</td> |
| 2067 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . esc_html( $value ) . '</td> |
| 2068 |
</tr>'; |
| 2069 |
} |
| 2070 |
break; |
| 2071 |
|
| 2072 |
case 'customer': |
| 2073 |
case 'delivery': |
| 2074 |
foreach ( $keys as $key ) { |
| 2075 |
if ( $meta[ $key ]['position'] === $position ) { |
| 2076 |
$value = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $cs . $key, $id ) ); |
| 2077 |
if ( is_array( $value ) ) { |
| 2078 |
$concatval = ''; |
| 2079 |
$c = ''; |
| 2080 |
foreach ( $value as $v ) { |
| 2081 |
$concatval .= $c . $v; |
| 2082 |
$c = ', '; |
| 2083 |
} |
| 2084 |
$value = $concatval; |
| 2085 |
} |
| 2086 |
$msg_body .= '<tr> |
| 2087 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . $meta[ $key ]['name'] . '</td> |
| 2088 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . esc_html( $value ) . '</td> |
| 2089 |
</tr>'; |
| 2090 |
} |
| 2091 |
} |
| 2092 |
break; |
| 2093 |
|
| 2094 |
case 'member': |
| 2095 |
foreach ( $keys as $key ) { |
| 2096 |
if ( $meta[ $key ]['position'] === $position ) { |
| 2097 |
$value = wel_safe_maybe_unserialize( $usces->get_member_meta_value( $cs . $key, $id ) ); |
| 2098 |
if ( is_array( $value ) ) { |
| 2099 |
$concatval = ''; |
| 2100 |
$c = ''; |
| 2101 |
foreach ( $value as $v ) { |
| 2102 |
$concatval .= $c . $v; |
| 2103 |
$c = ', '; |
| 2104 |
} |
| 2105 |
$value = $concatval; |
| 2106 |
} |
| 2107 |
$msg_body .= '<tr> |
| 2108 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . $meta[ $key ]['name'] . '</td> |
| 2109 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . esc_html( $value ) . '</td> |
| 2110 |
</tr>'; |
| 2111 |
} |
| 2112 |
} |
| 2113 |
break; |
| 2114 |
} |
| 2115 |
|
| 2116 |
} else { |
| 2117 |
|
| 2118 |
switch ( $custom_field ) { |
| 2119 |
case 'order': |
| 2120 |
$msg_body .= "\r\n"; |
| 2121 |
$msg_body .= usces_mail_line( 1, $mailaddress ); |
| 2122 |
foreach ( $keys as $key ) { |
| 2123 |
$value = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $cs . $key, $id ) ); |
| 2124 |
if ( is_array( $value ) ) { |
| 2125 |
$concatval = ''; |
| 2126 |
$c = ''; |
| 2127 |
foreach ( $value as $v ) { |
| 2128 |
$concatval .= $c . $v; |
| 2129 |
$c = ', '; |
| 2130 |
} |
| 2131 |
$value = $concatval; |
| 2132 |
} |
| 2133 |
$msg_body .= $meta[ $key ]['name'] . ' : ' . $value . "\r\n"; |
| 2134 |
} |
| 2135 |
$msg_body .= usces_mail_line( 1, $mailaddress ); |
| 2136 |
break; |
| 2137 |
|
| 2138 |
case 'customer': |
| 2139 |
case 'delivery': |
| 2140 |
foreach ( $keys as $key ) { |
| 2141 |
if ( $meta[ $key ]['position'] === $position ) { |
| 2142 |
$value = wel_safe_maybe_unserialize( $usces->get_order_meta_value( $cs . $key, $id ) ); |
| 2143 |
if ( is_array( $value ) ) { |
| 2144 |
$concatval = ''; |
| 2145 |
$c = ''; |
| 2146 |
foreach ( $value as $v ) { |
| 2147 |
$concatval .= $c . $v; |
| 2148 |
$c = ', '; |
| 2149 |
} |
| 2150 |
$value = $concatval; |
| 2151 |
} |
| 2152 |
$msg_body .= $meta[ $key ]['name'] . ' : ' . $value . "\r\n"; |
| 2153 |
} |
| 2154 |
} |
| 2155 |
break; |
| 2156 |
|
| 2157 |
case 'member': |
| 2158 |
foreach ( $keys as $key ) { |
| 2159 |
if ( $meta[ $key ]['position'] === $position ) { |
| 2160 |
$value = wel_safe_maybe_unserialize( $usces->get_member_meta_value( $cs . $key, $id ) ); |
| 2161 |
if ( is_array( $value ) ) { |
| 2162 |
$concatval = ''; |
| 2163 |
$c = ''; |
| 2164 |
foreach ( $value as $v ) { |
| 2165 |
$concatval .= $c . $v; |
| 2166 |
$c = ', '; |
| 2167 |
} |
| 2168 |
$value = $concatval; |
| 2169 |
} |
| 2170 |
$msg_body .= $meta[ $key ]['name'] . ' : ' . $value . "\r\n"; |
| 2171 |
} |
| 2172 |
} |
| 2173 |
break; |
| 2174 |
} |
| 2175 |
} |
| 2176 |
} |
| 2177 |
$msg_body = apply_filters( 'usces_filter_mail_custom_field_info', $msg_body, $custom_field, $position, $id, $mailaddress ); |
| 2178 |
return $msg_body; |
| 2179 |
} |
| 2180 |
|
| 2181 |
/** |
| 2182 |
* Send mail |
| 2183 |
* (unused) |
| 2184 |
* |
| 2185 |
* @param array $para { |
| 2186 |
* The array of mail data. |
| 2187 |
* @type string $to_name To name. |
| 2188 |
* @type string $to_address To address. |
| 2189 |
* @type string $from_name From name. |
| 2190 |
* @type string $from_address From address. |
| 2191 |
* @type string $return_path Return path. |
| 2192 |
* @type string $subject Subject. |
| 2193 |
* @type string $message Message. |
| 2194 |
* } |
| 2195 |
* @return bool |
| 2196 |
*/ |
| 2197 |
function _usces_send_mail( $para ) { |
| 2198 |
global $usces; |
| 2199 |
|
| 2200 |
$from_name = $para['from_name']; |
| 2201 |
$from_address = $para['from_address']; |
| 2202 |
if ( false !== strpos( $para['from_address'], '..' ) || false !== strpos( $para['from_address'], '.@' ) ) { |
| 2203 |
$fname = str_replace( strstr( $para['from_address'], '@' ), '', $para['from_address'] ); |
| 2204 |
if ( '"' !== substr( $fname, 0, 1 ) && '"' !== substr( $fname, -1 ) ) { |
| 2205 |
$para['from_address'] = str_replace( $fname, '"RFC_violation"', $para['from_address'] ); |
| 2206 |
$from_name = $para['from_name'] . '(' . $from_address . ')'; |
| 2207 |
} |
| 2208 |
} |
| 2209 |
$from = htmlspecialchars( html_entity_decode( $from_name, ENT_QUOTES ), ENT_COMPAT ) . " <{$para['from_address']}>"; |
| 2210 |
$header = 'From: ' . apply_filters( 'usces_filter_send_mail_from', $from, $para ) . "\r\n"; |
| 2211 |
$header .= "Return-Path: {$para['return_path']}\r\n"; |
| 2212 |
|
| 2213 |
$subject = html_entity_decode( $para['subject'], ENT_QUOTES ); |
| 2214 |
$message = $para['message']; |
| 2215 |
|
| 2216 |
ini_set( 'SMTP', "{$usces->options['smtp_hostname']}" ); |
| 2217 |
if ( ! ini_get( 'smtp_port' ) ) { |
| 2218 |
ini_set( 'smtp_port', apply_filters( 'usces_filter_send_mail_port', 25, $para ) ); |
| 2219 |
} |
| 2220 |
ini_set( 'sendmail_from', '' ); |
| 2221 |
|
| 2222 |
$mails = explode( ',', $para['to_address'] ); |
| 2223 |
$to_mailes = array(); |
| 2224 |
foreach ( $mails as $mail ) { |
| 2225 |
if ( false !== strpos( $mail, '..' ) || false !== strpos( $mail, '.@' ) ) { |
| 2226 |
$name = str_replace( strstr( $mail, '@' ), '', $mail ); |
| 2227 |
if ( '"' !== substr( $name, 0, 1 ) && '"' !== substr( $name, -1 ) ) { |
| 2228 |
$to_mailes[] = str_replace( $name, '"' . $name . '"', $mail ); |
| 2229 |
} else { |
| 2230 |
$to_mailes[] = $mail; |
| 2231 |
} |
| 2232 |
} elseif ( is_email( trim( $mail ) ) ) { |
| 2233 |
$to_mailes[] = $mail; |
| 2234 |
} else { |
| 2235 |
$to_mailes[] = null; |
| 2236 |
} |
| 2237 |
} |
| 2238 |
|
| 2239 |
if ( ! empty( $to_mailes ) ) { |
| 2240 |
$res = @wp_mail( $to_mailes, $subject, $message, $header ); |
| 2241 |
} else { |
| 2242 |
$res = false; |
| 2243 |
} |
| 2244 |
|
| 2245 |
return $res; |
| 2246 |
} |
| 2247 |
|
| 2248 |
/** |
| 2249 |
* Send mail |
| 2250 |
* |
| 2251 |
* @param array $para { |
| 2252 |
* The array of mail data. |
| 2253 |
* @type string $to_name To name. |
| 2254 |
* @type string $to_address To address. |
| 2255 |
* @type string $from_name From name. |
| 2256 |
* @type string $from_address From address. |
| 2257 |
* @type string $reply_name Reply name. |
| 2258 |
* @type string $reply_to Reply address. |
| 2259 |
* @type string $return_path Return path. |
| 2260 |
* @type string $subject Subject. |
| 2261 |
* @type string $message Message. |
| 2262 |
* } |
| 2263 |
* @return bool |
| 2264 |
*/ |
| 2265 |
function usces_send_mail( $para ) { |
| 2266 |
global $usces; |
| 2267 |
|
| 2268 |
$header_fields = array( 'to_name', 'from_name', 'reply_name', 'subject' ); |
| 2269 |
foreach ( $header_fields as $field ) { |
| 2270 |
if ( isset( $para[ $field ] ) ) { |
| 2271 |
$para[ $field ] = usces_sanitize_email_header( $para[ $field ] ); |
| 2272 |
} |
| 2273 |
} |
| 2274 |
|
| 2275 |
$from_name = $para['from_name']; |
| 2276 |
$from_address = $para['from_address']; |
| 2277 |
|
| 2278 |
if ( strpos( $para['from_address'], '..' ) !== false || strpos( $para['from_address'], '.@' ) !== false ) { |
| 2279 |
$fname = str_replace( strstr( $para['from_address'], '@' ), '', $para['from_address'] ); |
| 2280 |
if ( '"' !== substr( $fname, 0, 1 ) && '"' !== substr( $fname, -1 ) ) { |
| 2281 |
$para['from_address'] = str_replace( $fname, '"RFC_violation"', $para['from_address'] ); |
| 2282 |
$from_name = $para['from_name'] . '(' . $from_address . ')'; |
| 2283 |
} |
| 2284 |
} |
| 2285 |
$from_name = html_entity_decode( $from_name, ENT_QUOTES ); |
| 2286 |
$from_name = mb_encode_mimeheader( $from_name ); |
| 2287 |
|
| 2288 |
$para['from_name'] = $from_name; |
| 2289 |
$para['from'] = $from_address; |
| 2290 |
|
| 2291 |
$mails = explode( ',', $para['to_address'] ); |
| 2292 |
$to_mailes = array(); |
| 2293 |
foreach ( $mails as $mail ) { |
| 2294 |
if ( is_email( trim( $mail ) ) ) { |
| 2295 |
$to_mailes[] = $mail; |
| 2296 |
} |
| 2297 |
} |
| 2298 |
|
| 2299 |
$usces->mail_para = $para; |
| 2300 |
add_action( 'phpmailer_init', 'usces_send_mail_init', 5 ); |
| 2301 |
|
| 2302 |
$subject = html_entity_decode( $para['subject'], ENT_QUOTES ); |
| 2303 |
$message = $para['message']; |
| 2304 |
$attachments = isset( $para['attachments'] ) ? $para['attachments'] : array(); |
| 2305 |
|
| 2306 |
$res = false; |
| 2307 |
foreach ( $to_mailes as $to_maile ) { |
| 2308 |
if ( strpos( $to_maile, '..' ) !== false || strpos( $to_maile, '.@' ) !== false ) { |
| 2309 |
$headers = 'From: ' . $from_address . "\r\n"; |
| 2310 |
if ( isset( $para['headers'] ) && ! empty( $para['headers'] ) ) { |
| 2311 |
$header_lines = explode( "\r\n", $para['headers'] ); |
| 2312 |
$filtered_headers = array_filter( |
| 2313 |
$header_lines, |
| 2314 |
function( $line ) { |
| 2315 |
return stripos( $line, 'Reply-To:' ) !== 0; |
| 2316 |
} |
| 2317 |
); |
| 2318 |
$headers .= implode( "\r\n", $filtered_headers ) . "\r\n"; |
| 2319 |
} |
| 2320 |
$reply_to_email = $usces->mail_para['reply_to']; |
| 2321 |
$reply_to_name = $usces->mail_para['reply_name']; |
| 2322 |
if ( ! empty( $reply_to_name ) ) { |
| 2323 |
$new_reply_to = 'Reply-To: "' . $reply_to_name . '" <' . $reply_to_email . '>' . "\r\n"; |
| 2324 |
} else { |
| 2325 |
$new_reply_to = 'Reply-To: ' . $reply_to_email . "\r\n"; |
| 2326 |
} |
| 2327 |
$headers .= $new_reply_to; |
| 2328 |
$res = @mb_send_mail( $to_maile, $subject, $message, $headers ); |
| 2329 |
} elseif ( ! empty( $to_maile ) ) { |
| 2330 |
$headers = ( ! empty( $para['headers'] ) ) ? $para['headers'] : ''; |
| 2331 |
$res = @wp_mail( $to_maile, $subject, $message, $headers, $attachments ); |
| 2332 |
} else { |
| 2333 |
$res = false; |
| 2334 |
} |
| 2335 |
} |
| 2336 |
|
| 2337 |
remove_action( 'phpmailer_init', 'usces_send_mail_init', 5 ); |
| 2338 |
$usces->mail_para = array(); |
| 2339 |
return $res; |
| 2340 |
} |
| 2341 |
|
| 2342 |
/** |
| 2343 |
* Fires after PHPMailer is initialized. |
| 2344 |
* phpmailer_init |
| 2345 |
* |
| 2346 |
* @param object $phpmailer The PHPMailer instance (passed by reference). |
| 2347 |
*/ |
| 2348 |
function usces_send_mail_init( $phpmailer ) { |
| 2349 |
global $usces; |
| 2350 |
|
| 2351 |
$from_name = apply_filters( 'usces_filter_send_mail_from', $usces->mail_para['from_name'], $usces->mail_para ); |
| 2352 |
$from_name = usces_sanitize_email_header( $from_name ); |
| 2353 |
|
| 2354 |
$phpmailer->Mailer = 'mail'; |
| 2355 |
$phpmailer->From = $usces->mail_para['from']; |
| 2356 |
$phpmailer->FromName = $from_name; |
| 2357 |
if ( ( isset( $usces->mail_para['reply_to'] ) && ! empty( $usces->mail_para['reply_to'] ) ) && ( isset( $usces->mail_para['reply_name'] ) && ! empty( $usces->mail_para['reply_name'] ) ) ) { |
| 2358 |
$phpmailer->ClearReplyTos(); |
| 2359 |
$reply_name = usces_sanitize_email_header( $usces->mail_para['reply_name'] ); |
| 2360 |
$phpmailer->addReplyTo( $usces->mail_para['reply_to'], $reply_name ); |
| 2361 |
} |
| 2362 |
if ( usces_is_html_mail() ) { |
| 2363 |
if ( 'text/html' !== trim( $phpmailer->ContentType ) ) { |
| 2364 |
$phpmailer->ContentType = 'text/html'; |
| 2365 |
$phpmailer->Body = wpautop( $phpmailer->Body ); |
| 2366 |
} |
| 2367 |
$phpmailer->isHTML( true ); |
| 2368 |
} |
| 2369 |
do_action( 'usces_filter_phpmailer_init', array( &$phpmailer ) ); |
| 2370 |
} |
| 2371 |
|
| 2372 |
/** |
| 2373 |
* Get first mail addrwess of order mail. |
| 2374 |
* |
| 2375 |
* @return string |
| 2376 |
*/ |
| 2377 |
function usces_get_first_order_mail() { |
| 2378 |
global $usces; |
| 2379 |
|
| 2380 |
$orders = explode( ',', $usces->options['order_mail'] ); |
| 2381 |
$first_order_mail = isset( $orders[0] ) ? $orders[0] : ''; |
| 2382 |
return $first_order_mail; |
| 2383 |
} |
| 2384 |
/** |
| 2385 |
* Address format |
| 2386 |
* |
| 2387 |
* @param string $type Mail type. |
| 2388 |
* @param array $data Order data. |
| 2389 |
* @param int $order_id Order ID. |
| 2390 |
* @param string $out Return value or echo. |
| 2391 |
* @return string|void |
| 2392 |
*/ |
| 2393 |
function uesces_get_mail_addressform( $type, $data, $order_id, $out = 'return' ) { |
| 2394 |
global $usces, $usces_settings; |
| 2395 |
|
| 2396 |
$options = get_option( 'usces', array() ); |
| 2397 |
$applyform = usces_get_apply_addressform( $options['system']['addressform'] ); |
| 2398 |
$values = array(); |
| 2399 |
$value_default = array( |
| 2400 |
'name1' => null, |
| 2401 |
'name2' => null, |
| 2402 |
'name3' => null, |
| 2403 |
'name4' => null, |
| 2404 |
'zipcode' => null, |
| 2405 |
'country' => null, |
| 2406 |
'pref' => null, |
| 2407 |
'address1' => null, |
| 2408 |
'address2' => null, |
| 2409 |
'address3' => null, |
| 2410 |
'tel' => null, |
| 2411 |
'fax' => null, |
| 2412 |
); |
| 2413 |
|
| 2414 |
$formtag = ''; |
| 2415 |
switch ( $type ) { |
| 2416 |
case 'admin_mail_customer': |
| 2417 |
$values = $data; |
| 2418 |
$values['country'] = ! empty( $values['country'] ) ? $values['country'] : usces_get_local_addressform(); |
| 2419 |
$main_mode = 'customer'; |
| 2420 |
$name_label = __( 'Buyer', 'usces' ); |
| 2421 |
break; |
| 2422 |
case 'admin_mail': |
| 2423 |
$values = $data; |
| 2424 |
$values['country'] = ! empty( $values['country'] ) ? $values['country'] : usces_get_local_addressform(); |
| 2425 |
$main_mode = 'delivery'; |
| 2426 |
$name_label = __( 'A destination name', 'usces' ); |
| 2427 |
break; |
| 2428 |
case 'order_mail_customer': |
| 2429 |
$values = $data['customer']; |
| 2430 |
$values['country'] = ! empty( $values['country'] ) ? $values['country'] : usces_get_local_addressform(); |
| 2431 |
$main_mode = 'customer'; |
| 2432 |
$name_label = __( 'Buyer', 'usces' ); |
| 2433 |
break; |
| 2434 |
case 'order_mail': |
| 2435 |
$values = $data['delivery']; |
| 2436 |
$values['country'] = ! empty( $values['country'] ) ? $values['country'] : usces_get_local_addressform(); |
| 2437 |
$main_mode = 'delivery'; |
| 2438 |
$name_label = __( 'A destination name', 'usces' ); |
| 2439 |
break; |
| 2440 |
} |
| 2441 |
// set data value default. |
| 2442 |
foreach ( $value_default as $key => $val ) { |
| 2443 |
if ( ! isset( $values[ $key ] ) ) { |
| 2444 |
$values[ $key ] = $value_default[ $key ]; |
| 2445 |
} |
| 2446 |
} |
| 2447 |
|
| 2448 |
foreach ( $values as $key => $val ) { |
| 2449 |
if ( is_string( $val ) ) { |
| 2450 |
$val = preg_replace( '/[\r\n]/', '', $val ); |
| 2451 |
$values[ $key ] = esc_html( $val ); |
| 2452 |
} |
| 2453 |
} |
| 2454 |
|
| 2455 |
$pref = ( __( '-- Select --', 'usces' ) === $values['pref'] || '-- Select --' === $values['pref'] ) ? '' : $values['pref']; |
| 2456 |
$target_market_count = ( isset( $options['system']['target_market'] ) && is_array( $options['system']['target_market'] ) ) ? count( $options['system']['target_market'] ) : 1; |
| 2457 |
|
| 2458 |
if ( usces_is_html_mail() ) { |
| 2459 |
|
| 2460 |
switch ( $applyform ) { |
| 2461 |
case 'JP': |
| 2462 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2463 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2464 |
$order_data = usces_get_order_email( $order_id ); |
| 2465 |
$mem_id = $order_data['mem_id']; |
| 2466 |
$order_email = $order_data['order_email']; |
| 2467 |
|
| 2468 |
if ( ! empty( $mem_id ) ) { |
| 2469 |
$formtag .= '<tr> |
| 2470 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'membership number', 'usces' ) . '</td> |
| 2471 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $mem_id . '</td> |
| 2472 |
</tr>' . "\r\n"; |
| 2473 |
} |
| 2474 |
if ( ! empty( $order_email ) ) { |
| 2475 |
$formtag .= '<tr> |
| 2476 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'e-mail adress', 'usces' ) . '</td> |
| 2477 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $order_email . '</td> |
| 2478 |
</tr>' . "\r\n"; |
| 2479 |
} |
| 2480 |
} |
| 2481 |
|
| 2482 |
$formtag .= '<tr> |
| 2483 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . $name_label . '</td> |
| 2484 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name1'] . ' ' . $values['name2'] ) ) . '</td> |
| 2485 |
</tr>' . "\r\n"; |
| 2486 |
|
| 2487 |
if ( ! empty( $values['name3'] ) || ! empty( $values['name4'] ) ) { |
| 2488 |
$formtag .= '<tr> |
| 2489 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'furigana', 'usces' ) . '</td> |
| 2490 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $values['name3'] . ' ' . $values['name4'] . '</td> |
| 2491 |
</tr>' . "\r\n"; |
| 2492 |
} |
| 2493 |
|
| 2494 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2495 |
|
| 2496 |
if ( 1 < $target_market_count ) { |
| 2497 |
$formtag .= '<tr> |
| 2498 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Country', 'usces' ) . '</td> |
| 2499 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $usces_settings['country'][ $values['country'] ] . '</td> |
| 2500 |
</tr>' . "\r\n"; |
| 2501 |
} |
| 2502 |
|
| 2503 |
$formtag .= '<tr> |
| 2504 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Zip/Postal Code', 'usces' ) . '</td> |
| 2505 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $values['zipcode'] . '</td> |
| 2506 |
</tr>' . "\r\n"; |
| 2507 |
|
| 2508 |
$formtag .= '<tr> |
| 2509 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Address', 'usces' ) . '</td> |
| 2510 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $pref . $values['address1'] . $values['address2'] . ' ' . $values['address3'] . '</td> |
| 2511 |
</tr>' . "\r\n"; |
| 2512 |
|
| 2513 |
$formtag .= '<tr> |
| 2514 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'Phone number', 'usces' ) . '</td> |
| 2515 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $values['tel'] . '</td> |
| 2516 |
</tr>' . "\r\n"; |
| 2517 |
|
| 2518 |
$formtag .= '<tr> |
| 2519 |
<td style="padding: 0 0 10px; text-align: left; width: 100px; font-weight: normal; vertical-align: text-top;">' . __( 'FAX number', 'usces' ) . '</td> |
| 2520 |
<td style="padding: 0 0 10px 50px; width: calc( 100% - 100px );">' . $values['fax'] . '</td> |
| 2521 |
</tr>' . "\r\n"; |
| 2522 |
|
| 2523 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2524 |
break; |
| 2525 |
|
| 2526 |
case 'CN': |
| 2527 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2528 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2529 |
$order_data = usces_get_order_email( $order_id ); |
| 2530 |
$mem_id = $order_data['mem_id']; |
| 2531 |
$order_email = $order_data['order_email']; |
| 2532 |
|
| 2533 |
$formtag .= ( ! empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . ' : ' . $mem_id . "\r\n" : ''; |
| 2534 |
$formtag .= ( ! empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . ' : ' . $order_email . "\r\n" : ''; |
| 2535 |
} |
| 2536 |
// translators: %s: name of user. |
| 2537 |
$formtag .= $name_label . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name1'] . ' ' . $values['name2'] ) ) . "\r\n"; |
| 2538 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2539 |
if ( 1 < $target_market_count ) { |
| 2540 |
$formtag .= __( 'Country', 'usces' ) . ' : ' . $usces_settings['country'][ $values['country'] ] . "\r\n"; |
| 2541 |
} |
| 2542 |
$formtag .= __( 'State', 'usces' ) . ' : ' . $pref . "\r\n"; |
| 2543 |
$formtag .= __( 'City', 'usces' ) . ' : ' . $values['address1'] . "\r\n"; |
| 2544 |
$formtag .= __( 'Address', 'usces' ) . ' : ' . $values['address2'] . ' ' . $values['address3'] . "\r\n"; |
| 2545 |
$formtag .= __( 'Zip/Postal Code', 'usces' ) . ' : ' . $values['zipcode'] . "\r\n"; |
| 2546 |
$formtag .= __( 'Phone number', 'usces' ) . ' : ' . $values['tel'] . "\r\n"; |
| 2547 |
$formtag .= __( 'FAX number', 'usces' ) . ' : ' . $values['fax'] . "\r\n"; |
| 2548 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2549 |
break; |
| 2550 |
|
| 2551 |
case 'US': |
| 2552 |
default: |
| 2553 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2554 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2555 |
$order_data = usces_get_order_email( $order_id ); |
| 2556 |
$mem_id = $order_data['mem_id']; |
| 2557 |
$order_email = $order_data['order_email']; |
| 2558 |
|
| 2559 |
$formtag .= ( ! empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . ' : ' . $mem_id . "\r\n" : ''; |
| 2560 |
$formtag .= ( ! empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . ' : ' . $order_email . "\r\n" : ''; |
| 2561 |
} |
| 2562 |
// translators: %s: name of user. |
| 2563 |
$formtag .= $name_label . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name2'] . ' ' . $values['name1'] ) ) . "\r\n"; |
| 2564 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2565 |
$formtag .= __( 'Address', 'usces' ) . ' : ' . $values['address2'] . ' ' . $values['address3'] . "\r\n"; |
| 2566 |
$formtag .= __( 'City', 'usces' ) . ' : ' . $values['address1'] . "\r\n"; |
| 2567 |
$formtag .= __( 'State', 'usces' ) . ' : ' . $pref . "\r\n"; |
| 2568 |
if ( 1 < $target_market_count ) { |
| 2569 |
$formtag .= __( 'Country', 'usces' ) . ' : ' . $usces_settings['country'][ $values['country'] ] . "\r\n"; |
| 2570 |
} |
| 2571 |
$formtag .= __( 'Zip/Postal Code', 'usces' ) . ' : ' . $values['zipcode'] . "\r\n"; |
| 2572 |
$formtag .= __( 'Phone number', 'usces' ) . ' : ' . $values['tel'] . "\r\n"; |
| 2573 |
$formtag .= __( 'FAX number', 'usces' ) . ' : ' . $values['fax'] . "\r\n"; |
| 2574 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2575 |
break; |
| 2576 |
} |
| 2577 |
|
| 2578 |
} else { |
| 2579 |
|
| 2580 |
switch ( $applyform ) { |
| 2581 |
case 'JP': |
| 2582 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2583 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2584 |
$order_data = usces_get_order_email( $order_id ); |
| 2585 |
$mem_id = $order_data['mem_id']; |
| 2586 |
$order_email = $order_data['order_email']; |
| 2587 |
|
| 2588 |
$formtag .= ( ! empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . ' : ' . $mem_id . "\r\n" : ''; |
| 2589 |
$formtag .= ( ! empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . ' : ' . $order_email . "\r\n" : ''; |
| 2590 |
} |
| 2591 |
// translators: %s: name of user. |
| 2592 |
$formtag .= $name_label . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name1'] . ' ' . $values['name2'] ) ) . "\r\n"; |
| 2593 |
if ( ! empty( $values['name3'] ) || ! empty( $values['name4'] ) ) { |
| 2594 |
$formtag .= __( 'furigana', 'usces' ) . ' : ' . $values['name3'] . ' ' . $values['name4'] . "\r\n"; |
| 2595 |
} |
| 2596 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2597 |
if ( 1 < $target_market_count ) { |
| 2598 |
$formtag .= __( 'Country', 'usces' ) . ' : ' . $usces_settings['country'][ $values['country'] ] . "\r\n"; |
| 2599 |
} |
| 2600 |
$formtag .= __( 'Zip/Postal Code', 'usces' ) . ' : ' . $values['zipcode'] . "\r\n"; |
| 2601 |
$formtag .= __( 'Address', 'usces' ) . ' : ' . $pref . $values['address1'] . $values['address2'] . ' ' . $values['address3'] . "\r\n"; |
| 2602 |
$formtag .= __( 'Phone number', 'usces' ) . ' : ' . $values['tel'] . "\r\n"; |
| 2603 |
$formtag .= __( 'FAX number', 'usces' ) . ' : ' . $values['fax'] . "\r\n"; |
| 2604 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2605 |
break; |
| 2606 |
|
| 2607 |
case 'CN': |
| 2608 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2609 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2610 |
$order_data = usces_get_order_email( $order_id ); |
| 2611 |
$mem_id = $order_data['mem_id']; |
| 2612 |
$order_email = $order_data['order_email']; |
| 2613 |
|
| 2614 |
$formtag .= ( ! empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . ' : ' . $mem_id . "\r\n" : ''; |
| 2615 |
$formtag .= ( ! empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . ' : ' . $order_email . "\r\n" : ''; |
| 2616 |
} |
| 2617 |
// translators: %s: name of user. |
| 2618 |
$formtag .= $name_label . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name1'] . ' ' . $values['name2'] ) ) . "\r\n"; |
| 2619 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2620 |
if ( 1 < $target_market_count ) { |
| 2621 |
$formtag .= __( 'Country', 'usces' ) . ' : ' . $usces_settings['country'][ $values['country'] ] . "\r\n"; |
| 2622 |
} |
| 2623 |
$formtag .= __( 'State', 'usces' ) . ' : ' . $pref . "\r\n"; |
| 2624 |
$formtag .= __( 'City', 'usces' ) . ' : ' . $values['address1'] . "\r\n"; |
| 2625 |
$formtag .= __( 'Address', 'usces' ) . ' : ' . $values['address2'] . ' ' . $values['address3'] . "\r\n"; |
| 2626 |
$formtag .= __( 'Zip/Postal Code', 'usces' ) . ' : ' . $values['zipcode'] . "\r\n"; |
| 2627 |
$formtag .= __( 'Phone number', 'usces' ) . ' : ' . $values['tel'] . "\r\n"; |
| 2628 |
$formtag .= __( 'FAX number', 'usces' ) . ' : ' . $values['fax'] . "\r\n"; |
| 2629 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2630 |
break; |
| 2631 |
|
| 2632 |
case 'US': |
| 2633 |
default: |
| 2634 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_pre', $order_id ); |
| 2635 |
if ( 'order_mail_customer' === $type || 'admin_mail_customer' === $type ) { |
| 2636 |
$order_data = usces_get_order_email( $order_id ); |
| 2637 |
$mem_id = $order_data['mem_id']; |
| 2638 |
$order_email = $order_data['order_email']; |
| 2639 |
|
| 2640 |
$formtag .= ( ! empty( $mem_id ) ) ? __( 'membership number', 'usces' ) . ' : ' . $mem_id . "\r\n" : ''; |
| 2641 |
$formtag .= ( ! empty( $order_email ) ) ? __( 'e-mail adress', 'usces' ) . ' : ' . $order_email . "\r\n" : ''; |
| 2642 |
} |
| 2643 |
// translators: %s: name of user. |
| 2644 |
$formtag .= $name_label . ' : ' . sprintf( _x( '%s', 'honorific', 'usces' ), ( $values['name2'] . ' ' . $values['name1'] ) ) . "\r\n"; |
| 2645 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'name_after', $order_id ); |
| 2646 |
$formtag .= __( 'Address', 'usces' ) . ' : ' . $values['address2'] . ' ' . $values['address3'] . "\r\n"; |
| 2647 |
$formtag .= __( 'City', 'usces' ) . ' : ' . $values['address1'] . "\r\n"; |
| 2648 |
$formtag .= __( 'State', 'usces' ) . ' : ' . $pref . "\r\n"; |
| 2649 |
if ( 1 < $target_market_count ) { |
| 2650 |
$formtag .= __( 'Country', 'usces' ) . ' : ' . $usces_settings['country'][ $values['country'] ] . "\r\n"; |
| 2651 |
} |
| 2652 |
$formtag .= __( 'Zip/Postal Code', 'usces' ) . ' : ' . $values['zipcode'] . "\r\n"; |
| 2653 |
$formtag .= __( 'Phone number', 'usces' ) . ' : ' . $values['tel'] . "\r\n"; |
| 2654 |
$formtag .= __( 'FAX number', 'usces' ) . ' : ' . $values['fax'] . "\r\n"; |
| 2655 |
$formtag .= usces_mail_custom_field_info( $main_mode, 'fax_after', $order_id ); |
| 2656 |
break; |
| 2657 |
} |
| 2658 |
} |
| 2659 |
$res = apply_filters( 'usces_filter_apply_mail_addressform', $formtag, $type, $data, $order_id ); |
| 2660 |
|
| 2661 |
if ( 'return' === $out ) { |
| 2662 |
return $res; |
| 2663 |
} else { |
| 2664 |
wel_esc_script_e( $res ); |
| 2665 |
} |
| 2666 |
} |
| 2667 |
|
| 2668 |
/** |
| 2669 |
* Get order email |
| 2670 |
* |
| 2671 |
* @param int $order_id Order ID. |
| 2672 |
* @return array |
| 2673 |
*/ |
| 2674 |
function usces_get_order_email( $order_id ) { |
| 2675 |
global $wpdb; |
| 2676 |
|
| 2677 |
$usces_order_table = $wpdb->prefix . 'usces_order'; |
| 2678 |
$order_data = $wpdb->get_results( $wpdb->prepare( "SELECT mem_id, order_email FROM $usces_order_table WHERE ID = %d LIMIT 1", $order_id ) ); |
| 2679 |
$res = array( |
| 2680 |
'mem_id' => isset( $order_data[0] ) ? $order_data[0]->mem_id : 0, |
| 2681 |
'order_email' => isset( $order_data[0] ) ? $order_data[0]->order_email : null, |
| 2682 |
); |
| 2683 |
return $res; |
| 2684 |
} |
| 2685 |
|
| 2686 |
/** |
| 2687 |
* Lines to draw on emails |
| 2688 |
* |
| 2689 |
* @param int $type Line type. |
| 2690 |
* @param string $email E-mail address. |
| 2691 |
* @return string |
| 2692 |
*/ |
| 2693 |
function usces_mail_line( $type, $email = '' ) { |
| 2694 |
$line = ''; |
| 2695 |
|
| 2696 |
switch ( $type ) { |
| 2697 |
case 1: |
| 2698 |
$line = '******************************************************'; |
| 2699 |
break; |
| 2700 |
case 2: |
| 2701 |
$line = '------------------------------------------------------------------'; |
| 2702 |
break; |
| 2703 |
case 3: |
| 2704 |
$line = '============================================='; |
| 2705 |
break; |
| 2706 |
} |
| 2707 |
|
| 2708 |
$line = apply_filters( 'usces_filter_mail_line', $line, $type, $email ); |
| 2709 |
|
| 2710 |
return $line . "\r\n"; |
| 2711 |
} |
| 2712 |
|
| 2713 |
/** |
| 2714 |
* Tax label for mail |
| 2715 |
* |
| 2716 |
* @param array $data Order data. |
| 2717 |
* @return string |
| 2718 |
*/ |
| 2719 |
function usces_mail_tax_label( $data ) { |
| 2720 |
global $usces; |
| 2721 |
|
| 2722 |
$tax_label = ''; |
| 2723 |
|
| 2724 |
if ( empty( $data ) || ! array_key_exists( 'order_condition', $data ) ) { |
| 2725 |
$condition = $usces->get_condition(); |
| 2726 |
$tax_mode = $usces->options['tax_mode']; |
| 2727 |
$reduced_taxrate = usces_is_reduced_taxrate(); |
| 2728 |
$tax_rate = ( ! empty( $usces->options['tax_rate'] ) && ! $reduced_taxrate ) ? '(' . $usces->options['tax_rate'] . __( '%', 'usces' ) . ')' : ''; |
| 2729 |
} else { |
| 2730 |
$condition = wel_safe_maybe_unserialize( $data['order_condition'] ); |
| 2731 |
$tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode']; |
| 2732 |
if ( isset( $condition['applicable_taxrate'] ) ) { |
| 2733 |
$reduced_taxrate = ( 'reduced' === $condition['applicable_taxrate'] ) ? true : false; |
| 2734 |
} else { |
| 2735 |
$reduced_taxrate = usces_is_reduced_taxrate(); |
| 2736 |
} |
| 2737 |
$tax_rate = ( ! empty( $condition['tax_rate'] ) && ! $reduced_taxrate ) ? '(' . $condition['tax_rate'] . __( '%', 'usces' ) . ')' : ''; |
| 2738 |
} |
| 2739 |
|
| 2740 |
if ( 'exclude' === $tax_mode ) { |
| 2741 |
$tax_label = __( 'consumption tax', 'usces' ) . $tax_rate; |
| 2742 |
} else { |
| 2743 |
if ( usces_is_html_mail() ) { |
| 2744 |
$tax_label = __( 'Internal tax', 'usces' ) . $tax_rate; |
| 2745 |
} else { |
| 2746 |
if ( isset( $condition['tax_mode'] ) && ! empty( $data['ID'] ) ) { |
| 2747 |
$materials = array( |
| 2748 |
'total_items_price' => $data['order_item_total_price'], |
| 2749 |
'discount' => $data['order_discount'], |
| 2750 |
'shipping_charge' => $data['order_shipping_charge'], |
| 2751 |
'cod_fee' => $data['order_cod_fee'], |
| 2752 |
'use_point' => $data['order_usedpoint'], |
| 2753 |
'carts' => usces_get_ordercartdata( $data['ID'] ), |
| 2754 |
'condition' => $condition, |
| 2755 |
'order_id' => $data['ID'], |
| 2756 |
); |
| 2757 |
$tax_label = '( ' . __( 'Internal tax', 'usces' ) . $tax_rate . ' : ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )'; |
| 2758 |
} else { |
| 2759 |
$tax_label = __( 'Internal tax', 'usces' ) . $tax_rate; |
| 2760 |
} |
| 2761 |
} |
| 2762 |
} |
| 2763 |
$tax_label = apply_filters( 'usces_filter_mail_tax_label', $tax_label ); |
| 2764 |
|
| 2765 |
return wel_esc_script( $tax_label ); |
| 2766 |
} |
| 2767 |
|
| 2768 |
/** |
| 2769 |
* Tax Calculation for mail |
| 2770 |
* |
| 2771 |
* @param array $data When the 'order' key in $data exist, entry data, unless order data. |
| 2772 |
* @return string |
| 2773 |
*/ |
| 2774 |
function usces_mail_tax( $data ) { |
| 2775 |
global $usces; |
| 2776 |
|
| 2777 |
$tax_str = ''; |
| 2778 |
|
| 2779 |
if ( empty( $data ) || ! array_key_exists( 'order_condition', $data ) ) { |
| 2780 |
$condition = $usces->get_condition(); |
| 2781 |
$tax_mode = $usces->options['tax_mode']; |
| 2782 |
} else { |
| 2783 |
$condition = wel_safe_maybe_unserialize( $data['order_condition'] ); |
| 2784 |
$tax_mode = ( isset( $condition['tax_mode'] ) ) ? $condition['tax_mode'] : $usces->options['tax_mode']; |
| 2785 |
} |
| 2786 |
|
| 2787 |
if ( 'exclude' === $tax_mode ) { |
| 2788 |
if ( array_key_exists( 'order', $data ) && array_key_exists( 'tax', $data['order'] ) ) { /* from Entry */ |
| 2789 |
$tax = $data['order']['tax']; |
| 2790 |
} elseif ( array_key_exists( 'order_tax', $data ) ) { /* from Order Data */ |
| 2791 |
$tax = $data['order_tax']; |
| 2792 |
} else { |
| 2793 |
$tax = 0; |
| 2794 |
} |
| 2795 |
$tax_str = usces_crform( $tax, true, false, 'return' ); |
| 2796 |
} else { |
| 2797 |
if ( array_key_exists( 'order', $data ) ) { /* from Entry */ |
| 2798 |
$materials = array( |
| 2799 |
'total_items_price' => $data['order']['total_items_price'], |
| 2800 |
'discount' => ( isset( $data['order']['discount'] ) ) ? $data['order']['discount'] : 0, |
| 2801 |
'shipping_charge' => ( isset( $data['order']['shipping_charge'] ) ) ? $data['order']['shipping_charge'] : 0, |
| 2802 |
'cod_fee' => ( isset( $data['order']['cod_fee'] ) ) ? $data['order']['cod_fee'] : 0, |
| 2803 |
'use_point' => ( isset( $data['order']['use_point'] ) ) ? $data['order']['use_point'] : 0, |
| 2804 |
); |
| 2805 |
$tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )'; |
| 2806 |
} elseif ( array_key_exists( 'order_tax', $data ) ) { /* from Order Data */ |
| 2807 |
$materials = array( |
| 2808 |
'total_items_price' => $data['order_item_total_price'], |
| 2809 |
'discount' => $data['order_discount'], |
| 2810 |
'shipping_charge' => $data['order_shipping_charge'], |
| 2811 |
'cod_fee' => $data['order_cod_fee'], |
| 2812 |
'use_point' => $data['order_usedpoint'], |
| 2813 |
'carts' => usces_get_ordercartdata( $data['ID'] ), |
| 2814 |
'condition' => wel_safe_unserialize( $data['order_condition'] ), |
| 2815 |
); |
| 2816 |
$tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )'; |
| 2817 |
} else { |
| 2818 |
$materials = array(); |
| 2819 |
$tax_str = '( ' . usces_crform( usces_internal_tax( $materials, 'return' ), true, false, 'return' ) . ' )'; |
| 2820 |
} |
| 2821 |
} |
| 2822 |
$tax_str = apply_filters( 'usces_filter_mail_tax', $tax_str ); |
| 2823 |
|
| 2824 |
return wel_esc_script( $tax_str ); |
| 2825 |
} |
| 2826 |
|
| 2827 |
/** |
| 2828 |
* Attachable Attachment File Extension |
| 2829 |
* |
| 2830 |
* @param array $email_attach_file_extensions Setting values. |
| 2831 |
* @return array |
| 2832 |
*/ |
| 2833 |
function wel_email_attach_file_extension( $email_attach_file_extensions ) { |
| 2834 |
if ( empty( $email_attach_file_extensions ) || ! is_array( $email_attach_file_extensions ) ) { |
| 2835 |
$email_attach_file_extension = array( 'jpg', 'png', 'pdf' ); |
| 2836 |
} else { |
| 2837 |
$email_attach_file_extension = array(); |
| 2838 |
|
| 2839 |
$allowed_extensions = array_keys( get_allowed_mime_types() ); |
| 2840 |
$extensions = array(); |
| 2841 |
foreach ( $allowed_extensions as $extension ) { |
| 2842 |
$extensions = array_merge( $extensions, explode( '|', $extension ) ); |
| 2843 |
} |
| 2844 |
foreach ( (array) $email_attach_file_extensions as $extension ) { |
| 2845 |
if ( in_array( $extension, $extensions, true ) ) { |
| 2846 |
$email_attach_file_extension[] = $extension; |
| 2847 |
} |
| 2848 |
} |
| 2849 |
} |
| 2850 |
|
| 2851 |
return $email_attach_file_extension; |
| 2852 |
} |
| 2853 |
|
| 2854 |
/** |
| 2855 |
* Sanitize value for use in email headers to prevent header injection. |
| 2856 |
* Removes CR, LF, and NULL characters that could be used for injection. |
| 2857 |
* |
| 2858 |
* @param string $value The value to sanitize. |
| 2859 |
* @return string Sanitized value safe for use in email headers. |
| 2860 |
*/ |
| 2861 |
function usces_sanitize_email_header( $value ) { |
| 2862 |
if ( ! is_string( $value ) ) { |
| 2863 |
return ''; |
| 2864 |
} |
| 2865 |
// Remove CR, LF, NULL, and vertical tab characters. |
| 2866 |
return preg_replace( '/[\r\n\x00\x0B]/', '', $value ); |
| 2867 |
} |
| 2868 |
|