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

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

问题描述

需要向订单商品添加自定义元.用Google搜索它,大多数文章说使用"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,将会看到

/**
 * @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(),因此,如果需要该功能,请使用该功能. 动作挂钩未重命名,并在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天全站免登陆