第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

如何將 Woocommerce 多個(gè)與會(huì)者自定義元數(shù)據(jù)包含到新訂單電子郵件中

如何將 Woocommerce 多個(gè)與會(huì)者自定義元數(shù)據(jù)包含到新訂單電子郵件中

PHP
精慕HU 2023-08-19 17:32:06
受 Woocommerce 中將自定義元數(shù)據(jù)作為帶有標(biāo)題的 html 樣式表添加到電子郵件中的啟發(fā),我使用以下代碼來(lái)顯示與會(huì)者信息:add_action('woocommerce_email_order_details', 'action_after_email_order_details', 25, 4 );function action_after_email_order_details( $order, $sent_to_admin, $plain_text, $email ){? ?$event = get_post_meta( $order->get_id(), 'WooCommerceEventsOrderTickets', true );? ?if( ! is_array($event) ) return;? ?$event = isset($event[1][1]) ? $event[1][1] : '';? ?if( sizeof($event) == 0 ) return;? ?$custom = isset($event['WooCommerceEventsCustomAttendeeFields']) ? $event['WooCommerceEventsCustomAttendeeFields'] : '';? ?// Set our array of needed data? ?$fields_array = [? ? __('First name')? ? => isset($event['WooCommerceEventsAttendeeName']) ? $event['WooCommerceEventsAttendeeName'] : '',? ? __('Last name')? ? ?=> isset($event['WooCommerceEventsAttendeeLastName']) ? $event['WooCommerceEventsAttendeeLastName'] : '',? ?];? ?if( ! $event ) return;? ?// The HTML Structure? ?$html_output = '<h2>' . __('Attendee Info') . '</h2>? ?<div class="discount-info">? ? ? <table cellspacing="0" cellpadding="6"><tbody>';? ?// Loop though the data array to set the fields? ?foreach( $fields_array as $label => $value ):? ?if( ! empty($value) ):? ? ?$html_output .= '<tr>? ? ? ? <th>' . $label . '</th>? ? ? ? <td>' . $value . '</td>? ? </tr>';? ?endif;? ?endforeach;? ?$html_output .= '</tbody></table>? ?</div><br>'; // HTML (end)}但它僅顯示第一個(gè)與會(huì)者的信息。是否有一個(gè)選項(xiàng)可以包含元數(shù)據(jù)(僅名字和姓氏)但對(duì)于woocommerce_email_order_details掛鉤內(nèi)的所有(多個(gè))與會(huì)者?
查看完整描述

1 回答

?
慕虎7371278

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊

好吧,我明白了,如果有人需要的話(huà),這是這個(gè)函數(shù):


add_action('woocommerce_email_order_details', 'action_after_email_order_details', 25, 4 );

function action_after_email_order_details( $order, $sent_to_admin, $plain_text, $email ) {

$events = get_post_meta( $order->get_id(), 'WooCommerceEventsOrderTickets', true );


if( ! is_array($events) ) return;


$events = isset($events[1]) ? $events[1] : '';


if( ! $events ) return;


// The HTML Structure

$html_output = '<h2>' . __('Attendee Info') . '</h2>

<div class="attendees-info">

    <table cellspacing="0" cellpadding="6"><tbody>';


$i = 1;

foreach( $events as $event ) :


    if( sizeof($event) == 0 ) return;

    // get only first and last name for each attendee

    $attendeeFirstName = isset($event['WooCommerceEventsAttendeeName']) ? $event['WooCommerceEventsAttendeeName'] : '';

    $attendeeLastName = isset($event['WooCommerceEventsAttendeeLastName']) ? $event['WooCommerceEventsAttendeeLastName'] : '';


    $html_output .= '<tr>

    <th>Attendee '. $i . '</th>

    <td>' . $attendeeFirstName .' '.$attendeeLastName. '</td>

    </tr>';


    $i++;


endforeach; 


$html_output .= '</tbody></table>

</div><br>'; // HTML (end)


// The CSS styling

$styles = '<style>

    .attendees-info table{width: 100%; font-family: \'Helvetica Neue\', Helvetica, Roboto, Arial, sans-serif;

        color: #737373; border: 1px solid #e4e4e4; margin-bottom:8px;}

    .attendees-info table th, table.tracking-info td{text-align: left; border-top-width: 4px;

        color: #737373; border: 1px solid #e4e4e4; padding: 12px; width:58%;}

    .attendees-info table td{text-align: left; border-top-width: 4px; color: #737373; border: 1px solid #e4e4e4; padding: 12px;}

</style>';


// The Output CSS + HTML

echo $styles . $html_output;

}


查看完整回答
反對(duì) 回復(fù) 2023-08-19
  • 1 回答
  • 0 關(guān)注
  • 110 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)