0
文件电子邮件阶items.php具有下面的代码行:Woocommerce覆盖插件操作
echo "\n" . sprintf(__('Cost: %s', 'woocommerce'), $order->get_formatted_line_subtotal($item));
下列行动挂钩已添加到我使用的插件(Woocommerce复合材料产品):
add_action('woocommerce_order_formatted_line_subtotal', array($this, 'wc_cp_order_item_subtotal'), 10, 3);
我想覆盖函数wc_cp_order_item_subtotal来改变项目小计的显示方式。我曾尝试将以下内容添加到我的子主题functions.php中,但它没有做任何事情。
remove_action('woocommerce_order_formatted_line_subtotal', 'wc_cp_order_item_subtotal', 10);
add_action('woocommerce_order_formatted_line_subtotal', 'child_wc_cp_order_item_subtotal', 10, 3);
function child_wc_cp_add_order_item_meta($order_item_id, $cart_item_values, $cart_item_key = '') {
return 'xxxxxxx';
}
任何提示,以帮助我得到这个工作将不胜感激。
感谢。我使用官方的Woocommerce复合产品插件,但它看起来像在2.4.0版本中重构了代码并删除了对BTO的引用。我如何计算出我的等同于$ woocommerce_bto-> order-> woocommerce_bto的是什么? – 2014-09-25 11:11:24
它看起来像一切'bto'变成'cp','woo'变成'wc'。所以整个插件的全局变量是'$ woocommerce_composite_products',而'WC_CP_Order()'类被初始化为主类的'order'变量,因此'$ woocommerce_composite_product-> order'。我不知道从哪里得到额外的'woocommerce_bto',可能是复制/粘贴失败。 – helgatheviking 2014-09-25 12:20:43
工作原理 - 非常感谢! – 2014-09-25 12:38:40