首页 > 解决方案 > 基本 PHP,Woocommerce 客户电子邮件所需的指导

问题描述

我知道这是基本的 PHP,但我才刚刚开始。我正在编辑客户确认电子邮件的 Woocommerce 电子邮件模板 /woocommerce/emails/customer-processing-order.php

我需要添加一个链接,将客户电子邮件和订购的产品拉入 URL。这就是我要做的:

<div style="text-align:center">
<a href="https://www.example.com?user_email=<?php echo $order->get_billing_email();?>&product_codes=<?php echo $order->get_items();?>">Click here</a>
</div>

这对我不起作用,但我很欣赏我的基本 PHP 知识很差,所以我可能在这里犯了一个非常基本的错误。如何引用客户电子邮件和订购到 URL 字符串的产品?谢谢。

标签: wordpresswoocommerce

解决方案


首先,直接更新位于 /woocommerce/emails/ 目录的电子邮件模板是错误的做法。

如果您需要自定义 woocommerce 电子邮件模板,则需要将 /woocommerce/emails/customer-processing-order.php 中的文件复制到 content/themes/yourtheme/woocommerce/emails/customer-processing-order.php 。

有关详细信息,请参阅https://docs.woocommerce.com/document/template-structure/

对于其余部分,我如@Jignesh 所述,只需在 url 中传递 order id ,然后在模板中,您可以使用以下方式获取订单详细信息

$order = wc_get_order($order_id);


推荐阅读