Plugin Directory

Changeset 2850359


Ignore:
Timestamp:
01/18/2023 10:04:35 AM (3 years ago)
Author:
viaads
Message:

Event-Stability Update

Location:
viaads
Files:
15 added
6 edited

Legend:

Unmodified
Added
Removed
  • viaads/trunk/hooks/addCart.php

    r2846806 r2850359  
    8080        }
    8181
     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
    8290        $data->ApiKey = get_option( "viaads_api_key" );
    8391        $data->client = $clientInfo;
  • viaads/trunk/hooks/pageLook.php

    r2846806 r2850359  
    22
    33namespace ViaAds;
     4
    45use WC_Product;
    56
     
    89use Exception;
    910
    10 defined( 'ABSPATH' ) || exit;
     11defined('ABSPATH') || exit;
    1112
    12 add_action( 'template_redirect', 'ViaAds\\ViaAds_productLook' );
    13 function ViaAds_productLook() {
     13add_action('template_redirect', 'ViaAds\\ViaAds_productLook');
     14function ViaAds_productLook()
     15{
    1416    try {
    1517        //Get product
    16         if ( is_product() ) {
     18        if (is_product()) {
    1719            global $post;
    1820            $product_id = $post->ID;
     
    2022            return;
    2123        }
    22         $product = wc_get_product( $product_id );
     24        $product = wc_get_product($product_id);
    2325
    2426        //guid//email//emailGuid
    25         if(!isset($_COOKIE[ 'ViaAds' ])) {
     27        if (!isset($_COOKIE['ViaAds'])) {
    2628            return;
    2729        }
    2830
    29         $cookieValue = sanitize_text_field($_COOKIE[ 'ViaAds' ]);
     31        $cookieValue = sanitize_text_field($_COOKIE['ViaAds']);
    3032
    31         $cookieValues = explode( "//", $cookieValue );
     33        $cookieValues = explode("//", $cookieValue);
    3234        $data = new stdClass();
    3335
    3436        //ClientInfo
    3537        $clientInfo = new stdClass();
    36         $ip = sanitize_text_field($_SERVER[ 'HTTP_X_FORWARDED_FOR' ]);
     38        $ip = sanitize_text_field($_SERVER['HTTP_X_FORWARDED_FOR']);
    3739        $clientInfo->ip = $ip;
    3840
    3941        //User Agent
    4042        $userAgentFile = realpath(dirname(plugin_dir_path(__FILE__)) . '/userAgent.php');
    41         if($userAgentFile) {
    42             require_once( $userAgentFile );
     43        if ($userAgentFile) {
     44            require_once($userAgentFile);
    4345            $ua = ViaAds_getBrowser();
    4446            $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'];
    4951            $data->user_agent = $userAgent;
    5052        }
     
    5254        //ProductPageUrl
    5355        $productPageUrl = new stdClass();
    54         $productPageUrl->full = get_permalink( $product->get_id() );
     56        $productPageUrl->full = get_permalink($product->get_id());
    5557
    5658        //Email
     
    5961        $email = ( string )$current_user->user_email;
    6062        $customer = new stdClass();
    61         if ( strlen( $email ) > 4 ) {
     63        if (strlen($email) > 4) {
    6264            $customer->Email = $email;
    6365        } else {
    64             $customer->Email = $cookieValues[ 1 ];
     66            $customer->Email = $cookieValues[1];
    6567        }
    6668
    67         $customer->Session_id = $cookieValues[ 0 ];
    68         $customer->Email_guid = $cookieValues[ 2 ];
     69        $customer->Session_id = $cookieValues[0];
     70        $customer->Email_guid = $cookieValues[2];
    6971        $data->Customer = $customer;
    7072
     
    7678        $shopEvent->Price = $product->get_price();
    7779
    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");
    7989        $data->client = $clientInfo;
    8090        $data->url = $productPageUrl;
    8191        $data->Shop_event = $shopEvent;
     92
    8293        $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) {
    8797        $error_object = new stdClass();
    8898        $error_object->Error = $e->getMessage();
    8999
    90         $currentPageUrl = sanitize_url( home_url( $_SERVER['REQUEST_URI'] ) );
     100        $currentPageUrl = sanitize_url(home_url($_SERVER['REQUEST_URI']));
    91101        $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);
    94104    }
    95105}
  • viaads/trunk/hooks/removeCart.php

    r2845940 r2850359  
    8484        }
    8585
     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
    8694        $data->ApiKey = get_option("viaads_api_key");
    8795        $data->client = $clientInfo;
  • viaads/trunk/readme.txt

    r2846806 r2850359  
    44Requires at least: 5.4
    55Tested up to: 6.1
    6 Stable tag: 1.0.7
     6Stable tag: 1.0.8
    77Requires PHP: 7.0
    88License: GPLv3
  • viaads/trunk/sync.php

    r2846806 r2850359  
    3232            ViaAds_PostToUrl("https://integration.viaads.dk/woocommerce/WebShopData", $webshop, true);
    3333        } 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);
    3539        } else {
    3640            return;
     
    132136        }
    133137
    134         if ($product->get_sale_price() != 0) {
     138        if ($product->get_sale_price() != 0 && $product->get_sale_price() != "") {
    135139            // On Sale
    136140            $product_object->OnSale = true;
     
    185189                // Regular Price
    186190                $child_object->RegularPrice = $child->get_price();
    187                 if ($child_object->RegularPrice == ""){
     191                if ($child_object->RegularPrice == "") {
    188192                    $child_object->RegularPrice = null;
    189193                }
    190194
    191195                // On Sale Data
    192                 if ($product->get_sale_price() != 0) {
     196                if ($product->get_sale_price() != 0 && $product->get_sale_price() != "") {
    193197                    // On Sale
    194198                    $child_object->OnSale = true;
     
    285289{
    286290    $orderCollection = wc_get_orders(array(
    287         'date_modified' => date('Y-m-d', strtotime(date("Y-m-d") . ' - 1 days')) . '...'
     291        'date_modified' => date('Y-m-d', strtotime(date("Y-m-d") . ' - 2 days')) . '...'
    288292            . date('Y-m-d', strtotime(date("Y-m-d") . ' + 14 days')),
    289293    ));
     294
     295    if (isset($_GET['debug1']) && $_GET['debug1'] == "tEBLZTqKDLzhEjc2Kw9mqu5vrJUB") {
     296        print_r($orderCollection);
     297    }
     298
    290299    //Test
    291300    /*$orderCollection = wc_get_orders( array(
     
    392401        $orderFinal->customer = $customer;
    393402
     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
    394411        array_push($orders, $orderFinal);
    395412    }
  • viaads/trunk/viaads.php

    r2846806 r2850359  
    33 * Plugin Name: ViaAds
    44 * Description: Plugin der muliggør forbindelsen til ViaAds / Plug-in enabling the connection to ViaAds.
    5  * Version: 1.0.7
     5 * Version: 1.0.8
    66 * Author: ViaAds
    77 * Author URI: https://www.viaads.dk/
Note: See TracChangeset for help on using the changeset viewer.