Woocommerce:哪个钩子替换已弃用的“woocommerce_add_order_item_meta"; [英] Woocommerce: Which hook to replace deprecated "woocommerce_add_order_item_meta"

查看:30
本文介绍了Woocommerce:哪个钩子替换已弃用的“woocommerce_add_order_item_meta";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要添加自定义元来订购商品.谷歌搜索,大多数文章都说使用woocommerce_add_order_item_meta"钩子.此钩子在最新版本 2.3.7 中已弃用.有人,请告诉我改用哪个钩子.

Need to add custom meta to order items. Googled it and most articles says to use "woocommerce_add_order_item_meta" hook. This hook is deprecated in the newest version 2.3.7. Someone, please tell me which hook to use instead.

http://docs.woothemes.com/wc-apidocs/function-woocommerce_add_order_item_meta.html

推荐答案

如果你查看 wc-deprecated-functions.php 你会看到

If you look at wc-deprecated-functions.php you will see

/**
 * @deprecated
 */
function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) {
    return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique );
}

基本上,函数已重命名为wc_add_order_item_meta(),因此如果您需要该函数,请使用它.action hook 未重命名,保留在 class-wc-checkout.php 中为:

Basically, the function was renamed to wc_add_order_item_meta(), so if you need the function then use that. The action hook was not renamed and remains in class-wc-checkout.php as:

// Allow plugins to add order item meta
do_action( 'woocommerce_add_order_item_meta', $item_id, $values, $cart_item_key );

这篇关于Woocommerce:哪个钩子替换已弃用的“woocommerce_add_order_item_meta";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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