wordpress - 基本 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 字符串的产品?谢谢。
解决方案
首先,直接更新位于 /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);
推荐阅读
- javascript - Vue JS:如何仅使用本机拖动事件(没有 Draggable 小部件)使对象拖动到轴 x 和 y?
- node-sqlite3 - “返回”(节点)附近的 SQLite 语法错误
- reactjs - 使用 /authorize 和 /oauth/token 端点进行身份验证以访问自定义 Api 后获取访问令牌的正确方法是什么
- sql - 查询结果在 Oracle SQL 中的查询标头
- amazon-web-services - S3 静态托管网页找不到子文件夹内容
- jvm - Vert.x httpClient/webClient 逐块或作为流处理响应
- javascript - 无效电子邮件的正则表达式
- javascript - Quasar 2.2.2、Vue 3 和 Firebase:如何从路由器访问 GlobalProperties
- reactjs - 如何在 React 自定义元素中为 MUI 材料 v5 创建插入点以在阴影 dom 中安装样式
- python - 如何安全地在 dict 中找到重复值?