andre пре 4 година
родитељ
комит
9e1d8ea0db
1 измењених фајлова са 15 додато и 9 уклоњено
  1. 15 9
      js/scripts.js

+ 15 - 9
js/scripts.js

@@ -3816,34 +3816,40 @@ function validate_captcha(form)
 }
 
 function updateProductTotalMessage(billingcycle) {
+    console.log(billingcycle);
     var now = new Date();
     var orderDay = daysIntoYear(new Date(now.getFullYear(), now.getMonth(), now.getDate()));
     switch(billingcycle) {
         case 'monthly':
-            console.log(billingcycle);
             billingDay = daysIntoYear(new Date(now.getFullYear(), now.getMonth() + 1, 0));
-            console.log(billingDay - orderDay);
             jQuery('#producttotalmessage').html('Monatlich');
             break;
         case 'quarterly':
-            console.log(billingcycle);
-            if (now.getMonth() < 4) {
-                billingDay = daysIntoYear(new Date(now.getFullYear(), 2, 31));
-                console.log(billingDay - orderDay);
+            if (now.getMonth() < 3) {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 2, 31)); // 31.3.
+            } else if (now.getMonth() < 6) {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 5, 30)); // 30.6.
+            } else if (now.getMonth() < 9) {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 8, 30)); // 30.9.
+            } else {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 11, 31)); // 31.12.
             }
             jQuery('#producttotalmessage').html('4teljährlich');
             break;
         case 'semiannually':
-            console.log(billingcycle);
+            if (now.getMonth() < 6) {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 5, 30)); // 30.6.
+            } else {
+                billingDay = daysIntoYear(new Date(now.getFullYear(), 11, 31)); // 31.12.
+            }
             jQuery('#producttotalmessage').html('Halbjährlich');
             break;
         case 'annually':
-            console.log(billingcycle);
             billingDay = daysIntoYear(new Date(now.getFullYear(), 11, 31));
-            console.log(billingDay - orderDay);
             jQuery('#producttotalmessage').html('Jährlich');
             break;
     }
+    console.log(billingDay - orderDay);
 }
 
 function daysIntoYear(date){