I created a code to add text in an email for a specific product. I want to retrieve the price of the product but it does not work. It gives me an error when ordering "There was an error processing the order. Please try again."
Here is the code :
add_action( 'woocommerce_email_before_order_table', 'esprit_add_content_specific_email', 20, 4 );
function esprit_add_content_specific_email( $order, $sent_to_admin, $plain_text, $email ) {
global $woocommerce;
$items = $order->get_items();
foreach ( $items as $item ) {
$product_id = $item['product_id'];
$price = $product_id->get_price();
if ( $product_id == 3550 ) {
echo 'Message uniquement sur la carte cadeaux libre.';
echo "id";
echo $product_id;
echo "prix";
echo $price;
}
}
}
I manage to retrieve the product id but not the "get_price()".
Please, any help for me. Sorry for my english :-)