I want to send a telegram notification to my group when a new order is received on my store.
I use the following code I’ve found in another thread:
add_action( 'woocommerce_new_order', 'telegram_notification', 1, 1 );
function telegram_notification( $order_id ) {
$order = wc_get_order( $order_id );
$text = "*" . __( 'New Order') . "*nn";
$text .= __( 'Order number') . ': ' . $order_id . "n";
$text .= __( 'Status') . ': ' . wc_get_order_status_name( $order->get_status() ) . "n";
$text .= __( 'Date') . ': ' . $order->get_date_modified() . "n";
$text .= __( 'Email') . ': ' . $order->get_billing_email() . "n";
$text .= __( 'Total price') . ': ' . $order->get_total() . "n";
$text .= __( 'Payment method') . ': ' . $order->get_payment_method_title() . "n";
$xsl = file_get_contents("https://api.telegram.org/bot12345:xxxxx-zzzzz/sendMessage?parse_mode=html&chat_id=-1234567890&text=" . $text);
}
I want to also send the product names and SKU, but I can’t seem to figure it out. The original poster also had this problem.
Here’s the question thread: WooCommerce notification with Telegram
Thank you in advanced for your time.
Tried various methods but none seem to print the products and products info.