1 回答

TA貢獻1752條經驗 獲得超4個贊
好的,處理此問題的最佳簡單方法是向所有登錄的驅動程序用戶發送推送通知?;旧?,查詢在 WordPress 中具有驅動程序角色的運行會話的所有用戶。然后,迭代這些嘗試向每個人發送通知。像這樣更改函數:
/**
?* Add a notification when a new woocommerce order is recieved.
?*
?*/
add_action('woocommerce_thankyou', 'wpmobileapp_woo_order', 10, 1 );
function wpmobileapp_woo_order($order_id) {
? ??
? ??
? $order = new WC_Order( $order_id );
? $items = $order->get_items();
? $customer_address = $order->get_billing_address();
?
? $user_email = $user_meta->user_email;
? $image_url = '';
? $link = '';
? ??
? $title = "new order";
? $message = $order . ', ' . $items . ', ' . $customer_address;
? // get all users with role 'driver' and an active WP session:
? $drivers = get_users([
? ? 'role' => 'driver',
? ? 'meta_key' => 'session_tokens',
? ? 'meta_compare' => 'EXISTS'
? ]);
? // notify each of these by push notification
? foreach ($drivers as $driver) {
? ? $driver_email = $driver->user_email;
? ? wpmobileapp_push($title, $message , $image_url, $link, $lang_2letters = 'all', $send_timestamp = '', $driver_email);
? ? error_log("WooCommerce Driver notification: sending push notification to account of $driver_email");
? }
}
您可以啟用WP_DEBUG并WP_DEBUG_LOG檢查哪個驅動程序帳戶應該收到推送通知。如果存在日志消息,但您的測試驅動程序用戶沒有收到通知,可能您需要進一步測試此 wpmobileapp_push 內容。
- 1 回答
- 0 關注
- 112 瀏覽
添加回答
舉報