Woocommerce - 基于产品类别的电子邮件文本

时间:2014-11-28 04:11:39

标签: wordpress woocommerce

我想知道是否有办法通过购买的产品类别分离我的处理订单电子邮件。

我知道不太清楚:P

例如:

  • 我有两种产品。 Test1和Test2。 Test1具有“ICT销售”类别,而Test2具有“私人销售”。
  • 如果有人购买了Test1,我希望该电子邮件说“感谢您购买ICT产品”
  • 如果有人购买了Test2,我希望它说'这是私人促销!'

不幸的是我使用JS比PHP和WP钩子更流畅(我假设if / else语句在这里不起作用:P)

提前感谢您的帮助!

2 个答案:

答案 0 :(得分:2)

您可以在主题中复制电子邮件模板,然后按照自己的意愿进行操作。

例如,将woocommerce / templates / email / customer-processing-order.php复制到themes / yourtheme / woocommerce / emails / customer-processing-order.php

然后编辑customer-processing-order.php这样的事情应该是你的伎俩(你需要完成然后显示你想要的任何东西)

$ict = false;
$private = false;

foreach ( $order->get_items() as $item ){
    $categories = get_the_terms( $item['product_id'] , 'product_cat' );

    foreach( $categories as $categorie ) {
        if ($categorie->slug == 'ICT') {
            $ict = true;
        }elseif( $categorie->slug == 'private-sale-slug' ) {
            $private = true;
        }
    }
}

答案 1 :(得分:-1)

Hi bro Please go to wocommerce product page (wp-admin/edit.php?post_type=product) and
click on the quickedit of test2 product. Here see you selected checkbox on private so
comout message ('This is a private sale!') when purchage product test2 .please remove
selected checkbox on private.
相关问题