我可以看到下面的代碼輸出的這一部分:如何在WooCommerce電子郵件中設置風格化銀行詳細信息?
<?php do_action('woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text); ?>
行動woocommerce_email_before_order_table是在文件woocommerce /包括/網關/類-WC-網關bacs.php
// Customer Emails
add_action('woocommerce_email_before_order_table', array($this, 'email_instructions'), 10, 3);
電子郵件說明是在同一個文件:
/**
* Add content to the WC emails.
*
* @access public
* @param WC_Order $order
* @param bool $sent_to_admin
* @param bool $plain_text
* @return void
*/
public function email_instructions($order, $sent_to_admin, $plain_text = false) {
if (! $sent_to_admin && 'bacs' === $order->payment_method && $order->has_status('on-hold')) {
if ($this->instructions) {
echo wpautop(wptexturize($this->instructions)) . PHP_EOL;
}
$this->bank_details($order->id);
}
}
而且一部分,我很感興趣:
/**
* Get bank details and place into a list format
*/
private function bank_details($order_id = '') {
if (empty($this->account_details)) {
return;
}
echo '<h2>' . __('Our Bank Details', 'woocommerce') . '</h2>' . PHP_EOL;
$bacs_accounts = apply_filters('woocommerce_bacs_accounts', $this->account_details);
if (! empty($bacs_accounts)) {
foreach ($bacs_accounts as $bacs_account) {
$bacs_account = (object) $bacs_account;
if ($bacs_account->account_name || $bacs_account->bank_name) {
echo '<h3>' . implode(' - ', array_filter(array($bacs_account->account_name, $bacs_account->bank_name))) . '</h3>' . PHP_EOL;
}
echo '<ul class="order_details bacs_details">' . PHP_EOL;
// BACS account fields shown on the thanks page and in emails
$account_fields = apply_filters('woocommerce_bacs_account_fields', array(
'account_number'=> array(
'label' => __('Account Number', 'woocommerce'),
'value' => $bacs_account->account_number
),
'sort_code' => array(
'label' => __('Sort Code', 'woocommerce'),
'value' => $bacs_account->sort_code
),
'iban' => array(
'label' => __('IBAN', 'woocommerce'),
'value' => $bacs_account->iban
),
'bic' => array(
'label' => __('BIC', 'woocommerce'),
'value' => $bacs_account->bic
)
), $order_id);
foreach ($account_fields as $field_key => $field) {
if (! empty($field['value'])) {
echo '<li class="' . esc_attr($field_key) . '">' . esc_attr($field['label']) . ': <strong>' . wptexturize($field['value']) . '</strong></li>' . PHP_EOL;
}
}
echo '</ul>';
}
}
}
我想添加一些內聯樣式到h2,h3和li元素來使它們在電子郵件中風格化。如果此函數輸出結果並且不返回並且不將數據存儲在變量中,如何使用過濾器(或其他方法在更新後不會丟失更改)執行此操作?
我可以在電子郵件中看到h2和h3中有一些內聯樣式,但我無法理解它們來自哪裏。
我將不勝感激任何幫助。
我已經複製了電子郵件模板,但問題是我想更改的信息不是來自模板,而是來自woocommerce類。 – 2014-12-05 09:30:47