/** * Plugin Name: WooCommerce Telegram 배송완료 알림 (Multi-Site) * Description: empresskorea.com, stylemz.com, skinseoulshop.com 주문이 배송 완료되면 Telegram으로 Fulfilled 메시지를 전송합니다. * Version: 1.1 * Author: Empress Korea */ if (!defined('ABSPATH')) exit; add_action('woocommerce_order_status_completed', 'ek_send_fulfilled_telegram_message_multisite'); function ek_send_fulfilled_telegram_message_multisite($order_id) { $order = wc_get_order($order_id); if (!$order) return; // ✅ 사이트 도메인 분기 $host = $_SERVER['HTTP_HOST'] ?? ''; $site_map = [ 'empresskorea.com' => ['name' => '🌸 Empress Korea'], 'stylemz.com' => ['name' => '👗 StyleMZ'], 'skinseoulshop.com' => ['name' => '🧴 Skin Seoul Shop'], ]; if (!isset($site_map[$host])) return; $site_name = $site_map[$host]['name']; // ✅ 주문 정보 $customer_name = trim($order->get_billing_first_name() . ' ' . $order->get_billing_last_name()); $order_date = $order->get_date_created() ? $order->get_date_created()->date('Y-m-d') : date('Y-m-d'); $country = $order->get_shipping_country() ?: 'N/A'; $shipping_total = number_format($order->get_shipping_total(), 2); // ✅ 아이템 정보 $items = []; foreach ($order->get_items() as $item) { $items[] = '• ' . $item->get_name() . ' x' . $item->get_quantity() . ' = $' . number_format($item->get_total(), 2); } // ✅ 메시지 $message = "📦 {$site_name} Fulfilled 🧾 Order ID: {$order_id} 👤 Customer: {$customer_name} 📅 Date: {$order_date} 🌍 Country: {$country} 🚚 Shipping: {$shipping_total} USD 🛒 Items: " . implode("\n", $items); // ✅ 텔레그램 전송 $TELEGRAM_BOT_TOKEN = '7284506085:AAF2KUcnCiEWwU746OFiqOaZr2V60bQE9S8'; $TELEGRAM_CHAT_ID = '-1001776338940'; $telegram_url = "https://api.telegram.org/bot{$TELEGRAM_BOT_TOKEN}/sendMessage"; $response = wp_remote_post($telegram_url, [ 'headers' => ['Content-Type' => 'application/json; charset=utf-8'], 'body' => json_encode([ 'chat_id' => $TELEGRAM_CHAT_ID, 'text' => $message, // parse_mode 제거 → 이스케이프 불필요 ]), 'method' => 'POST', 'timeout' => 10, ]); if (is_wp_error($response)) { error_log('[Telegram Fulfilled] 전송 실패: ' . $response->get_error_message()); } } Welcome to Empress Korea | Premium K-Beauty & Lifestyle - EmpressKorea
We ship worldwide, with all orders dispatched from Korea.
Time to refresh your wardrobe. Shop Now
Sale discount off 30%
Shipping Discount: 12% of Your Total Purchase!
Delivered with the latest products from Korea.
Only the Latest Korean Products — Delivered with Care.

New Arrivals

Shop
Search
Account
0 Wishlist
2 Cart
Shopping Cart