Plugin Directory

Changeset 2761915


Ignore:
Timestamp:
07/26/2022 04:09:47 PM (3 years ago)
Author:
newsmanapp
Message:

improvements

Location:
newsmanapp/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • newsmanapp/trunk/includes/class-wc-newsman-remarketing-js.php

    r2760264 r2761915  
    164164
    165165        var remarketingid = '$remarketingid';
    166         var _nzmPluginInfo = '2.3.8:woocommerce';
     166        var _nzmPluginInfo = '2.3.9:woocommerce';
    167167       
    168168        //Newsman remarketing tracking code REPLACEABLE
     
    194194            script_dom.setAttribute('data-site-id', remarketingid);
    195195            script_dom.src = remarketingEndpoint;
     196            //check for engine name
     197            if (_nzmPluginInfo.indexOf('shopify') !== -1) {
     198                script_dom.onload = function(){
     199                    if (typeof newsmanRemarketingLoad === 'function')
     200                        newsmanRemarketingLoad();
     201                }
     202            }
    196203            s.parentNode.insertBefore(script_dom, s);
    197204        })();
     
    257264        }
    258265
    259         function timestamp(min, max) {
     266        function timestampGenerator(min, max) {
    260267            min = Math.ceil(min);
    261268            max = Math.floor(max);
     
    266273
    267274            if (!endTimePassed())
     275            {
     276                if (!isProd)
     277                    console.log('newsman remarketing: execution stopped at the beginning, 5 seconds didn\"t pass between requests');
     278
    268279                return;
     280            }
    269281
    270282            if (isError && isProd == true) {
     
    278290            if (bufferedXHR || firstLoad) {
    279291
    280                 var paramChar = '?t=';
    281 
    282                 if (ajaxurl.indexOf('?') >= 0)
    283                     paramChar = '&t=';
    284 
    285                 var timestamp = paramChar + Date.now() + this.timestamp(999, 999999999);
    286 
     292            var paramChar = '?t=';
     293
     294            if (ajaxurl.indexOf('?') >= 0)
     295                paramChar = '&t=';
     296
     297            var timestamp = paramChar + Date.now() + timestampGenerator(999, 999999999);
     298
     299            try{
    287300                xhr.open('GET', ajaxurl + timestamp, true);
     301            }
     302            catch(ex){
     303                if (!isProd)
     304                console.log('newsman remarketing: malformed XHR url');
     305
     306                isError = true;
     307            }
    288308
    289309                startTimePassed();
     
    304324                        }
    305325
     326                        //check for engine name
     327                        if (_nzmPluginInfo.indexOf('shopify') !== -1) {
     328
     329                            var products = [];
     330
     331                            if(response.item_count > 0)
     332                            {
     333                                response.items.forEach(function(item){
     334                               
     335                                    products.push(
     336                                        {
     337                                            'id': item.id,
     338                                            'name': item.product_title,
     339                                            'quantity': item.quantity,
     340                                            'price': item.price
     341                                        }
     342                                    );
     343
     344                                });
     345                            }
     346
     347                            response = products;
     348                        }
     349
    306350                        lastCart = JSON.parse(sessionStorage.getItem('lastCart'));
    307351
     
    356400                }
    357401
    358                 xhr.send(null);
     402                try{
     403                    xhr.send(null);
     404                }
     405                catch(ex){
     406                    if (!isProd)
     407                    console.log('newsman remarketing: error on xhr send');
     408
     409                isError = true;
     410                }
    359411
    360412            } else {
     
    419471                    //own request exclusion
    420472                    if (
    421                                     pointer.responseURL.indexOf('getCart.json') >= 0 ||
     473                                    _location.indexOf('getCart.json') >= 0 ||
    422474                                    //magento 2.x
    423                                     pointer.responseURL.indexOf('/static/') >= 0 ||
    424                                     pointer.responseURL.indexOf('/pub/static') >= 0 ||
    425                                     pointer.responseURL.indexOf('/customer/section') >= 0 ||
     475                                    _location.indexOf('/static/') >= 0 ||
     476                                    _location.indexOf('/pub/static') >= 0 ||
     477                                    _location.indexOf('/customer/section') >= 0 ||
    426478                                    //opencart 1
    427                                     pointer.responseURL.indexOf('getCart=true') >= 0
     479                                    _location.indexOf('getCart=true') >= 0 ||
     480                                    //shopify
     481                                    _location.indexOf('cart.js') >= 0
    428482                    ) {
    429483                        validate = false;
    430484                    } else {
    431                         if (_location.indexOf(window.location.origin) !== -1)
     485                        //check for engine name
     486                        if (_nzmPluginInfo.indexOf('shopify') !== -1) {
    432487                            validate = true;
     488                        }
     489                        else{
     490                            if (_location.indexOf(window.location.origin) !== -1)
     491                            validate = true;
     492                        }
    433493                    }
    434  
     494
    435495                    if (validate) {
    436496                        bufferedXHR = true;
     
    451511        }
    452512
    453          //Newsman remarketing auto events
     513        //Newsman remarketing auto events
    454514        ";
    455515       
  • newsmanapp/trunk/newsmanapp.php

    r2760263 r2761915  
    55Plugin URI: https://github.com/Newsman/WP-Plugin-NewsmanApp
    66Description: NewsmanApp for Wordpress (sign up widget, subscribers sync, create and send newsletters from blog posts)
    7 Version: 2.3.8
     7Version: 2.3.9
    88Author: Newsman
    99Author URI: https://www.newsman.com
  • newsmanapp/trunk/wc-newsman-remarketing.php

    r2760268 r2761915  
    66 * Author: Newsman
    77 * Author URI: https://newsman.com
    8  * Version: 2.3.8
     8 * Version: 2.3.9
    99 * WC requires at least: 2.1
    1010 * WC tested up to: 4.1
Note: See TracChangeset for help on using the changeset viewer.