1 回答

TA貢獻1809條經驗 獲得超8個贊
這與訂單商品有關,應另存為訂單商品元數據,而不能另存為訂單元數據。
現在,這應該與您的2個自定義字段quantity和同時保存assemblycost。因此,您應該在問題中提供保存quantity和assemblycost作為訂單項元數據的相關代碼。
您可以嘗試以下操作(但是我不確定是否可以使用):
add_action( 'woocommerce_checkout_create_order_line_item', 'action_checkout_create_order_line_item_callback', 1000, 4 );
function action_checkout_create_order_line_item_callback( $item, $cart_item_key, $cart_item, $order ) {
$quantity = $item->get_meta('quantity');
$assemblycost = $item->get_meta('assemblycost');
if( isset($quantity) && isset($assemblycost) ) {
$item->update_meta_data( 'calculated_field', $quantity * $assemblycost );
}
}
代碼進入您的活動子主題(或活動主題)的function.php文件中。
- 1 回答
- 0 關注
- 185 瀏覽
添加回答
舉報