get_items(); $products = array(); foreach ($items as $item) { $quantity = $item->get_quantity(); $product = $item->get_product(); $images_arr = wp_get_attachment_image_src($product->get_image_id(), array('72', '72'), false); $image = null; if ($images_arr !== null && $images_arr[0] !== null) { $image = $images_arr[0]; if (is_ssl() && strpos($image, "https") == false) { $image = str_replace('http', 'https', $image); } } $p = array( 'id' => $product->get_id(), 'quantity' => (int) $quantity, 'price' => (int) $product->get_price(), 'name' => $product->get_name(), 'link' => get_permalink($product->get_id()), 'image' => $image, ); array_push($products, $p); } apprised_send_webhook($order, $products); } function Apprised_user_register($id) { $user = new WP_User($id); $meta = get_user_meta($id); if (!isset($user)) { return; } // apprised_log('wp user event', $user); apprised_send_user($user->user_email, $meta); } function apprised_woo_user_register($id, $data, $pass) { $user = new WP_User($id); $meta = get_user_meta($id); // apprised_log('woo user event', $user); apprised_send_user($data['user_email'], $meta); } /** hooks - END */ /** helpers */ function apprised_send_user($email, $meta) { $apiKey = apprised_get_api_key(); if (!isset($email) || !isset($apiKey)) { // apprised_log('no email or api key'); return; } $data = array( 'email' => is_email(sanitize_email($email))?sanitize_email($email):"", 'siteUrl' => get_site_url(), ); if (isset($meta['first_name'][0])) { $first_name = sanitize_text_field($meta['first_name'][0]); if ( strlen( $first_name ) > 20 ) { $first_name = substr( $first_name, 0, 20 ); } $data['firstName'] = $first_name; } elseif (isset($_POST['first_name']) && strlen($_POST['first_name']) > 0) { $first_name = sanitize_text_field($_POST['first_name']); if ( strlen( $first_name ) > 20 ) { $first_name = substr( $first_name, 0, 20 ); } $data['firstName'] = $first_name; } if (isset($meta['last_name'][0])) { $last_name = sanitize_text_field($meta['last_name'][0]); if ( strlen( $last_name ) > 20 ) { $last_name = substr( $last_name, 0, 20 ); } $data['lastName'] = $last_name; } elseif (isset($_POST['last_name']) && strlen($_POST['last_name']) > 0) { $last_name = sanitize_text_field($_POST['last_name']); if ( strlen( $last_name ) > 20 ) { $last_name = substr( $last_name, 0, 20 ); } $data['lastName'] = $last_name; } if (isset($_SERVER['REMOTE_ADDR'])) { $data['ip'] = $_SERVER['REMOTE_ADDR']; } $headers = array( 'Content-Type' => 'application/json', 'Authorization' => "Bearer $apiKey", ); $url = 'https://my.apprised.app/api/WoocommerceConversion'; $json = json_encode($data); // apprised_log('sending data', $json); $res = wp_remote_post($url, array( 'headers' => $headers, 'body' => $json, )); } function apprised_send_webhook($order, $products) { $apiKey = apprised_get_api_key(); if (!isset($apiKey)) { return; } $headers = array( 'Content-Type' => 'application/json', 'authorization' => "Bearer $apiKey", ); $data = array( 'firstName' => sanitize_text_field($order->get_billing_first_name()), 'lastName' => sanitize_text_field($order->get_billing_last_name()), 'email' =>sanitize_email( $order->get_billing_email()), 'ip' => $order->get_customer_ip_address(), 'siteUrl' => get_site_url(), 'total' => (int) $order->get_total(), 'currency' => $order->get_currency(), 'products' => $products, ); $url = 'https://my.apprised.app/api/WoocommerceConversion'; $res = wp_remote_post($url, array( 'headers' => $headers, 'body' => json_encode($data), )); } function apprised_get_api_key() { $apiKey = get_option(ApprisedConstants::option_api_key()); if (isset($apiKey) ) { return $apiKey; } return null; } function apprised_menu_page_html() { if (!current_user_can('manage_options')) { return; } $apiKey = apprised_get_api_key(); ?>
Apprised is Installed
If you still see "waiting for data..." open your website in incognito or clear cache
Your API Key:
id, 'apprised') > 0) return; ?>

Apprised is not configured! Click here