添加自定义订单项元数据 [英] Add custom order item meta data

查看:38
本文介绍了添加自定义订单项元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一些将与 woocommerce_order_status_completed 挂钩运行的代码.该代码将连接到第 3 方以检索所购买物品的序列号.最初我打算只将序列号通过电子邮件发送给客户,但我想知道,是否可以将检索到的序列号添加到订购的项目(元?),以便客户转到他们的帐户页面查看订单,他们会看到此处列出的序列号(在购买的产品下方?

I am currently working on some code that will run with the woocommerce_order_status_completed hook. The code will connect to a 3rd party to retrieve a serial number for the purchased item. Originally I was planning on just emailing the serial to the customer, but I was wondering, would it be possible to add the retrieved serial number to the ordered item (meta?) so that when the customer goes to their account page to view the order, they see the serial number listed there (under the product(s) that was purchased?

这可能吗?将信息添加到要在帐户页面中显示的订单?

Is this possible some how? Add information to the order to be shown in the account page?

推荐答案

好的,像这样添加:

function add_order_item_meta($item_id, $values) {
    $key = ''; // Define your key here
    $value = ''; // Get your value here
    woocommerce_add_order_item_meta($item_id, $key, $value);
}
add_action('woocommerce_add_order_item_meta', 'add_order_item_meta', 10, 2);

这篇关于添加自定义订单项元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆