Changeset 2850359
- Timestamp:
- 01/18/2023 10:04:35 AM (3 years ago)
- Location:
- viaads
- Files:
-
- 15 added
- 6 edited
-
tags/1.0.8 (added)
-
tags/1.0.8/apikey.php (added)
-
tags/1.0.8/externalJS.php (added)
-
tags/1.0.8/handleEmailGuid.php (added)
-
tags/1.0.8/hooks (added)
-
tags/1.0.8/hooks/addCart.php (added)
-
tags/1.0.8/hooks/pageLook.php (added)
-
tags/1.0.8/hooks/removeCart.php (added)
-
tags/1.0.8/http.php (added)
-
tags/1.0.8/js (added)
-
tags/1.0.8/js/viaads_handleEmailGuid.js (added)
-
tags/1.0.8/readme.txt (added)
-
tags/1.0.8/sync.php (added)
-
tags/1.0.8/userAgent.php (added)
-
tags/1.0.8/viaads.php (added)
-
trunk/hooks/addCart.php (modified) (1 diff)
-
trunk/hooks/pageLook.php (modified) (6 diffs)
-
trunk/hooks/removeCart.php (modified) (1 diff)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/sync.php (modified) (5 diffs)
-
trunk/viaads.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
viaads/trunk/hooks/addCart.php
r2846806 r2850359 80 80 } 81 81 82 //Plugin 83 $path = dirname(dirname(__FILE__)) . '/viaads.php'; 84 $pluginData = get_plugin_data($path); 85 $plugin = new stdClass(); 86 $plugin->Name = "WooCommerce"; 87 $plugin->Version = $pluginData['Version']; 88 $data->Plugin = $plugin; 89 82 90 $data->ApiKey = get_option( "viaads_api_key" ); 83 91 $data->client = $clientInfo; -
viaads/trunk/hooks/pageLook.php
r2846806 r2850359 2 2 3 3 namespace ViaAds; 4 4 5 use WC_Product; 5 6 … … 8 9 use Exception; 9 10 10 defined( 'ABSPATH') || exit;11 defined('ABSPATH') || exit; 11 12 12 add_action( 'template_redirect', 'ViaAds\\ViaAds_productLook' ); 13 function ViaAds_productLook() { 13 add_action('template_redirect', 'ViaAds\\ViaAds_productLook'); 14 function ViaAds_productLook() 15 { 14 16 try { 15 17 //Get product 16 if ( is_product()) {18 if (is_product()) { 17 19 global $post; 18 20 $product_id = $post->ID; … … 20 22 return; 21 23 } 22 $product = wc_get_product( $product_id);24 $product = wc_get_product($product_id); 23 25 24 26 //guid//email//emailGuid 25 if (!isset($_COOKIE[ 'ViaAds'])) {27 if (!isset($_COOKIE['ViaAds'])) { 26 28 return; 27 29 } 28 30 29 $cookieValue = sanitize_text_field($_COOKIE[ 'ViaAds']);31 $cookieValue = sanitize_text_field($_COOKIE['ViaAds']); 30 32 31 $cookieValues = explode( "//", $cookieValue);33 $cookieValues = explode("//", $cookieValue); 32 34 $data = new stdClass(); 33 35 34 36 //ClientInfo 35 37 $clientInfo = new stdClass(); 36 $ip = sanitize_text_field($_SERVER[ 'HTTP_X_FORWARDED_FOR']);38 $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']); 37 39 $clientInfo->ip = $ip; 38 40 39 41 //User Agent 40 42 $userAgentFile = realpath(dirname(plugin_dir_path(__FILE__)) . '/userAgent.php'); 41 if ($userAgentFile) {42 require_once( $userAgentFile);43 if ($userAgentFile) { 44 require_once($userAgentFile); 43 45 $ua = ViaAds_getBrowser(); 44 46 $userAgent = new stdClass(); 45 $userAgent->device_name = $ua[ 'platform'];46 $userAgent->name = $ua[ 'name'];47 $userAgent->original = sanitize_text_field($_SERVER[ 'HTTP_USER_AGENT']);48 $userAgent->version = $ua[ 'version'];47 $userAgent->device_name = $ua['platform']; 48 $userAgent->name = $ua['name']; 49 $userAgent->original = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); 50 $userAgent->version = $ua['version']; 49 51 $data->user_agent = $userAgent; 50 52 } … … 52 54 //ProductPageUrl 53 55 $productPageUrl = new stdClass(); 54 $productPageUrl->full = get_permalink( $product->get_id());56 $productPageUrl->full = get_permalink($product->get_id()); 55 57 56 58 //Email … … 59 61 $email = ( string )$current_user->user_email; 60 62 $customer = new stdClass(); 61 if ( strlen( $email ) > 4) {63 if (strlen($email) > 4) { 62 64 $customer->Email = $email; 63 65 } else { 64 $customer->Email = $cookieValues[ 1];66 $customer->Email = $cookieValues[1]; 65 67 } 66 68 67 $customer->Session_id = $cookieValues[ 0];68 $customer->Email_guid = $cookieValues[ 2];69 $customer->Session_id = $cookieValues[0]; 70 $customer->Email_guid = $cookieValues[2]; 69 71 $data->Customer = $customer; 70 72 … … 76 78 $shopEvent->Price = $product->get_price(); 77 79 78 $data->ApiKey = get_option( "viaads_api_key" ); 80 //Plugin 81 $path = dirname(dirname(__FILE__)) . '/viaads.php'; 82 $pluginData = get_plugin_data($path); 83 $plugin = new stdClass(); 84 $plugin->Name = "WooCommerce"; 85 $plugin->Version = $pluginData['Version']; 86 $data->Plugin = $plugin; 87 88 $data->ApiKey = get_option("viaads_api_key"); 79 89 $data->client = $clientInfo; 80 90 $data->url = $productPageUrl; 81 91 $data->Shop_event = $shopEvent; 92 82 93 $date = new DateTime(); 83 $data->Event_date = $date->format( 'Y-m-d\TH:i:s' ); 84 85 ViaAds_PostToUrlEvent( "https://integration.viaads.dk/woocommerce/event", $data ); 86 } catch ( Exception $e ) { 94 $data->Event_date = $date->format('Y-m-d\TH:i:s'); 95 ViaAds_PostToUrlEvent("https://integration.viaads.dk/woocommerce/event", $data); 96 } catch (Exception $e) { 87 97 $error_object = new stdClass(); 88 98 $error_object->Error = $e->getMessage(); 89 99 90 $currentPageUrl = sanitize_url( home_url( $_SERVER['REQUEST_URI'] ));100 $currentPageUrl = sanitize_url(home_url($_SERVER['REQUEST_URI'])); 91 101 $error_object->Url = wp_http_validate_url($currentPageUrl); 92 93 ViaAds_PostToUrlEvent( "https://integration.viaads.dk/error", $error_object);102 103 ViaAds_PostToUrlEvent("https://integration.viaads.dk/error", $error_object); 94 104 } 95 105 } -
viaads/trunk/hooks/removeCart.php
r2845940 r2850359 84 84 } 85 85 86 //Plugin 87 $path = dirname(dirname(__FILE__)) . '/viaads.php'; 88 $pluginData = get_plugin_data($path); 89 $plugin = new stdClass(); 90 $plugin->Name = "WooCommerce"; 91 $plugin->Version = $pluginData['Version']; 92 $data->Plugin = $plugin; 93 86 94 $data->ApiKey = get_option("viaads_api_key"); 87 95 $data->client = $clientInfo; -
viaads/trunk/readme.txt
r2846806 r2850359 4 4 Requires at least: 5.4 5 5 Tested up to: 6.1 6 Stable tag: 1.0. 76 Stable tag: 1.0.8 7 7 Requires PHP: 7.0 8 8 License: GPLv3 -
viaads/trunk/sync.php
r2846806 r2850359 32 32 ViaAds_PostToUrl("https://integration.viaads.dk/woocommerce/WebShopData", $webshop, true); 33 33 } else if ($_GET['event'] == "orders") { 34 ViaAds_PostToUrl("https://integration.viaads.dk/woocommerce/WebShopOrderData", ViaAds_getOrders(), true); 34 $orders = ViaAds_getOrders(); 35 if (isset($_GET['debug']) && $_GET['debug'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") { 36 print_r($orders); 37 } 38 ViaAds_PostToUrl("https://integration.viaads.dk/woocommerce/WebShopOrderData", $orders, true); 35 39 } else { 36 40 return; … … 132 136 } 133 137 134 if ($product->get_sale_price() != 0 ) {138 if ($product->get_sale_price() != 0 && $product->get_sale_price() != "") { 135 139 // On Sale 136 140 $product_object->OnSale = true; … … 185 189 // Regular Price 186 190 $child_object->RegularPrice = $child->get_price(); 187 if ($child_object->RegularPrice == "") {191 if ($child_object->RegularPrice == "") { 188 192 $child_object->RegularPrice = null; 189 193 } 190 194 191 195 // On Sale Data 192 if ($product->get_sale_price() != 0 ) {196 if ($product->get_sale_price() != 0 && $product->get_sale_price() != "") { 193 197 // On Sale 194 198 $child_object->OnSale = true; … … 285 289 { 286 290 $orderCollection = wc_get_orders(array( 287 'date_modified' => date('Y-m-d', strtotime(date("Y-m-d") . ' - 1days')) . '...'291 'date_modified' => date('Y-m-d', strtotime(date("Y-m-d") . ' - 2 days')) . '...' 288 292 . date('Y-m-d', strtotime(date("Y-m-d") . ' + 14 days')), 289 293 )); 294 295 if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") { 296 print_r($orderCollection); 297 } 298 290 299 //Test 291 300 /*$orderCollection = wc_get_orders( array( … … 392 401 $orderFinal->customer = $customer; 393 402 403 //Plugin 404 $path = dirname(__FILE__) . '/viaads.php'; 405 $pluginData = get_plugin_data($path); 406 $plugin = new stdClass(); 407 $plugin->Name = "WooCommerce"; 408 $plugin->Version = $pluginData['Version']; 409 $orderFinal->Plugin = $plugin; 410 394 411 array_push($orders, $orderFinal); 395 412 } -
viaads/trunk/viaads.php
r2846806 r2850359 3 3 * Plugin Name: ViaAds 4 4 * Description: Plugin der muliggør forbindelsen til ViaAds / Plug-in enabling the connection to ViaAds. 5 * Version: 1.0. 75 * Version: 1.0.8 6 6 * Author: ViaAds 7 7 * Author URI: https://www.viaads.dk/
Note: See TracChangeset
for help on using the changeset viewer.