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