Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.01 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2.  
  3.  
  4. getValue("#quantityOrder", ".product-quant-body");
  5. getValue("#quantityColor", ".product-quant-color-body");
  6. getCalcVal(".price-desc .product-name", "productNameVal");
  7.  
  8. // getCalcVal(".price-desc .product-name", "input[name=productNameVal]");
  9. // getCalcVal("price-cal-header.desktop .product-color", "input[name=color]");
  10. // getCalcVal(".price-cal-body .product-color-body span", "input[name=colorVal]");
  11. // getCalcVal("price-cal-header.desktop .product-tech-print", "input[name=technology]");
  12. // getCalcVal(".price-cal-body .product-tech-print-body span", "input[name=technologyVal]");
  13. // getCalcVal("price-cal-header.desktop .product-area-print", "input[name=surface]");
  14. // getCalcVal(".price-cal-body .product-area-print-body span", "input[name=surfaceVal]");
  15. // getCalcVal("price-cal-header.desktop .product-quant", "input[name=productAmount]");
  16. // getCalcVal(".price-cal-body .product-quant-body span", "input[name=productAmountVal]");
  17. // getCalcVal("price-cal-header.desktop .product-quant-color", "input[name=colorAmount]");
  18. // getCalcVal(".price-cal-body .product-quant-color-body span", "input[name=colorAmountVal]");
  19. // getCalcVal("price-cal-header.desktop .product-quant-price", "input[name=price]");
  20. // getCalcVal(".price-cal-body .product-quant-price-body span", "input[name=priceVal]");
  21. // getCalcVal("price-cal-header.desktop .product-prepress", "input[name=prepare]");
  22. // getCalcVal(".price-cal-body .product-prepress-body span", "input[name=prepareVal]");
  23. // getCalcVal("price-cal-header.desktop .product-final ", "input[name=sumPrice]");
  24. // getCalcVal(".price-cal-body .product-final-body span", "input[name=sumPriceVal]");
  25.  
  26. $("#quantityOrder").focusin(function() {
  27. $(this).keyup(function() {
  28. if ($(this).val() < 100) {
  29. $(".min-val.order").fadeIn();
  30. } else {
  31. $(".min-val.order").fadeOut();
  32. }
  33. checkValidation();
  34. });
  35. });
  36.  
  37.  
  38. $("#quantityColor").focusin(function() {
  39. $(this).keyup(function() {
  40.  
  41. if ($(this).val() < 1) {
  42. $(".min-val.color").fadeIn();
  43. $(".max-val.color").fadeOut();
  44. } else if ($(this).val() > 10) {
  45. $(".max-val.color").fadeIn();
  46. $(".min-val.color").fadeOut();
  47. } else {
  48. $(".min-val.color").fadeOut();
  49. $(".max-val.color").fadeOut();
  50. }
  51. checkValidation();
  52.  
  53. });
  54. });
  55.  
  56. function checkValidation() {
  57. var inpObj = document.getElementById("quantityOrder");
  58. var inpObj2 = document.getElementById("quantityColor");
  59.  
  60. if (inpObj.checkValidity() && inpObj2.checkValidity()) {
  61. $(".product-calc .product-calc-buttons button").prop("disabled", false)
  62. } else {
  63. $(".product-calc .product-calc-buttons button").prop("disabled", true)
  64. }
  65. }
  66.  
  67. $(".product-calc-buttons .btn-fill-avant").on("click", function() {
  68.  
  69.  
  70. getValue("#quantityOrder", ".product-quant-body");
  71. getValue("#quantityColor", ".product-quant-color-body");
  72.  
  73. // ------- Pobieranie koloru ------ //
  74.  
  75. var productFilterColor = $("#productFilterColor").children("option:selected").text();
  76. $(".product-color-body span").text(productFilterColor);
  77.  
  78.  
  79. // ------- Pobieranie technologi ------ //
  80.  
  81. var productTech = $("#productTech").children("option:selected").text();
  82. $(".product-tech-print-body span").text(productTech);
  83.  
  84.  
  85. // ------- Pobieranie powierzchni ------ //
  86.  
  87. var productSurface = $("#productSurface").children("option:selected").text();
  88. $(".product-area-print-body span").text(productSurface);
  89.  
  90.  
  91. // ------- Pobieranie ilości sztuk i kolorów ------ //
  92.  
  93. var quantityOrder = $("#quantityOrder").val();
  94. var quantityColor = $("#quantityColor").val();
  95.  
  96.  
  97. // ------- Pobieranie ceny 1 sztuki ------ //
  98.  
  99. var productPrice = $(".product-quant-price-body span").text();
  100. var productPriceNum = parseInt(productPrice);
  101.  
  102.  
  103. // ------- Pobieranie ceny przygotowalni ------ //
  104.  
  105. var preparePrice = $(".product-prepress-body span").text();
  106. var preparePriceNum = parseInt(preparePrice);
  107. var colorPrice = 130;
  108.  
  109. if ($("#productTech").val() == 'nadruk-chemoutwardzalny') {
  110. switch (quantityOrder) {
  111. case 100:
  112. colorPrice = 5
  113. break;
  114. case 200:
  115. colorPrice = 20
  116. break;
  117. }
  118. }
  119.  
  120.  
  121. if (quantityColor > 1) {
  122. colorPrice = 130 + (quantityColor - 1) * 50;
  123. }
  124.  
  125.  
  126. var num = quantityOrder * productPriceNum + colorPrice + preparePriceNum;
  127. var result = num.toFixed(2)
  128.  
  129. document.getElementById("result").innerHTML = result + " zł";
  130.  
  131. $("#price_calculation").fadeIn();
  132. $("#price_calculation .price-rever").fadeIn();
  133.  
  134. });
  135.  
  136. });
  137.  
  138.  
  139. // ------- Pobieranie ilości sztuk i kolorów ------ //
  140.  
  141. function getValue(buttonID, fieldClass) {
  142. var value = $(buttonID).val();
  143. $(fieldClass).text(value);
  144.  
  145. }
  146.  
  147. function getCalcVal(calcField, inputVal) {
  148. var value = $(calcField).text();
  149. $("input[name=" + inputVal + "]").val(value);
  150. }
  151.  
  152. $("#createCsv").on("click", function() {
  153. console.log(inputVal);
  154. // getCalcVal(".price-desc .product-name", "productNameVal");
  155. getCalcVal("price-cal-header.desktop .product-color", "name=color");
  156. // getCalcVal(".price-cal-body .product-color-body span", "input[name=colorVal]");
  157. // getCalcVal("price-cal-header.desktop .product-tech-print", "input[name=technology]");
  158. // getCalcVal(".price-cal-body .product-tech-print-body span", "input[name=technologyVal]");
  159. // getCalcVal("price-cal-header.desktop .product-area-print", "input[name=surface]");
  160. // getCalcVal(".price-cal-body .product-area-print-body span", "input[name=surfaceVal]");
  161. // getCalcVal("price-cal-header.desktop .product-quant", "input[name=productAmount]");
  162. // getCalcVal(".price-cal-body .product-quant-body span", "input[name=productAmountVal]");
  163. // getCalcVal("price-cal-header.desktop .product-quant-color", "input[name=colorAmount]");
  164. // getCalcVal(".price-cal-body .product-quant-color-body span", "input[name=colorAmountVal]");
  165. // getCalcVal("price-cal-header.desktop .product-quant-price", "input[name=price]");
  166. // getCalcVal(".price-cal-body .product-quant-price-body span", "input[name=priceVal]");
  167. // getCalcVal("price-cal-header.desktop .product-prepress", "input[name=prepare]");
  168. // getCalcVal(".price-cal-body .product-prepress-body span", "input[name=prepareVal]");
  169. // getCalcVal("price-cal-header.desktop .product-final ", "input[name=sumPrice]");
  170. // getCalcVal(".price-cal-body .product-final-body span", "input[name=sumPriceVal]");
  171.  
  172. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement