【问题标题】:Woocommerce - Email text based off product categoryWoocommerce - 基于产品类别的电子邮件文本
【发布时间】:2014-11-28 04:11:39
【问题描述】:

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

我知道这不是很清楚:P

例如:

  • 我有两种产品。测试 1 和测试 2。 Test1 的类别为“ICT Sale”,而 Test2 的类别为“Private Sale”。
  • 如果有人购买了 Test1,我希望通过电子邮件说“感谢您购买 ICT 产品”
  • 如果有人购买了 Test2,我希望它说“这是私人销售!”

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

提前感谢您的帮助!

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    您可以在您的主题中复制电子邮件模板,然后做任何您想做的事情。

    例如,将 woocommerce/templates/emails/customer-processing-order.php 复制到主题/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;
            }
        }
    }
    

    【讨论】:

      【解决方案2】:
      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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-05
        • 2019-05-30
        • 2021-04-02
        • 2022-01-02
        • 2020-10-03
        • 2018-11-07
        • 1970-01-01
        相关资源
        最近更新 更多