Changeset 2761915
- Timestamp:
- 07/26/2022 04:09:47 PM (3 years ago)
- Location:
- newsmanapp/trunk
- Files:
-
- 3 edited
-
includes/class-wc-newsman-remarketing-js.php (modified) (9 diffs)
-
newsmanapp.php (modified) (1 diff)
-
wc-newsman-remarketing.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
newsmanapp/trunk/includes/class-wc-newsman-remarketing-js.php
r2760264 r2761915 164 164 165 165 var remarketingid = '$remarketingid'; 166 var _nzmPluginInfo = '2.3. 8:woocommerce';166 var _nzmPluginInfo = '2.3.9:woocommerce'; 167 167 168 168 //Newsman remarketing tracking code REPLACEABLE … … 194 194 script_dom.setAttribute('data-site-id', remarketingid); 195 195 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 } 196 203 s.parentNode.insertBefore(script_dom, s); 197 204 })(); … … 257 264 } 258 265 259 function timestamp (min, max) {266 function timestampGenerator(min, max) { 260 267 min = Math.ceil(min); 261 268 max = Math.floor(max); … … 266 273 267 274 if (!endTimePassed()) 275 { 276 if (!isProd) 277 console.log('newsman remarketing: execution stopped at the beginning, 5 seconds didn\"t pass between requests'); 278 268 279 return; 280 } 269 281 270 282 if (isError && isProd == true) { … … 278 290 if (bufferedXHR || firstLoad) { 279 291 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{ 287 300 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 } 288 308 289 309 startTimePassed(); … … 304 324 } 305 325 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 306 350 lastCart = JSON.parse(sessionStorage.getItem('lastCart')); 307 351 … … 356 400 } 357 401 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 } 359 411 360 412 } else { … … 419 471 //own request exclusion 420 472 if ( 421 pointer.responseURL.indexOf('getCart.json') >= 0 ||473 _location.indexOf('getCart.json') >= 0 || 422 474 //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 || 426 478 //opencart 1 427 pointer.responseURL.indexOf('getCart=true') >= 0 479 _location.indexOf('getCart=true') >= 0 || 480 //shopify 481 _location.indexOf('cart.js') >= 0 428 482 ) { 429 483 validate = false; 430 484 } else { 431 if (_location.indexOf(window.location.origin) !== -1) 485 //check for engine name 486 if (_nzmPluginInfo.indexOf('shopify') !== -1) { 432 487 validate = true; 488 } 489 else{ 490 if (_location.indexOf(window.location.origin) !== -1) 491 validate = true; 492 } 433 493 } 434 494 435 495 if (validate) { 436 496 bufferedXHR = true; … … 451 511 } 452 512 453 //Newsman remarketing auto events513 //Newsman remarketing auto events 454 514 "; 455 515 -
newsmanapp/trunk/newsmanapp.php
r2760263 r2761915 5 5 Plugin URI: https://github.com/Newsman/WP-Plugin-NewsmanApp 6 6 Description: NewsmanApp for Wordpress (sign up widget, subscribers sync, create and send newsletters from blog posts) 7 Version: 2.3. 87 Version: 2.3.9 8 8 Author: Newsman 9 9 Author URI: https://www.newsman.com -
newsmanapp/trunk/wc-newsman-remarketing.php
r2760268 r2761915 6 6 * Author: Newsman 7 7 * Author URI: https://newsman.com 8 * Version: 2.3. 88 * Version: 2.3.9 9 9 * WC requires at least: 2.1 10 10 * WC tested up to: 4.1
Note: See TracChangeset
for help on using the changeset viewer.