Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.                 <script type="text/javascript"><!--
  2.                     var special_row = {{ special_row }};
  3.                     var price_brutto = {{ (price*1.23)|number_format(2,'.','') }};
  4.  
  5.                     $(document).on('submit', 'form[data-confirm]', function(e) {
  6.                         for (i = 0; i < special_row; i++) {
  7.  
  8.                             var sale_type = $('#special-option' + i + '').val();
  9.                             var sale_value = $('#specialprice' + i +'').val();
  10.                            
  11.                             if ((sale_type == '-%' && sale_value > 30)) {
  12.                                 var sale_price = (price_brutto * (1-(sale_value/100))).toFixed(2);
  13.                                 $('#form-product').attr("data-confirm", "Czy na pewno ustawić tak dużą wartość zniżki? Cena produktu po obniżce wyniesie " + sale_price +"zł brutto, cena regularna to " + price_brutto + "zł brutto");
  14.                                 if(!confirm($(this).data('confirm'))) {
  15.                                     e.stopImmediatePropagation();
  16.                                     e.preventDefault();
  17.                                 }
  18.                             } else if (sale_type == '=') {
  19.                                 var sale_price = (sale_value * 1.23).toFixed(2);
  20.                                 var percent = (1-(sale_price/price_brutto)).toFixed(2);
  21.  
  22.                                 if (percent > 0.3) {
  23.                                 $('#form-product').attr("data-confirm", "Czy na pewno chcesz ustawić cenę tego produktu na " + sale_price + "zł brutto (obniżka o " + percent * 100 + "%)? Cena regularna to " + price_brutto + " zł brutto");
  24.                                 if(!confirm($(this).data('confirm'))) {
  25.                                     e.stopImmediatePropagation();
  26.                                     e.preventDefault();
  27.                                 }
  28.                                 }
  29.                             }
  30.                         }
  31.                     });
  32.  
  33.                 </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement