2017-10-28 12 views
2

私はWooCommerce 3.1.1を使用していますが、顧客と管理者の新しい注文番号で特定の商品カテゴリのテキストに「価格額」を置き換えようとしています。Woocommerceの電子メール通知で特定の商品カテゴリの価格アイテムを非表示

私はほとんどすべてを試しましたが、電子メール通知の注文明細詳細テーブルを見つけることができません。

このメールは、今のところ次のようになります。

Email

すべてのヘルプは本当にいただければ幸いです。

+0

メールテンプレートを編集しましたか? – Spartacus

+0

コードが見つかりません。 –

答えて

2

あなたは、にこの公式ドキュメントを読むために変更が必要な程度Overriding WooCommerce Templates via your active Theme

テンプレートを学び、オーバーライドがあなたのWCバージョン(またはラインのためのライン58でemails/email-order-items.php

ある最初が必要になりますWCのバージョン3.2以上) 55、あなたが置き換えられます:

<td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal($item); ?></td> 

をこのすることにより(ここで、あなたは)独自のカテゴリと置換テキスト文字列を設定する必要があります

<?php 
## ---- Variables to define (below)---- ## 

$categories = array('clothing'); // The Product categories coma separated (IDs slugs or names) 
$replacement_text = __('Replacement text (here)'); // The replacement text 

// Getting the email ID global variable (From our function below) 
$refNameGlobalsVar = $GLOBALS; 
$email_id = $refNameGlobalsVar['email_id_str']; 

// When matching product categories, "New Order", "Processing" and "On Hold" email notifications 
if(has_term($categories, 'product_cat', $product->get_id()) 
&& ($email_id == 'new_order' || $email_id == 'customer_processing_order' || $email_id == 'customer_on_hold_order')) 
    $formated_line_subtotal = $replacement_text; 
else 
    $formated_line_subtotal = $order->get_formatted_line_subtotal($item); 
?> 
<td class="td" style="text-align:<?php echo $text_align; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $formated_line_subtotal; ?></td> 

を、あなたのアクティブな子テーマ(またはアクティブなテーマのfunction.phpファイルでこれを追加する必要があります電子メールIDを取得するには)

// Setting the email_id as a global variable 
add_action('woocommerce_email_before_order_table', 'the_email_id_as_a_global', 1, 4); 
function the_email_id_as_a_global($order, $sent_to_admin, $plain_text, $email){ 
    $GLOBALS['email_id_str'] = $email->id; 
} 

今、あなたはこれを取得する際に製品カテゴリが一致し、「新規注文」(管理者)、「顧客保留注文日」と「顧客処理順序」電子メール通知のみ:

enter image description here

+0

このコードは、管理者に送信された電子メールには作用しますが、顧客には送信されません。 –

+0

@MujtabaK **更新日:**「新しい注文」の電子メール通知は管理者にのみ送信されるため、「お客様の保留オーダー」と「顧客処理オーダー」の電子メール通知をifステートメントに追加しました。あまりにも。 – LoicTheAztec

+0

コードを更新しましたが、テストできません。チェックアウトページで、「Internal Server Error Stripe」というエラーが表示されます。 –

関連する問題