Plugin Directory

Changeset 2513764


Ignore:
Timestamp:
04/13/2021 05:41:31 AM (5 years ago)
Author:
delabon
Message:

Version 3.0.0

Location:
woomotiv
Files:
1 added
9 edited
1 copied

Legend:

Unmodified
Added
Removed
  • woomotiv/trunk/index.php

    r2495355 r2513764  
    44 * Plugin Name: Woomotiv - Live Sales Notification for Woocommerce
    55 * Description: Laverage social proof to increase trust, traffic and sales.
    6  * Version: 2.15.5
     6 * Version: 3.0.0
    77 * Author: Sabri Taieb
    88 * Author Uri: https://delabon.com
     
    1818
    1919# Defined
    20 define( 'WOOMOTIV_VERSION', '2.15.5' );
     20define( 'WOOMOTIV_VERSION', '3.0.0' );
    2121define( 'WOOMOTIV_URL', plugins_url( '', __FILE__ ) );
    2222define( 'WOOMOTIV_DIR', __DIR__ );
  • woomotiv/trunk/js/front.js

    r2415564 r2513764  
    11/**
    2  * Plugin
     2 * Woomotive plugin (Frontend script)
    33 */
    4 (function( $ ){
     4 (function( $ ){
    55   
    66    var win = $( window );
     
    88    var nonce = woomotivObj.nonce;
    99    var ajax_url = woomotivObj.ajax_url;
     10    var isFirstGetItemsCall = true;
    1011    var timer = false;
    1112    var secTimer = false;
     
    1718    var cancelAnimationFrame = window.cancelAnimationFrame || window.mozCancelAnimationFrame;
    1819    var requestAnimID;
    19 
    20     function whichTransitionEvent(){
     20    var excluded = {
     21        orders: [],
     22        reviews: [],
     23        custom: [],
     24    };
     25    var isNoRepeaEnabled = parseInt(woomotivObj.is_no_repeat_enabled);
     26    var excludedOrdersKey = 'woomotiv_seen_orders_' + woomotivObj.site_hash;
     27    var excludedReviewsKey = 'woomotiv_seen_reviews_' + woomotivObj.site_hash;
     28    var excludedCustomPopKey = 'woomotiv_seen_custompop_' + woomotivObj.site_hash;
     29
     30    function whichTransitionEndEvent(){
    2131        var t;
    2232        var el = document.createElement('fakeelement');
     
    3545    }
    3646
    37     function whichAnimationEvent(){
     47    function whichAnimationEndEvent(){
    3848       
    3949        var t;
     
    5464    }
    5565
    56     var transitionEvent = whichTransitionEvent();
    57     var animationEvent = whichAnimationEvent();
     66    function whichTransitionStartEvent(){
     67
     68        var t;
     69        var el = document.createElement('fakeelement');
     70
     71        var transitions = {
     72          'transition':'transitionstart',
     73          'OTransition':'oTransitionStart',
     74          'MozTransition':'transitionstart',
     75          'WebkitTransition':'webkitTransitionStart'
     76        }
     77   
     78        for(t in transitions){
     79            if( el.style[t] !== undefined ){
     80                return transitions[t];
     81            }
     82        }
     83    }
     84
     85    function whichAnimationStartEvent(){
     86       
     87        var t;
     88        var el = document.createElement('fakeelement');
     89
     90        var transitions = {
     91          'animation':'animationstart',
     92          'OAnimation':'oAnimationStart',
     93          'MozAnimation':'animationstart',
     94          'WebkitAnimation':'webkitAnimationStart'
     95        }
     96   
     97        for(t in transitions){           
     98            if( el.style[t] !== undefined ){
     99                return transitions[t];
     100            }
     101        }
     102    }
     103
     104    var transitionEndEvent = whichTransitionEndEvent();
     105    var animationEndEvent = whichAnimationEndEvent();
     106    var transitionStartEvent = whichTransitionStartEvent();
     107    var animationStartEvent = whichAnimationStartEvent();
    58108    var transitionAnimations = [ 'fade', 'slideup', 'slidedown', 'slideright', 'slideleft' ];
     109    var tStartEvent = transitionAnimations.indexOf( woomotivObj.animation ) != -1 ? transitionStartEvent : animationStartEvent;
     110    var tEndEvent = transitionAnimations.indexOf( woomotivObj.animation ) != -1 ? transitionEndEvent : animationEndEvent;
    59111
    60112    /**
     
    113165        cindex = parseInt( cindex );
    114166
    115         if( ! items.eq( cindex ).length ) cindex = 0;
     167        // No more items
     168        if( ! items.eq( cindex ).length ){
     169           
     170            if( isNoRepeaEnabled ){
     171                excluded.orders = getExcludedOrdersFromStorage();
     172                excluded.reviews = getExcludedReviewsFromStorage();
     173                excluded.custom = getExcludedCustomPopsFromStorage();
     174            }
     175
     176            getItems(excluded);
     177        }
    116178
    117179        var item = items.eq( cindex );
    118         var cevent = transitionAnimations.indexOf( item.data('animation') ) != -1 ? transitionEvent : animationEvent;
    119 
    120         item.addClass('wmt-current').one( cevent , function(){
    121 
     180
     181        // Show element
     182        item.addClass('wmt-current');
     183
     184        // item.one( tStartEvent, function(){
     185        //     console.log(this);
     186        // });
     187
     188        // First one fires after element is completelty visible
     189        // Second one after element is completetly hidden
     190        item.one( tEndEvent , function(){
     191
     192            // Update excluded
     193            if( item.is('[data-type="order"]') ){
     194                addExcludedOrder( parseInt( item.attr('data-order') ) );
     195            }
     196            else if( item.is('[data-type="review"]') ){
     197                addExcludedReview( parseInt( item.attr('data-review') ) );
     198            }
     199            else if( item.is('[data-type="custom"]') ){
     200                addExcludedCustomPop( parseInt( item.attr('data-id') ) );
     201            }
     202           
     203            // Hide element
    122204            secTimer = setTimeout(function(){
    123 
    124205                item.removeClass('wmt-current');
    125206
    126                 timer = setTimeout( function(){
    127 
    128                     start( cindex + 1 );
    129                    
    130                 }, intervalTime );
     207                // after animation is completed show the next one
     208                item.one( tEndEvent , function(){
     209                           
     210                    timer = setTimeout( function(){
     211
     212                        // Next one
     213                        start( cindex + 1 );
     214                       
     215                    }, intervalTime );
     216
     217                });
    131218
    132219            }, hideTime );
    133 
    134         });
    135 
    136     }
    137 
    138     // Get items and create html nodes
    139     ajax( 'get_items' ).done( function( response ){
    140 
    141         if( ! response.hasOwnProperty( 'data' ) ) return;
    142         if( response.data.length === 0 ) return;
    143 
    144         if( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) ){
    145             var pause_date = new Date( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) );
    146 
    147             if( pause_date > new Date() ){
    148                 return;
    149             }
    150         }
    151        
    152         response.data.map(function( item ){
    153             body.append( item.markup );
    154         });
    155 
    156         // show time
    157         items = $('.woomotiv-popup');
    158        
    159         setTimeout(function(){
     220        });
     221    }
     222
     223    /**
     224     * Add excluded order to storage
     225     * @param {*} orderId
     226     */
     227    function addExcludedOrder( orderId ){
     228
     229        // No dulication
     230        excluded.orders = excluded.orders.filter(function( item ){
     231            if( item == orderId ) return false;
     232
     233            return true;
     234        });
     235       
     236        excluded.orders.push(orderId);
     237
     238        if( ! isNoRepeaEnabled ) return;
     239
     240        var orders = getExcludedOrdersFromStorage();
     241        var isFound = false;
     242
     243        orders.map(function( item ){
     244            if( item == orderId ) isFound = true;
     245        });
     246
     247        if( ! isFound ){
     248            orders.push(orderId);
     249            localStorage.setItem( excludedOrdersKey, orders.join(',') );
     250        }
     251    }
     252
     253    /**
     254     * Add excluded review to storage
     255     * @param {*} reviewId
     256     */
     257     function addExcludedReview( reviewId ){
     258       
     259        // No dulication
     260        excluded.reviews = excluded.reviews.filter(function( item ){
     261            if( item == reviewId ) return false;
     262
     263            return true;
     264        });
     265
     266        excluded.reviews.push(reviewId);
     267
     268        if( ! isNoRepeaEnabled ) return;
     269
     270        var reviews = getExcludedReviewsFromStorage();
     271        var isFound = false;
     272
     273        reviews.map(function( item ){
     274            if( item == reviewId ) isFound = true;
     275        });
     276
     277        if( ! isFound ){
     278            reviews.push(reviewId);
     279            localStorage.setItem( excludedReviewsKey, reviews.join(',') );
     280        }
     281    }
     282
     283    /**
     284     * Add excluded custom popup to storage
     285     * @param {*} reviewId
     286     */
     287     function addExcludedCustomPop( id ){
     288       
     289        // No dulication
     290        excluded.custom = excluded.custom.filter(function( item ){
     291            if( item == id ) return false;
     292
     293            return true;
     294        });
     295
     296        excluded.custom.push( id );
     297
     298        if( ! isNoRepeaEnabled ) return;
     299
     300        var customPops = getExcludedCustomPopsFromStorage();
     301        var isFound = false;
     302
     303        customPops.map(function( item ){
     304            if( item == id ) isFound = true;
     305        });
     306
     307        if( ! isFound ){
     308            customPops.push(id);
     309            localStorage.setItem( excludedCustomPopKey, customPops.join(',') );
     310        }
     311    }
     312
     313    /**
     314     * Return excluded orders from localStorage
     315     *
     316     * @returns {array}
     317     */
     318    function getExcludedOrdersFromStorage(){
     319
     320        var orders = localStorage.getItem( excludedOrdersKey );
     321        orders = ! orders ? [] : orders.split(',');
     322
     323        return orders.filter(function(item){
     324
     325            if( item === "" ) return false;
     326
     327            return true;
     328        });
     329    }
     330
     331    /**
     332     * Return excluded reviews from localStorage
     333     *
     334     * @returns {array}
     335     */
     336    function getExcludedReviewsFromStorage(){
     337
     338        var reviews = localStorage.getItem( excludedReviewsKey );
     339        reviews = ! reviews ? [] : reviews.split(',');
     340
     341        return reviews.filter(function(item){
    160342           
    161             requestAnimID = requestAnimationFrame( function(){
    162                 start( 0 );
     343            if( item === "" ) return false;
     344
     345            return true;
     346        });
     347    }
     348
     349    /**
     350     * Return excluded custom popups from localStorage
     351     *
     352     * @returns {array}
     353     */
     354     function getExcludedCustomPopsFromStorage(){
     355
     356        var customPops = localStorage.getItem( excludedCustomPopKey );
     357        customPops = ! customPops ? [] : customPops.split(',');
     358
     359        return customPops.filter(function(item){
     360           
     361            if( item === "" ) return false;
     362
     363            return true;
     364        });
     365    }
     366
     367    /**
     368     * Clear localStorage
     369     */
     370    function clearLocalStorage(){
     371        localStorage.removeItem( excludedOrdersKey );
     372        localStorage.removeItem( excludedReviewsKey );
     373        localStorage.removeItem( excludedCustomPopKey );
     374    }
     375
     376    /**
     377     * Get items using ajax
     378     */
     379    function getItems( excluded ){
     380
     381        // Get items and create html nodes
     382        ajax( 'get_items', {
     383            excluded: excluded,
     384        }).done( function( response ){
     385
     386            if( ! response.hasOwnProperty( 'data' ) ) return;
     387            if( response.data.length === 0 && isFirstGetItemsCall ) return;
     388
     389            isFirstGetItemsCall = false;
     390
     391            // No more orders
     392            if( response.data.length === 0 ){
     393
     394                if( isNoRepeaEnabled ){
     395                    clearLocalStorage();
     396                }
     397
     398                excluded.orders = [];
     399                excluded.reviews = [];
     400                excluded.custom = [];
     401
     402                getItems(excluded);
     403            }
     404
     405            if( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) ){
     406                var pause_date = new Date( localStorage.getItem('woomotiv_pause_date_' + woomotivObj.site_hash ) );
     407
     408                if( pause_date > new Date() ){
     409                    return;
     410                }
     411            }
     412           
     413            // Remove the old ones
     414            if( items ){
     415                items.remove();
     416            }
     417
     418            // Add the new ones
     419            response.data.map(function( item ){
     420                body.append( item.markup );
    163421            });
    164422
    165         }, parseInt( intervalTime / 2 ) );
    166 
    167         items.on( 'mouseenter', function( event ){
    168             clearTimeout( timer );
    169             clearTimeout( secTimer );
    170             cancelAnimationFrame(requestAnimID);
    171         });
    172 
    173         items.on( 'mouseleave', function( event ){
    174 
    175             var item = items.filter('.wmt-current');
    176             var index = item.data('index');
    177             var halftime = parseInt( hideTime / 2 );
    178 
    179             if( index === undefined ) return;
    180            
     423            items = $('.woomotiv-popup');
     424
     425            // show time
    181426            setTimeout(function(){
    182 
    183                 item.removeClass('wmt-current');
    184                
    185             }, halftime );
    186 
    187             setTimeout( function (){
    188427               
    189428                requestAnimID = requestAnimationFrame( function(){
    190                     start( item.data('index') + 1 );
     429                    start( 0 );
    191430                });
    192431
    193             }, ( hideTime + hideTime ) );
    194 
    195         });
    196 
    197         items.find('.woomotiv-close').on( 'click', function( event ){
    198             items.remove();
    199             localStorage.setItem('woomotiv_pause_date_' + woomotivObj.site_hash , dateAdd( new Date(), 'minute', 30 ) );
    200         });
    201 
    202         // Stats Update
    203         items.on( 'click', function( event ){
    204 
    205             event.preventDefault();
    206 
    207             var self = $(this);
    208             var data = {};
    209 
    210             if( self.data('type') === 'order' ){
    211                 data.type = 'order';
    212                 data.product_id = self.data('product');
    213             }
    214             else if( self.data('type') === 'review' ){
    215                 data.type = 'review';
    216                 data.product_id = self.data('product');
    217             }
    218             else{
    219                 data.type = 'custom';
    220                 data.id = self.data('id');
    221             }
    222 
    223             ajax( 'update_stats', data ).done(function( response ){
     432            }, parseInt( intervalTime / 2 ) );
     433
     434            // New items events
     435            items.on( 'mouseenter', function( e ){
     436                $(this).off( tEndEvent );
     437                clearTimeout( timer );
     438                clearTimeout( secTimer );
     439                cancelAnimationFrame(requestAnimID);
     440            });
     441
     442            items.on( 'mouseleave', function( event ){
     443
     444                var item = items.filter('.wmt-current');
     445                var index = item.data('index');
     446                var halftime = parseInt( hideTime / 2 );
     447
     448                if( index === undefined ) return;
    224449               
    225                 if( woomotivObj.disable_link != 1 ){
    226                     location.href = self.find('.woomotiv-link').attr('href');
     450                setTimeout(function(){
     451
     452                    item.removeClass('wmt-current');
     453                   
     454                }, halftime );
     455
     456                setTimeout( function (){
     457                   
     458                    requestAnimID = requestAnimationFrame( function(){
     459                        start( item.data('index') + 1 );
     460                    });
     461
     462                }, ( hideTime + hideTime ) );
     463
     464            });
     465
     466            items.find('.woomotiv-close').on( 'click', function( event ){
     467                items.remove();
     468                localStorage.setItem('woomotiv_pause_date_' + woomotivObj.site_hash , dateAdd( new Date(), 'minute', 30 ) );
     469            });
     470
     471            // Stats Update
     472            items.on( 'click', function( event ){
     473
     474                event.preventDefault();
     475
     476                var self = $(this);
     477                var data = {};
     478
     479                if( self.data('type') === 'order' ){
     480                    data.type = 'order';
     481                    data.product_id = self.data('product');
    227482                }
     483                else if( self.data('type') === 'review' ){
     484                    data.type = 'review';
     485                    data.product_id = self.data('product');
     486                }
     487                else{
     488                    data.type = 'custom';
     489                    data.id = self.data('id');
     490                }
     491
     492                ajax( 'update_stats', data ).done(function( response ){
     493                   
     494                    if( woomotivObj.disable_link != 1 ){
     495                        location.href = self.find('.woomotiv-link').attr('href');
     496                    }
     497
     498                });
    228499
    229500            });
    230501
    231502        });
    232 
    233     });
     503    }
     504
     505    // No-repeat is disabled, lets clear the local storage
     506    if( ! isNoRepeaEnabled ){
     507        clearLocalStorage();
     508    }
     509    // No-repeat is enabled, let's get the excluded one from the local storage
     510    else{
     511        excluded.orders = getExcludedOrdersFromStorage();
     512        excluded.reviews = getExcludedReviewsFromStorage();
     513        excluded.custom = getExcludedCustomPopsFromStorage();
     514    }
     515
     516    // Show time
     517    getItems(excluded);
    234518
    235519})( jQuery );
  • woomotiv/trunk/js/front.min.js

    r2415564 r2513764  
    1 !function(o){o(window);var i,a,t=o("body"),n=woomotivObj.nonce,r=woomotivObj.ajax_url,m=!1,s=!1,d=1e3*parseInt(woomotivObj.interval),u=1e3*parseInt(woomotivObj.hide),c=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,w=window.cancelAnimationFrame||window.mozCancelAnimationFrame;var l=function(){var e,t=document.createElement("fakeelement"),n={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in n)if(void 0!==t.style[e])return n[e]}(),f=function(){var e,t=document.createElement("fakeelement"),n={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(e in n)if(void 0!==t.style[e])return n[e]}(),v=["fade","slideup","slidedown","slideright","slideleft"];function p(e,t){return(t="object"==typeof t?t:{}).action="woomotiv_"+e,t.hasOwnProperty("nonce")||(t.nonce=n),o.ajax({type:"POST",url:r,data:t})}function b(e){e=parseInt(e),i.eq(e).length||(e=0);var t=i.eq(e),n=-1!=v.indexOf(t.data("animation"))?l:f;t.addClass("wmt-current").one(n,function(){s=setTimeout(function(){t.removeClass("wmt-current"),m=setTimeout(function(){b(e+1)},d)},u)})}p("get_items").done(function(e){if(e.hasOwnProperty("data")&&0!==e.data.length){if(localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash))if(new Date(localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash))>new Date)return;e.data.map(function(e){t.append(e.markup)}),i=o(".woomotiv-popup"),setTimeout(function(){a=c(function(){b(0)})},parseInt(d/2)),i.on("mouseenter",function(e){clearTimeout(m),clearTimeout(s),w(a)}),i.on("mouseleave",function(e){var t=i.filter(".wmt-current"),n=t.data("index"),o=parseInt(u/2);void 0!==n&&(setTimeout(function(){t.removeClass("wmt-current")},o),setTimeout(function(){a=c(function(){b(t.data("index")+1)})},u+u))}),i.find(".woomotiv-close").on("click",function(e){i.remove(),localStorage.setItem("woomotiv_pause_date_"+woomotivObj.site_hash,function(e,t,n){function o(){i.getDate()!=e.getDate()&&i.setDate(0)}var i=new Date(e);switch(t.toLowerCase()){case"year":i.setFullYear(i.getFullYear()+n),o();break;case"quarter":i.setMonth(i.getMonth()+3*n),o();break;case"month":i.setMonth(i.getMonth()+n),o();break;case"week":i.setDate(i.getDate()+7*n);break;case"day":i.setDate(i.getDate()+n);break;case"hour":i.setTime(i.getTime()+36e5*n);break;case"minute":i.setTime(i.getTime()+6e4*n);break;case"second":i.setTime(i.getTime()+1e3*n);break;default:i=void 0}return i}(new Date,"minute",30))}),i.on("click",function(e){e.preventDefault();var t=o(this),n={};"order"===t.data("type")?(n.type="order",n.product_id=t.data("product")):"review"===t.data("type")?(n.type="review",n.product_id=t.data("product")):(n.type="custom",n.id=t.data("id")),p("update_stats",n).done(function(e){1!=woomotivObj.disable_link&&(location.href=t.find(".woomotiv-link").attr("href"))})})}})}(jQuery);
     1!function(o){o(window);var i,a,n=o("body"),r=woomotivObj.nonce,s=woomotivObj.ajax_url,m=!0,c=!1,d=!1,l=1e3*parseInt(woomotivObj.interval),f=1e3*parseInt(woomotivObj.hide),u=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame,w=window.cancelAnimationFrame||window.mozCancelAnimationFrame,v={orders:[],reviews:[],custom:[]},p=parseInt(woomotivObj.is_no_repeat_enabled),h="woomotiv_seen_orders_"+woomotivObj.site_hash,b="woomotiv_seen_reviews_"+woomotivObj.site_hash,_="woomotiv_seen_custompop_"+woomotivObj.site_hash,t=function(){var t,e=document.createElement("fakeelement"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(t in o)if(void 0!==e.style[t])return o[t]}(),e=function(){var t,e=document.createElement("fakeelement"),o={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"animationend",WebkitAnimation:"webkitAnimationEnd"};for(t in o)if(void 0!==e.style[t])return o[t]}(),g=(function(){var t,e=document.createElement("fakeelement"),o={transition:"transitionstart",OTransition:"oTransitionStart",MozTransition:"transitionstart",WebkitTransition:"webkitTransitionStart"};for(t in o)if(void 0!==e.style[t])return}(),function(){var t,e=document.createElement("fakeelement"),o={animation:"animationstart",OAnimation:"oAnimationStart",MozAnimation:"animationstart",WebkitAnimation:"webkitAnimationStart"};for(t in o)if(void 0!==e.style[t])return}(),["fade","slideup","slidedown","slideright","slideleft"]),k=(g.indexOf(woomotivObj.animation),-1!=g.indexOf(woomotivObj.animation)?t:e);function T(t,e){return(e="object"==typeof e?e:{}).action="woomotiv_"+t,e.hasOwnProperty("nonce")||(e.nonce=r),o.ajax({type:"POST",url:s,data:e})}function O(m){m=parseInt(m),i.eq(m).length||(p&&(v.orders=j(),v.reviews=I(),v.custom=y()),A(v));var u=i.eq(m);u.addClass("wmt-current"),u.one(k,function(){var e,o,n,t,i,a,r,s;u.is('[data-type="order"]')?(a=parseInt(u.attr("data-order")),v.orders=v.orders.filter(function(t){return t!=a}),v.orders.push(a),p&&(r=j(),s=!1,r.map(function(t){t==a&&(s=!0)}),s||(r.push(a),localStorage.setItem(h,r.join(","))))):u.is('[data-type="review"]')?(n=parseInt(u.attr("data-review")),v.reviews=v.reviews.filter(function(t){return t!=n}),v.reviews.push(n),p&&(t=I(),i=!1,t.map(function(t){t==n&&(i=!0)}),i||(t.push(n),localStorage.setItem(b,t.join(","))))):u.is('[data-type="custom"]')&&(e=parseInt(u.attr("data-id")),v.custom=v.custom.filter(function(t){return t!=e}),v.custom.push(e),p&&(t=y(),o=!1,t.map(function(t){t==e&&(o=!0)}),o||(t.push(e),localStorage.setItem(_,t.join(","))))),d=setTimeout(function(){u.removeClass("wmt-current"),u.one(k,function(){c=setTimeout(function(){O(m+1)},l)})},f)})}function j(){var t=localStorage.getItem(h);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function I(){var t=localStorage.getItem(b);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function y(){var t=localStorage.getItem(_);return(t=t?t.split(","):[]).filter(function(t){return""!==t})}function S(){localStorage.removeItem(h),localStorage.removeItem(b),localStorage.removeItem(_)}function A(e){T("get_items",{excluded:e}).done(function(t){if(t.hasOwnProperty("data")&&(0!==t.data.length||!m)){if(m=!1,0===t.data.length&&(p&&S(),e.orders=[],e.reviews=[],e.custom=[],A(e)),localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash))if(new Date(localStorage.getItem("woomotiv_pause_date_"+woomotivObj.site_hash))>new Date)return;i&&i.remove(),t.data.map(function(t){n.append(t.markup)}),i=o(".woomotiv-popup"),setTimeout(function(){a=u(function(){O(0)})},parseInt(l/2)),i.on("mouseenter",function(t){o(this).off(k),clearTimeout(c),clearTimeout(d),w(a)}),i.on("mouseleave",function(t){var e=i.filter(".wmt-current"),o=e.data("index"),n=parseInt(f/2);void 0!==o&&(setTimeout(function(){e.removeClass("wmt-current")},n),setTimeout(function(){a=u(function(){O(e.data("index")+1)})},f+f))}),i.find(".woomotiv-close").on("click",function(t){i.remove(),localStorage.setItem("woomotiv_pause_date_"+woomotivObj.site_hash,function(t,e,o){function n(){i.getDate()!=t.getDate()&&i.setDate(0)}var i=new Date(t);switch(e.toLowerCase()){case"year":i.setFullYear(i.getFullYear()+o),n();break;case"quarter":i.setMonth(i.getMonth()+3*o),n();break;case"month":i.setMonth(i.getMonth()+o),n();break;case"week":i.setDate(i.getDate()+7*o);break;case"day":i.setDate(i.getDate()+o);break;case"hour":i.setTime(i.getTime()+36e5*o);break;case"minute":i.setTime(i.getTime()+6e4*o);break;case"second":i.setTime(i.getTime()+1e3*o);break;default:i=void 0}return i}(new Date,"minute",30))}),i.on("click",function(t){t.preventDefault();var e=o(this),t={};"order"===e.data("type")?(t.type="order",t.product_id=e.data("product")):"review"===e.data("type")?(t.type="review",t.product_id=e.data("product")):(t.type="custom",t.id=e.data("id")),T("update_stats",t).done(function(t){1!=woomotivObj.disable_link&&(location.href=e.find(".woomotiv-link").attr("href"))})})}})}p?(v.orders=j(),v.reviews=I(),v.custom=y()):S(),A(v)}(jQuery);
  • woomotiv/trunk/lib/class-frontend.php

    r2495131 r2513764  
    165165            'user_avatar'   => woomotiv()->config->woomotiv_user_avatar,
    166166            'disable_link'  => woomotiv()->config->woomotiv_disable_link,
    167             'template_content' => $template_content,
    168             'template_review' => $template_review,
    169             'hide_close_button'  => (int)woomotiv()->config->woomotiv_hide_close_button,
     167            'hide_close_button' => (int)woomotiv()->config->woomotiv_hide_close_button,
     168            'is_no_repeat_enabled' => (int)woomotiv()->config->woomotiv_no_repeat_sales_reviews,
     169            'is_premium' => wmv_fs()->is_premium(),
    170170        ));
    171171
     
    178178       
    179179        validateNounce();
    180        
     180
     181        $excluded = isset( $_POST['excluded'] ) ? $_POST['excluded'] : [];
     182
     183        if( ! array_key_exists( 'orders', $excluded ) ){
     184            $excluded['orders'] = [];
     185        }
     186
     187        if( ! array_key_exists( 'reviews', $excluded ) ){
     188            $excluded['reviews'] = [];
     189        }
     190
     191        if( ! array_key_exists( 'custom', $excluded ) ){
     192            $excluded['custom'] = [];
     193        }
     194
    181195        $country_list = require WC()->plugin_path() . '/i18n/countries.php';
    182196        $date_now = date_now();
    183         $orders = get_orders();
    184         $reviews = get_reviews();
    185         $custom_popups = get_custom_popups();
     197        $orders = get_orders( $excluded['orders'] );
     198        $reviews = get_reviews( $excluded['reviews'] );
     199        $custom_popups = get_custom_popups( $excluded['custom'] );
    186200        $notifications = array();
    187201        $counter = 1;
     
    312326
    313327        $output = '
    314             <div data-index="' .$index. '" data-type="order" data-product="' .$order['popup']['product']['id']. '" class="woomotiv-popup wmt-index-' .$index. '" data-size="' .$this->popup_size. '" data-shape="' .$this->popup_shape. '" data-animation="' .$this->popup_animation. '" data-position="' .$this->popup_position. '" data-hideonmobile="' .$this->popup_hide_on_mobile. '">
     328            <div data-index="' .$index. '" data-order="' . $order['popup']['order_id'] . '" data-type="order" data-product="' .$order['popup']['product']['id']. '" class="woomotiv-popup wmt-index-' .$index. '" data-size="' .$this->popup_size. '" data-shape="' .$this->popup_shape. '" data-animation="' .$this->popup_animation. '" data-position="' .$this->popup_position. '" data-hideonmobile="' .$this->popup_hide_on_mobile. '">
    315329                <div class="woomotiv-image" >' . $image . '</div>
    316330                <p>
     
    344358
    345359        $output = '
    346             <div data-index="' .$index. '" data-type="review" data-product="' .$order['popup']['product']['id']. '" class="woomotiv-popup wmt-index-' .$index. '" data-size="' .$this->popup_size. '" data-shape="' .$this->popup_shape. '" data-animation="' .$this->popup_animation. '" data-position="' .$this->popup_position. '" data-hideonmobile="' .$this->popup_hide_on_mobile. '">
     360            <div data-index="' .$index. '" data-review="' . $order['popup']['id'] . '" data-type="review" data-product="' .$order['popup']['product']['id']. '" class="woomotiv-popup wmt-index-' .$index. '" data-size="' .$this->popup_size. '" data-shape="' .$this->popup_shape. '" data-animation="' .$this->popup_animation. '" data-position="' .$this->popup_position. '" data-hideonmobile="' .$this->popup_hide_on_mobile. '">
    347361                <div class="woomotiv-image" >' . $image . '</div>
    348362                <p>
  • woomotiv/trunk/lib/config.php

    r2415564 r2513764  
    55    // general
    66    'woomotiv_display_order'                => 'recent_sales',
     7    'woomotiv_no_repeat_sales_reviews'      => 0,
    78    'woomotiv_display_processing_orders'    => 0,
    89    'woomotiv_display_reviews'              => 1,
  • woomotiv/trunk/lib/functions.php

    r2495355 r2513764  
    33namespace WooMotiv;
    44
     5use  WooMotiv\Framework\Helper ;
    56/**
    67 * Returns a link to upgrade
     
    103104 * Get orders
    104105 *
    105  * @return array
    106  */
    107 function get_orders()
     106 * @param array $excluded_orders
     107 * @return array
     108 */
     109function get_orders( $excluded_orders = array() )
    108110{
    109111    global  $wpdb ;
    110     $raw = "\n        SELECT \n            POSTS.ID, POSTS.post_status, POSTS.post_type, \n            WCITEMS.order_item_id, WCITEMS.order_item_type, \n            WCITEMMETA.meta_value  AS 'product_id', \n            POSTMETA.meta_value AS 'customer_id'\n        \n        FROM {$wpdb->prefix}posts AS POSTS\n        \n        LEFT JOIN\n            {$wpdb->prefix}woocommerce_order_items AS WCITEMS \n                ON \n                    WCITEMS.order_id = POSTS.ID\n                AND \n                    WCITEMS.order_item_type IN ('line_item')\n        \n        LEFT JOIN\n            {$wpdb->prefix}woocommerce_order_itemmeta AS WCITEMMETA\n                ON\n                    WCITEMS.order_item_id = WCITEMMETA.order_item_id\n                AND\n                    WCITEMMETA.meta_key = '_product_id'\n        \n        LEFT JOIN\n            {$wpdb->prefix}postmeta AS POSTMETA\n                ON \n                    POSTMETA.post_id = POSTS.ID\n                AND\n                    POSTMETA.meta_key = '_customer_user'\n        ";
    111     $raw .= "\n                WHERE\n                    post_status = 'wc-completed' \n            ";
    112     $raw .= " AND post_type = 'shop_order'";
     112    $excluded_orders = ( !is_array( $excluded_orders ) ? [] : $excluded_orders );
     113    $is_random = ( woomotiv()->config->woomotiv_display_order === 'random_sales' ? true : false );
     114    $raw = "\n        SELECT \n            POSTS.ID, POSTS.post_status, POSTS.post_type, \n            POSTMETA.meta_value AS 'customer_id'\n        \n        FROM \n            {$wpdb->prefix}posts AS POSTS\n        \n        LEFT JOIN\n            {$wpdb->prefix}postmeta AS POSTMETA\n                ON \n                    POSTMETA.post_id = POSTS.ID\n                AND\n                    POSTMETA.meta_key = '_customer_user'\n    ";
     115    $raw .= "\n            WHERE\n                POSTS.post_status = 'wc-completed' \n        ";
     116    $raw .= " AND POSTS.post_type = 'shop_order'";
     117    // Make sure it is a parent order
     118    $raw .= " AND POSTS.post_parent = 0";
     119    // Only if has products
     120    $raw .= " AND (SELECT COUNT(*) AS total_products FROM {$wpdb->prefix}woocommerce_order_items AS WOI where WOI.order_id = POSTS.ID) > 0";
     121    // Excluded orders
     122   
     123    if ( count( $excluded_orders ) ) {
     124        $excluded_orders_str = implode( ',', $excluded_orders );
     125        $raw .= " AND POSTS.ID NOT IN ({$excluded_orders_str})";
     126    }
     127   
    113128    // exclude current user orders
    114129    if ( is_user_logged_in() ) {
     
    127142    // random or recent sales
    128143   
    129     if ( woomotiv()->config->woomotiv_display_order == 'random_sales' ) {
     144    if ( $is_random ) {
    130145        $raw .= " ORDER BY RAND()";
    131146    } else {
     
    168183        $orders[] = (object) array(
    169184            'id'      => $data->ID,
    170             'order'   => wc_get_order( $data->ID ),
     185            'order'   => $order,
    171186            'product' => $product,
    172187        );
     
    178193 * Get reviews
    179194 *
    180  * @return array
    181  */
    182 function get_reviews()
    183 {
     195 * @param array $excluded
     196 * @return array
     197 */
     198function get_reviews( $excluded_reviews = array() )
     199{
     200    $excluded_reviews = ( !is_array( $excluded_reviews ) ? [] : $excluded_reviews );
    184201    /** Only Premium */
    185202    if ( wmv_fs()->is_free_plan() ) {
     
    193210 * @return array
    194211 */
    195 function get_custom_popups()
     212function get_custom_popups( $excluded_popups )
    196213{
    197214    /** Only Premium */
  • woomotiv/trunk/lib/hooks.php

    r2218297 r2513764  
    2828    if( ! function_exists('has_wp_user_avatar') ) return $url;
    2929
    30     if ( is_email( $id_or_email ) ) {
     30    if( is_string( $id_or_email ) && is_email( $id_or_email ) ) {
    3131        $user = get_user_by( 'email', $id_or_email );
    3232        $user_id = $user->ID;
  • woomotiv/trunk/readme.txt

    r2495355 r2513764  
    33Requires at least: 4.6
    44Tested up to: 5.7.0
    5 Stable tag: 2.15.5
     5Stable tag: 3.0.0
    66Requires PHP: 5.6
    77Tags: woocommerce notification, woocommerce sales notification, woocommerce sales popup, marketing, boost sales, boost conversion
     
    101101== Changelog ==
    102102
     103= 3.0.0 =
     104
     105* Added No-repeat functionality.
     106* Core updates
     107* Fixed a few bugs
     108
    103109= 2.15.5 =
    104110
  • woomotiv/trunk/views/tabs/general.php

    r2139962 r2513764  
    1414        'random_sales' => __('Random Sales ( Reviews )','woomotiv'),
    1515    ),
     16))
     17
     18.HTML::checkbox(array(
     19    'title' => __('No-repeat', 'woomotiv') . upgrade_link(),
     20    'description' => __('Do not repeat the same Sales/Reviews popups.', 'woomotiv'),
     21    'name' => 'woomotiv_no_repeat_sales_reviews',
     22    'value' => woomotiv()->config->woomotiv_no_repeat_sales_reviews,
     23    'text' => __('Enable','woomotiv'),
    1624))
    1725
Note: See TracChangeset for help on using the changeset viewer.