I'm trying to create a custom meta_key
in woocommerce_order_itemmeta
table for (unit price excluding tax) to use later.
I added the below code but I keep getting an error on the checkout page, showing only the red mark with 'Internal Server Error
'.
Someone who knows where things are going wrong?
// Save custom data to order item meta data
add_action( 'woocommerce_add_order_item_meta', 'unit_price_order_itemmeta', 10, 3 );
function unit_price_order_itemmeta( $item_id, $values, $cart_item_key ) {
$unit_price = wc_get_price_excluding_tax( $product );
wc_add_order_item_meta( $item_id, '_unit_price', $unit_price , false );
}