【问题标题】:woocommerce send customer invoice on thankyou pagewoocommerce 在感谢页面上发送客户发票
【发布时间】:2017-01-14 23:37:57
【问题描述】:

我正在尝试在下订单后向客户发送发票,并且用户到达感谢页面。

我认为我可以使用以下内容:

function sendinvoice($orderid)
{
    $email = new WC_Email_Customer_Invoice();
    $email->trigger($orderid);
}   

add_action('woocommerce_thankyou','sendinvoice');

但是在感谢页面上,我看到以下错误:

致命错误:在第 174 行的 /***/index.php 中找不到类 'WC_Email_Customer_Invoice'

关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    看起来您需要指定“WC_Email_Customer_Invoice”类所在的完整路径,您可以使用 require 或 include,例如: include_once(WP_PLUGIN_DIR . 'woocommerce/includes/emails/class-wc-email-customer-invoice.php');

    更新:实际上最好的方法是使用 global $woocommerce;然后就这样称呼它:

    WC()->mailer()->emails['WC_Email_Customer_Invoice']->trigger($orderid);
    

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      你需要包含这两个文件;

      include_once('../wp-content/plugins/woocommerce/includes/emails/class-wc-email.php');
      include_once('../wp-content/plugins/woocommerce/includes/emails/class-wc-email-customer-invoice.php');
      

      已更新;

      还有一个依赖文件;

      include_once('../wp-content/plugins/woocommerce/includes/libraries/class-emogrifier.php');

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-01-27
        • 1970-01-01
        • 2023-03-20
        • 2018-07-29
        • 1970-01-01
        • 1970-01-01
        • 2018-11-05
        • 2019-12-29
        相关资源
        最近更新 更多