Changeset 3115281
- Timestamp:
- 07/10/2024 06:11:30 AM (21 months ago)
- Location:
- checkout-countdown-for-woocommerce
- Files:
-
- 27 added
- 10 edited
-
tags/4.0.0 (added)
-
tags/4.0.0/assets (added)
-
tags/4.0.0/assets/checkout-countdown.css (added)
-
tags/4.0.0/assets/checkout-countdown.js (added)
-
tags/4.0.0/assets/checkout-countdown.min.css (added)
-
tags/4.0.0/assets/checkout-countdown.min.js (added)
-
tags/4.0.0/assets/index.php (added)
-
tags/4.0.0/checkout-countdown-for-woocommerce.php (added)
-
tags/4.0.0/classes (added)
-
tags/4.0.0/classes/class-admin-notices.php (added)
-
tags/4.0.0/functions (added)
-
tags/4.0.0/functions/cart-fragments.php (added)
-
tags/4.0.0/functions/enqueue.php (added)
-
tags/4.0.0/functions/functions.php (added)
-
tags/4.0.0/functions/index.php (added)
-
tags/4.0.0/functions/shortcode.php (added)
-
tags/4.0.0/index.php (added)
-
tags/4.0.0/languages (added)
-
tags/4.0.0/languages/checkout-countdown-for-woocommerce.pot (added)
-
tags/4.0.0/readme.txt (added)
-
tags/4.0.0/settings (added)
-
tags/4.0.0/settings/banana-framework (added)
-
tags/4.0.0/settings/banana-framework/class-settings-api.php (added)
-
tags/4.0.0/settings/banana-framework/index.php (added)
-
tags/4.0.0/settings/index.php (added)
-
tags/4.0.0/settings/settings.php (added)
-
trunk/assets/checkout-countdown.css (modified) (5 diffs)
-
trunk/assets/checkout-countdown.js (modified) (10 diffs)
-
trunk/assets/checkout-countdown.min.css (modified) (1 diff)
-
trunk/assets/checkout-countdown.min.js (modified) (1 diff)
-
trunk/checkout-countdown-for-woocommerce.php (modified) (5 diffs)
-
trunk/functions/cart-fragments.php (added)
-
trunk/functions/enqueue.php (modified) (3 diffs)
-
trunk/functions/functions.php (modified) (9 diffs)
-
trunk/functions/shortcode.php (modified) (3 diffs)
-
trunk/languages/checkout-countdown-for-woocommerce.pot (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
checkout-countdown-for-woocommerce/trunk/assets/checkout-countdown.css
r2167353 r3115281 1 /* Checkout Countdown bar CSS */2 1 .checkout-countdown-wrapper.checkout-countdown-bar { 3 2 text-align: center; … … 6 5 z-index: 9999; 7 6 } 8 .c cfwoo-is-hidden {7 .checkout-countdown-is-hidden { 9 8 display: none; 10 9 } 11 /* Loading Dots */ 12 @-webkit-keyframes ccfwoo-dot-keyframes { 10 @-webkit-keyframes checkout-countdown-loading-dot-keyframes { 13 11 0% { 14 12 opacity: 0.4; … … 27 25 } 28 26 } 29 @keyframes c cfwoo-dot-keyframes {27 @keyframes checkout-countdown-loading-dot-keyframes { 30 28 0% { 31 29 opacity: 0.4; … … 44 42 } 45 43 } 46 .c cfwoo-loading-dots{44 .checkout-countdown-loading { 47 45 width: 100%; 48 46 } 49 .c cfwoo-loading-dots--dot {50 -webkit-animation: c cfwoo-dot-keyframes 1.5s infinite ease-in-out;51 animation: c cfwoo-dot-keyframes 1.5s infinite ease-in-out;47 .checkout-countdown-loading-dot { 48 -webkit-animation: checkout-countdown-loading-dot-keyframes 1.5s infinite ease-in-out; 49 animation: checkout-countdown-loading-dot-keyframes 1.5s infinite ease-in-out; 52 50 background-color: rgb(209, 209, 209); 53 51 border-radius: 10px; … … 56 54 width: 5px; 57 55 } 58 .c cfwoo-loading-dots--dot:nth-child(2) {56 .checkout-countdown-loading-dot:nth-child(2) { 59 57 -webkit-animation-delay: 0.5s; 60 58 animation-delay: 0.5s; 61 59 } 62 .c cfwoo-loading-dots--dot:nth-child(3) {60 .checkout-countdown-loading-dot:nth-child(3) { 63 61 -webkit-animation-delay: 1s; 64 62 animation-delay: 1s; -
checkout-countdown-for-woocommerce/trunk/assets/checkout-countdown.js
r3065377 r3115281 7 7 */ 8 8 9 // eslint-disable-next-line10 9 var ccfwooController = { 11 10 counting: false, 12 cartItems: ccfwooLocal.cart_count,13 cart: 0,14 11 interval: false, 15 12 htmlElements: false, 13 forceStop: false, // Used to override the criteria. 16 14 config: ccfwooLocal, // localized data. 17 15 setElements(classNames) { … … 50 48 ccfwooFinishedCountingHTML(contentElement); 51 49 } 52 if (textType === "banner") { 50 if ( 51 textType === "banner" && 52 !elements[i]?.classList.contains("checkout-countdown-notice") 53 ) { 53 54 ccfwooBannerHTML(contentElement); 54 55 } … … 60 61 return this.counting; 61 62 }, 62 hasCart() { 63 return this.cartItems >= 1 ? true : false; 64 }, 65 getCartItems() { 66 return this.cartItems; 67 }, 68 setCartItems(value) { 69 this.cartItems = value; 63 hasCartCriteria() { 64 var cartFragment = document.querySelector(".ccfwoo-cart-fragment"); 65 66 if (cartFragment && !this.forceStop) { 67 var hasValidCart = 68 cartFragment.getAttribute("data-has-cart-criteria") && 69 cartFragment.getAttribute("data-has-cart-criteria") == true; 70 71 return hasValidCart; 72 } 73 74 return false; 70 75 }, 71 76 setIsCounting(value) { … … 74 79 } else { 75 80 ccfwooController.classes("add", "checkout-countdown-is-counting"); 76 ccfwooController.classes("remove", "ccfwoo-is-hidden"); 81 ccfwooController.classes("remove", "checkout-countdown-is-hidden"); 82 ccfwooController.classes("remove", "checkout-countdown-is-expired"); 77 83 } 78 84 … … 89 95 startInterval() { 90 96 // we are only counting if there's a cart. 91 if (this.hasCart ()) {97 if (this.hasCartCriteria()) { 92 98 this.setIsCounting(true); 93 99 } else { … … 154 160 155 161 /** 156 * Init Checkout Countdown - Pure JS version of Document Ready.162 * Init Checkout Countdown. 157 163 */ 158 164 document.addEventListener("DOMContentLoaded", function (event) { 159 165 // eslint-disable-line 160 ccfwooController.setElements(); // Set the HTML Elements. 161 162 // Combat Caching plugins by setting the cart items from cookies. 163 const cookie = ccfwooGetCookie("woocommerce_items_in_cart"); 164 165 const cookieCart = cookie && cookie >= 1 ? 1 : 0; 166 ccfwooController.setCartItems(cookieCart); 166 ccfwooController.setElements(); // Get instances of Checkout Countdown in the DOM. 167 // Register new event, ccfwooHasLoaded. 168 ccfwooController.triggerEvent("document", "ccfwooLoaded", true); 167 169 168 170 ccfwooCounter(); // Run without delay once. … … 184 186 }); 185 187 186 /* 188 /** 187 189 * Handles the countdown as an interval. 188 190 */ 189 191 function ccfwooCounter() { 190 192 // Stop early if no cart available and display the banner. 191 if (!ccfwooController.hasCart ()) {193 if (!ccfwooController.hasCartCriteria()) { 192 194 ccfwooController.setHtml("banner"); 193 195 ccfwooController.classes("remove", "checkout-countdown-is-counting"); … … 215 217 return; 216 218 } 219 // Expired text. 220 ccfwooController.classes("add", "checkout-countdown-is-expired"); 221 ccfwooController.setHtml("expired"); 222 217 223 ccfwooController.triggerEvent("document", "ccfwooFinishedCounting", true); 218 // Expired text.219 ccfwooController.setHtml("expired");220 224 }, 1000); 221 225 // Wait 5 seconds and display default text. … … 268 272 */ 269 273 function ccfwooBannerHTML(element) { 270 // Exit if no element.271 274 if (!element) { 272 275 return; 273 276 } 274 275 277 // Banner message if selected. 276 278 if ( … … 364 366 return formattedDifference; 365 367 } 366 /**367 * Get any cookie from the browsers. e.g woocommerce_items_in_cart.368 */369 function ccfwooGetCookie(name) {370 const match = document.cookie.match(new RegExp("(^| )" + name + "=([^;]+)"));371 if (match) return match[2];372 }373 368 374 369 /** -
checkout-countdown-for-woocommerce/trunk/assets/checkout-countdown.min.css
r2167353 r3115281 1 .checkout-countdown-wrapper.checkout-countdown-bar{text-align:center;padding:15px 0;width:100%;z-index:9999}.c cfwoo-is-hidden{display:none}@-webkit-keyframes ccfwoo-dot-keyframes{0%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}50%{opacity:1;-webkit-transform:scale(1.2,1.2);transform:scale(1.2,1.2)}100%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}}@keyframes ccfwoo-dot-keyframes{0%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}50%{opacity:1;-webkit-transform:scale(1.2,1.2);transform:scale(1.2,1.2)}100%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}}.ccfwoo-loading-dots{width:100%}.ccfwoo-loading-dots--dot{-webkit-animation:ccfwoo-dot-keyframes 1.5s infinite ease-in-out;animation:ccfwoo-dot-keyframes 1.5s infinite ease-in-out;background-color:#d1d1d1;border-radius:10px;display:inline-block;height:5px;width:5px}.ccfwoo-loading-dots--dot:nth-child(2){-webkit-animation-delay:.5s;animation-delay:.5s}.ccfwoo-loading-dots--dot:nth-child(3){-webkit-animation-delay:1s;animation-delay:1s}1 .checkout-countdown-wrapper.checkout-countdown-bar{text-align:center;padding:15px 0;width:100%;z-index:9999}.checkout-countdown-is-hidden{display:none}@-webkit-keyframes checkout-countdown-loading-dot-keyframes{0%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}50%{opacity:1;-webkit-transform:scale(1.2,1.2);transform:scale(1.2,1.2)}100%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}}@keyframes checkout-countdown-loading-dot-keyframes{0%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}50%{opacity:1;-webkit-transform:scale(1.2,1.2);transform:scale(1.2,1.2)}100%{opacity:.4;-webkit-transform:scale(1,1);transform:scale(1,1)}}.checkout-countdown-loading{width:100%}.checkout-countdown-loading-dot{-webkit-animation:checkout-countdown-loading-dot-keyframes 1.5s infinite ease-in-out;animation:checkout-countdown-loading-dot-keyframes 1.5s infinite ease-in-out;background-color:#d1d1d1;border-radius:10px;display:inline-block;height:5px;width:5px}.checkout-countdown-loading-dot:nth-child(2){-webkit-animation-delay:.5s;animation-delay:.5s}.checkout-countdown-loading-dot:nth-child(3){-webkit-animation-delay:1s;animation-delay:1s} -
checkout-countdown-for-woocommerce/trunk/assets/checkout-countdown.min.js
r2732232 r3115281 1 var ccfwooController={counting:!1, cartItems:ccfwooLocal.cart_count,cart:0,interval:!1,htmlElements:!1,config:ccfwooLocal,setElements(o){const e=o||"checkout-countdown-wrapper",t=document.getElementsByClassName(e);return this.htmlElements=t,t},getElements(){return this.htmlElements},setHtml(o,e,t){if(t=t||!1,!(e=e||this.htmlElements)||!o)return!1;let n;for(n=0;n<e.length;n++){const c=e[n].firstElementChild;"loading"===o&&ccfwooLoadingHTML(c),"counting"===o&&ccfwooUpdateCountingHTML(c,t),"expired"===o&&ccfwooFinishedCountingHTML(c),"banner"===o&&ccfwooBannerHTML(c)}return!0},isCounting(){return this.counting},hasCart(){return this.cartItems>=1},getCartItems(){return this.cartItems},setCartItems(o){this.cartItems=o},setIsCounting(o){!1===o?ccfwooController.classes("remove","checkout-countdown-is-counting"):(ccfwooController.classes("add","checkout-countdown-is-counting"),ccfwooController.classes("remove","ccfwoo-is-hidden")),this.counting=o},stopInterval(o){!0===o&&localStorage.removeItem("ccfwoo_end_date"),this.setIsCounting(!1),clearInterval(this.interval)},startInterval(){this.hasCart()?this.setIsCounting(!0):this.setIsCounting(!1),this.interval=setInterval(ccfwooCounter,1e3)},restartInterval(){this.stopInterval(!0),this.setHtml("loading"),this.startInterval()},setNewDate(o){const e=o||60*ccfwooLocal.ccfwoo_minutes,t=new Date;return t.setSeconds(t.getSeconds()+e),localStorage.setItem("ccfwoo_end_date",t),t},triggerEvent(o,e){if(e=new Event(e,{bubbles:!0}),"document"===o&&document.dispatchEvent(e),"window"===o&&window.dispatchEvent(e),"body"===o){document.getElementsByTagName("BODY")[0].dispatchEvent(e)}},classes(o,e,t){const n=this.htmlElements;if(!n)return!1;let c;for(c=0;c<n.length;c++)"add"===o&&n[c].classList.add(e),"remove"===o&&n[c].classList.remove(e),"replace"===o&&t&&(n[c].classList.remove(e),n[c].classList.add(t))}};function ccfwooCounter(){if(!ccfwooController.hasCart())return ccfwooController.setHtml("banner"),ccfwooController.classes("remove","checkout-countdown-is-counting"),void ccfwooController.stopInterval(!0);const o=ccfwooGetDurationRange(),e=ccfwooFormatDuration(o.start,o.end);!0===e.isPast?(ccfwooController.setHtml("loading"),ccfwooController.stopInterval(!0),ccfwooController.triggerEvent("document","ccfwooReachedZero",!0),setTimeout((function(){ccfwooController.isCounting()||(ccfwooController.triggerEvent("document","ccfwooFinishedCounting",!0),ccfwooController.setHtml("expired"))}),1e3),setTimeout((function(){ccfwooController.isCounting()||ccfwooController.setHtml("banner")}),1e3*parseInt(ccfwooLocal.expired_message_seconds))):ccfwooController.setHtml("counting",!1,e)}function ccfwooUpdateCountingHTML(o,e){if(!o)return;let t=ccfwooLocal.countdown_text.replace("{minutes}",e.minutes);t=t.replace("{seconds}",e.seconds),t=t.replace("{hours}",e.hours),t=t.replace("{days}",e.days),o.innerHTML=t}function ccfwooLoadingHTML(o){o&&(o.innerHTML=ccfwooLocal.loading_html)}function ccfwooBannerHTML(o){o&&"on"===ccfwooLocal.enable_banner_message&&ccfwooLocal.banner_message_text&&(o.innerHTML=ccfwooLocal.banner_message_text)}function ccfwooFinishedCountingHTML(o){o&&(o.innerHTML=ccfwooLocal.expired_text)}function ccfwooGetDurationRange(){const o=new Date;let e=!!localStorage.getItem("ccfwoo_end_date")&&localStorage.getItem("ccfwoo_end_date");e=e?new Date(e):ccfwooController.setNewDate();return{start:o,end:e}}function ccfwooFormatDuration(o,e){const t=new Date(e)-new Date(o),n=Number.isInteger(t),c=Math.floor(t/1e3/60/60/24/7),r=Math.floor(t/1e3/60/60/24-7*c),s=Math.floor(t/1e3/60/60-7*c*24-24*r),a=Math.floor(t/1e3/60-7*c*24*60-24*r*60-60*s),l=Math.floor(t/1e3-7*c*24*60*60-24*r*60*60-60*s*60-60*a),i=t/1e3<=0;return{milliseconds:Math.floor(t-7*c*24*60*60*1e3-24*r*60*60*1e3-60*s*60*1e3-60*a*1e3-1e3*l),seconds:ccfwooLeadingZero(l),minutes:ccfwooLeadingZero(a),hours:s,days:r,weekdays:c,totalSeconds:t/1e3,isPast:i,ValidDates:n}}function ccfwooGetCookie(o){const e=document.cookie.match(new RegExp("(^| )"+o+"=([^;]+)"));if(e)return e[2]}function ccfwooLeadingZero(o){if("on"===ccfwooLocal.leading_zero){const e=2;for(o=o.toString();o.length<e;)o="0"+o;return o}return o}document.addEventListener("DOMContentLoaded",(function(o){ccfwooController.setElements();const e=ccfwooGetCookie("woocommerce_items_in_cart"),t=e&&e>=1?1:0;ccfwooController.setCartItems(t),ccfwooCounter(),ccfwooController.startInterval(),ccfwooController.isCounting()&&ccfwooController.classes("add","checkout-countdown-is-counting")})),document.addEventListener("ccfwooFinishedCounting",(function(o){ccfwooController.classes("remove","checkout-countdown-is-counting")}));1 var ccfwooController={counting:!1,interval:!1,htmlElements:!1,forceStop:!1,config:ccfwooLocal,setElements(o){const e=o||"checkout-countdown-wrapper",t=document.getElementsByClassName(e);return this.htmlElements=t,t},getElements(){return this.htmlElements},setHtml(o,e,t){if(t=t||!1,!(e=e||this.htmlElements)||!o)return!1;let n;for(n=0;n<e.length;n++){const c=e[n].firstElementChild;"loading"===o&&ccfwooLoadingHTML(c),"counting"===o&&ccfwooUpdateCountingHTML(c,t),"expired"===o&&ccfwooFinishedCountingHTML(c),"banner"!==o||e[n]?.classList.contains("checkout-countdown-notice")||ccfwooBannerHTML(c)}return!0},isCounting(){return this.counting},hasCartCriteria(){var o=document.querySelector(".ccfwoo-cart-fragment");return!(!o||this.forceStop)&&(o.getAttribute("data-has-cart-criteria")&&1==o.getAttribute("data-has-cart-criteria"))},setIsCounting(o){!1===o?ccfwooController.classes("remove","checkout-countdown-is-counting"):(ccfwooController.classes("add","checkout-countdown-is-counting"),ccfwooController.classes("remove","checkout-countdown-is-hidden"),ccfwooController.classes("remove","checkout-countdown-is-expired")),this.counting=o},stopInterval(o){!0===o&&localStorage.removeItem("ccfwoo_end_date"),this.setIsCounting(!1),clearInterval(this.interval)},startInterval(){this.hasCartCriteria()?this.setIsCounting(!0):this.setIsCounting(!1),this.interval=setInterval(ccfwooCounter,1e3)},restartInterval(){this.stopInterval(!0),this.setHtml("loading"),this.startInterval()},setNewDate(o){const e=o||60*ccfwooLocal.ccfwoo_minutes,t=new Date;return t.setSeconds(t.getSeconds()+e),localStorage.setItem("ccfwoo_end_date",t),t},triggerEvent(o,e){if(e=new Event(e,{bubbles:!0}),"document"===o&&document.dispatchEvent(e),"window"===o&&window.dispatchEvent(e),"body"===o){document.getElementsByTagName("BODY")[0].dispatchEvent(e)}},classes(o,e,t){const n=this.htmlElements;if(!n)return!1;let c;for(c=0;c<n.length;c++)"add"===o&&n[c].classList.add(e),"remove"===o&&n[c].classList.remove(e),"replace"===o&&t&&(n[c].classList.remove(e),n[c].classList.add(t))}};function ccfwooCounter(){if(!ccfwooController.hasCartCriteria())return ccfwooController.setHtml("banner"),ccfwooController.classes("remove","checkout-countdown-is-counting"),void ccfwooController.stopInterval(!0);const o=ccfwooGetDurationRange(),e=ccfwooFormatDuration(o.start,o.end);!0===e.isPast?(ccfwooController.setHtml("loading"),ccfwooController.stopInterval(!0),ccfwooController.triggerEvent("document","ccfwooReachedZero",!0),setTimeout((function(){ccfwooController.isCounting()||(ccfwooController.classes("add","checkout-countdown-is-expired"),ccfwooController.setHtml("expired"),ccfwooController.triggerEvent("document","ccfwooFinishedCounting",!0))}),1e3),setTimeout((function(){ccfwooController.isCounting()||ccfwooController.setHtml("banner")}),1e3*parseInt(ccfwooLocal.expired_message_seconds))):ccfwooController.setHtml("counting",!1,e)}function ccfwooUpdateCountingHTML(o,e){if(!o)return;let t=ccfwooLocal.countdown_text.replace("{minutes}",e.minutes);t=t.replace("{seconds}",e.seconds),t=t.replace("{hours}",e.hours),t=t.replace("{days}",e.days),o.innerHTML=t}function ccfwooLoadingHTML(o){o&&(o.innerHTML=ccfwooLocal.loading_html)}function ccfwooBannerHTML(o){o&&"on"===ccfwooLocal.enable_banner_message&&ccfwooLocal.banner_message_text&&(o.innerHTML=ccfwooLocal.banner_message_text)}function ccfwooFinishedCountingHTML(o){o&&(o.innerHTML=ccfwooLocal.expired_text)}function ccfwooGetDurationRange(){const o=new Date;let e=!!localStorage.getItem("ccfwoo_end_date")&&localStorage.getItem("ccfwoo_end_date");e=e?new Date(e):ccfwooController.setNewDate();return{start:o,end:e}}function ccfwooFormatDuration(o,e){const t=new Date(e)-new Date(o),n=Number.isInteger(t),c=Math.floor(t/1e3/60/60/24/7),r=Math.floor(t/1e3/60/60/24-7*c),s=Math.floor(t/1e3/60/60-7*c*24-24*r),a=Math.floor(t/1e3/60-7*c*24*60-24*r*60-60*s),l=Math.floor(t/1e3-7*c*24*60*60-24*r*60*60-60*s*60-60*a),i=t/1e3<=0;return{milliseconds:Math.floor(t-7*c*24*60*60*1e3-24*r*60*60*1e3-60*s*60*1e3-60*a*1e3-1e3*l),seconds:ccfwooLeadingZero(l),minutes:ccfwooLeadingZero(a),hours:s,days:r,weekdays:c,totalSeconds:t/1e3,isPast:i,ValidDates:n}}function ccfwooLeadingZero(o){if("on"===ccfwooLocal.leading_zero){const e=2;for(o=o.toString();o.length<e;)o="0"+o;return o}return o}document.addEventListener("DOMContentLoaded",(function(o){ccfwooController.setElements(),ccfwooController.triggerEvent("document","ccfwooLoaded",!0),ccfwooCounter(),ccfwooController.startInterval(),ccfwooController.isCounting()&&ccfwooController.classes("add","checkout-countdown-is-counting")})),document.addEventListener("ccfwooFinishedCounting",(function(o){ccfwooController.classes("remove","checkout-countdown-is-counting")})); -
checkout-countdown-for-woocommerce/trunk/checkout-countdown-for-woocommerce.php
r3065377 r3115281 3 3 * Plugin Name: Checkout Countdown for WooCommerce 4 4 * Description: A flexible WooCommerce cart/checkout countdown to help improve cart conversion. 5 * Version: 3.2.35 * Version: 4.0.0 6 6 * Author: Puri.io 7 7 * Author URI: https://puri.io/ … … 12 12 * Requires at least: 5.0 13 13 * WC requires at least: 5.0 14 * WC tested up to: 8.814 * WC tested up to: 9.0 15 15 */ 16 16 … … 96 96 $this->constants = array( 97 97 'name' => 'Checkout Countdown for WooCommerce', 98 'version' => ' 3.2.3',98 'version' => '4.0.0', 99 99 'prefix' => 'ccfwoo', 100 100 'admin_page' => 'checkout-countdown', … … 140 140 } 141 141 142 if ( ! class_exists( 'woocommerce' ) ) { 143 return; 144 } 145 142 146 143 147 // Require core files. … … 146 150 if ( $enable_countdown === 'on' ) { 147 151 require_once plugin_dir_path( __FILE__ ) . 'functions/functions.php'; 152 require_once plugin_dir_path( __FILE__ ) . 'functions/cart-fragments.php'; 148 153 require_once plugin_dir_path( __FILE__ ) . 'functions/enqueue.php'; 149 154 require_once plugin_dir_path( __FILE__ ) . 'functions/shortcode.php'; -
checkout-countdown-for-woocommerce/trunk/functions/enqueue.php
r3065377 r3115281 6 6 function ccfwoo_core_enqueue_scripts() { 7 7 8 wp_enqueue_style( 'ccfwoo-style', plugin_dir_url( __FILE__ ) . '../assets/checkout-countdown.min.css', array(), ' 3.2.3' );8 wp_enqueue_style( 'ccfwoo-style', plugin_dir_url( __FILE__ ) . '../assets/checkout-countdown.min.css', array(), '4.0.0' ); 9 9 10 10 if ( ccfwoo_get_option( 'bar_position', false, 'top' ) === 'top' ) { 11 11 $position = 'position: relative;'; 12 12 } else { 13 $position = 'position: fixed;';13 $position = 'position: fixed;'; 14 14 $position .= 'bottom: 0;'; 15 15 } … … 26 26 ); 27 27 28 wp_add_inline_style( 'ccfwoo-style', $inline_css );28 wp_add_inline_style( 'ccfwoo-style', $inline_css ); 29 29 30 30 // Load Javascript and Access settings as variables. 31 wp_enqueue_script( 'ccfwoo-countdown', plugin_dir_url( __FILE__ ) . '../assets/checkout-countdown.min.js', array(), ' 3.2.3', true );31 wp_enqueue_script( 'ccfwoo-countdown', plugin_dir_url( __FILE__ ) . '../assets/checkout-countdown.min.js', array(), '4.0.0', true ); 32 32 33 33 $countdown_text = sprintf( … … 50 50 51 51 $data = array( 52 'ccfwoo_minutes' => ccfwoo_get_option( 'countdown_time' ),53 'top_banner_font_color' => ccfwoo_get_option( 'top_banner_font_color' ),52 'ccfwoo_minutes' => ccfwoo_get_option( 'countdown_time' ), 53 'top_banner_font_color' => ccfwoo_get_option( 'top_banner_font_color' ), 54 54 'top_banner_background_color' => ccfwoo_get_option( 'top_banner_background_color' ), 55 'countdown_text' => $countdown_text,56 'expired_text' => $expired_text,57 'banner_message_text' => $banner_message_text,58 'enable_banner_message' => ccfwoo_get_option( 'enable_banner_message' ),59 'leading_zero' => ccfwoo_get_option( 'leading_zero', false, false ),60 'c art_count' => ccfwoo_get_cart_content(), // Check the number of products in cart.61 ' countdown_locations' => is_array( ccfwoo_get_option( 'countdown_locations' ) ) ? ccfwoo_get_option( 'countdown_locations' ) : array(),62 ' loading_html' => ccfwoo_loading_html(),63 ' expired_message_seconds' => apply_filters( 'ccfwoo_expired_message_seconds', 6),55 'countdown_text' => $countdown_text, 56 'expired_text' => $expired_text, 57 'banner_message_text' => $banner_message_text, 58 'enable_banner_message' => ccfwoo_get_option( 'enable_banner_message' ), 59 'leading_zero' => ccfwoo_get_option( 'leading_zero', false, false ), 60 'countdown_locations' => is_array( ccfwoo_get_option( 'countdown_locations' ) ) ? ccfwoo_get_option( 'countdown_locations' ) : array(), 61 'loading_html' => ccfwoo_loading_html(), 62 'expired_message_seconds' => apply_filters( 'ccfwoo_expired_message_seconds', 6 ), 63 'cart_criteria' => ccfwoo_has_cart_criteria(), 64 64 ); 65 65 -
checkout-countdown-for-woocommerce/trunk/functions/functions.php
r3065377 r3115281 6 6 7 7 /** 8 * Checks if the cart has specific criteria. 9 * 10 * @return bool The result of the check. 11 */ 12 function ccfwoo_has_cart_criteria() { 13 14 $cart_has_items = WC()->cart && WC()->cart->is_empty() === false; 15 16 return apply_filters( 'ccfwoo_cart_criteria', $cart_has_items ); 17 } 18 19 /** 8 20 * Remove all settings on uninstall 9 21 */ … … 14 26 } 15 27 register_uninstall_hook( __FILE__, 'ccfwoo_uninstall' ); 16 17 /**18 * Get the number of products in cart.19 */20 function ccfwoo_get_cart_content() {21 22 if ( ! is_object( WC() ) ) {23 return 0;24 }25 26 if ( ! is_object( WC()->cart ) ) {27 return 0;28 }29 30 if ( empty( WC()->cart->get_cart_contents_count() ) ) {31 $content_count = 0;32 } else {33 $content_count = WC()->cart->get_cart_contents_count();34 }35 36 return $content_count;37 }38 28 39 29 /** … … 53 43 <li>Redirect after countdown has finished.</li> 54 44 <li>Restart/loop the countdown.</li> 55 <li>Recal ucate the cart totals with every loop.</li>45 <li>Recalculate the cart totals with every loop.</li> 56 46 <li>Start the timer without reloading the page when adding a product to cart (AJAX).</li> 57 47 <li>and much more!</li> … … 64 54 } 65 55 66 add_filter( 'ccfwoo_above_settings_sidebars', 'ccfwoo_upgrade_to_pro_sidebar', 10 );67 68 69 /**70 * Small upgrade notice at the bottom of general settings.71 */56 add_filter( 'ccfwoo_above_settings_sidebars', 'ccfwoo_upgrade_to_pro_sidebar', 10 ); 57 58 59 /** 60 * Small upgrade notice at the bottom of general settings. 61 */ 72 62 function ccfwoo_upgrade_to_pro_settings_bottom() { 73 63 echo '<div style="display:inline-block;width:100%; float:right; background-color:#ffffff;">'; … … 86 76 function ccfwoo_settings_preview() { 87 77 88 $ccfwoo_bg = ccfwoo_get_option( 'top_banner_background_color' ) ? ccfwoo_get_option( 'top_banner_background_color' ) : '#000000';78 $ccfwoo_bg = ccfwoo_get_option( 'top_banner_background_color' ) ? ccfwoo_get_option( 'top_banner_background_color' ) : '#000000'; 89 79 $ccfwoo_font = ccfwoo_get_option( 'top_banner_font_color' ) ? ccfwoo_get_option( 'top_banner_font_color' ) : '#ffffff'; 90 80 … … 133 123 function ccfwoo_convert_options_for_banana() { 134 124 135 $new_options = get_option( 'ccfwoo_general_section', 'none' );125 $new_options = get_option( 'ccfwoo_general_section', 'none' ); 136 126 $check_enable = get_option( 'ccfwoo_enable_countdown', 'none' ); 137 127 … … 141 131 } 142 132 143 // New settings already exists - return133 // New settings already exists - return 144 134 if ( is_array( $new_options ) ) { 145 135 … … 153 143 } 154 144 if ( $new_options['display_type'] === 'woo-notice' ) { 155 $new_location['cart-notice'] = 'cart-notice';145 $new_location['cart-notice'] = 'cart-notice'; 156 146 $new_location['checkout-notice'] = 'checkout-notice'; 157 147 } … … 184 174 $temp['display_type'] = $display_type; 185 175 186 $before_text = ! empty( get_option( 'ccfwoo_before_countdown' ) ) ? get_option( 'ccfwoo_before_countdown' ) : '';176 $before_text = ! empty( get_option( 'ccfwoo_before_countdown' ) ) ? get_option( 'ccfwoo_before_countdown' ) : ''; 187 177 $inbetween_text = ! empty( get_option( 'ccfwoo_inbetween_countdown' ) ) ? get_option( 'ccfwoo_inbetween_countdown' ) : ''; 188 $after_text = ! empty( get_option( 'ccfwoo_after_countdown' ) ) ? get_option( 'ccfwoo_after_countdown' ) : '';178 $after_text = ! empty( get_option( 'ccfwoo_after_countdown' ) ) ? get_option( 'ccfwoo_after_countdown' ) : ''; 189 179 190 180 if ( ! empty( $before_text ) || ! empty( $before_text ) || ! empty( $before_text ) ) { -
checkout-countdown-for-woocommerce/trunk/functions/shortcode.php
r2953672 r3115281 80 80 */ 81 81 function ccfwoo_loading_html() { 82 $loading_dots = '<div class="c cfwoo-loading-dots">83 <div class="c cfwoo-loading-dots--dot"></div>84 <div class="c cfwoo-loading-dots--dot"></div>85 <div class="c cfwoo-loading-dots--dot"></div>82 $loading_dots = '<div class="checkout-countdown-loading"> 83 <div class="checkout-countdown-loading-dot"></div> 84 <div class="checkout-countdown-loading-dot"></div> 85 <div class="checkout-countdown-loading-dot"></div> 86 86 </div>'; 87 87 … … 96 96 97 97 $loading_dots = ccfwoo_loading_html(); 98 $has_cart_criteria = ccfwoo_has_cart_criteria(); 98 99 99 if ( $type === 'notice' ) {100 $classes = array( 'checkout-countdown-wrapper' ); 100 101 101 $notice_html = '<div class="checkout-countdown-wrapper checkout-countdown-notice" id="cc-countdown-wrap"> 102 <div class="checkout-countdown-content" id="cc-countdown-timer">'; 103 $notice_html .= $loading_dots; 104 $notice_html .= '</div></div>'; 105 // error, notice or success. 106 return wc_print_notice( $notice_html, 'error' ); 102 if ( ccfwoo_get_option( 'enable_banner_message' ) !== 'on' && ! $has_cart_criteria ) { 103 $classes[] = 'checkout-countdown-is-hidden'; 107 104 } 108 105 109 $add_classes = ''; 110 $add_id = ''; 111 112 if ( $type === 'shortcode' ) { 113 $add_classes .= 'checkout-countdown-shortcode cc-shortcode cc-countdown '; 114 $add_id = 'cc-countdown-timer'; 106 switch ( $type ) { 107 case 'shortcode': 108 $classes[] = 'checkout-countdown-shortcode'; 109 break; 110 case 'bar': 111 $classes[] = 'checkout-countdown-bar'; 112 break; 113 case 'notice': 114 $classes[] = 'checkout-countdown-notice'; 115 break; 115 116 } 116 117 117 if ( $type === 'bar' ) { 118 $add_classes .= 'checkout-countdown-bar '; 119 } 120 121 $add_classes .= ccfwoo_get_option( 'enable_banner_message' ) !== 'on' && ccfwoo_get_cart_content() === 0 ? 'ccfwoo-is-hidden' : ''; 122 123 $html = '<div class="checkout-countdown-wrapper ' . $add_classes . '" id="' . $add_id . '">'; 118 $html = '<div class="' . implode( ' ', $classes ) . '">'; 124 119 $html .= '<div class="checkout-countdown-content">'; 125 120 $html .= $loading_dots; … … 127 122 $html .= '</div>'; 128 123 124 /** 125 * Notices should be printed as WC notices - they won't display the optional welcome message. 126 */ 127 if ( $type === 'notice' ) { 128 if ( ! $has_cart_criteria ) { 129 return ''; 130 } 131 132 return wc_print_notice( $html, 'error' ); 133 } 134 129 135 return $html; 130 136 } -
checkout-countdown-for-woocommerce/trunk/languages/checkout-countdown-for-woocommerce.pot
r3065377 r3115281 9 9 "Language-Team: Puri.io\n" 10 10 "Last-Translator: Puri.io\n" 11 "POT-Creation-Date: 2024-0 4-05 10:37+0000\n"11 "POT-Creation-Date: 2024-07-10 06:01+0000\n" 12 12 "X-Poedit-Basepath: ..\n" 13 13 "X-Poedit-KeywordsList: __;_e;_ex:1,2c;_n:1,2;_n_noop:1,2;_nx:1,2,4c;_nx_noop:1,2,3c;_x:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" -
checkout-countdown-for-woocommerce/trunk/readme.txt
r3065377 r3115281 7 7 Donate link: https://www.paypal.me/morganhvidt/ 8 8 Requires at least: 5.0 9 Tested up to: 6. 59 Tested up to: 6.6 10 10 Requires PHP: 7.4 11 11 Stable tag: trunk … … 139 139 == Changelog == 140 140 141 = 4.0.0 = 142 143 V4 is major update which includes breaking changes to previous css customization. 144 145 * Update: Change to more reliable cart detection using cart fragments instead of cookies. This allows customizations server side such as triggering the countdown for specific products or categories. 146 * Fixed: a case where banner text would be inserted in the WC notices. 147 * Ready & tested for WordPress 6.6 148 * Ready & tested for WooCommerce 9.0 149 * Breaking Changes: Standardized the CSS classes - read the [https://puri.io/docs/checkout-countdown-for-woocommerce/troubleshoot/migration-guide-v4/](Migration Guide for v4) for more information. 150 141 151 = 3.2.3 = 142 152
Note: See TracChangeset
for help on using the changeset viewer.