Advertisement
chernov2000

Зачеркивание цен в карточке

Jun 1st, 2022
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.         $(document).ready(function(){
  3.             function magnum(){
  4.                 const screenWidth = window.innerWidth;
  5.             if (screenWidth >= 768) {
  6.             $('#ex1').zoom(
  7.                     {
  8.                         magnify:1.5,
  9.                     }
  10.                 );
  11.          };
  12. }
  13. function showAtionPrice(){
  14. var cat_id = $('#ex1').attr('data-root-id');
  15. if (cat_id == 165||cat_id == 176||cat_id == 184)
  16. {
  17.     $(".time_buy_sticker").append('<img style="width:100%; z-index:1000" src="/upload/flag_25.png" alt="Скидка 25%" srcset="">');
  18.  
  19. $(".catalog-item-prop > .data-price-table").each(function (index, el){  
  20. if (this.hasAttribute("data-rozn-p")){    
  21.     var old_price_rozn = $(this).attr('data-rozn-p');
  22.     var new_price_rozn = Math.round(old_price_rozn * 0.75);
  23.     $(this).addClass("action_may").before('<span class="new_price_vew">' + new_price_rozn + '</span>');  
  24. }
  25. if (this.hasAttribute("data-m-opt-p")){
  26.     var old_price_mopt = $(this).attr('data-m-opt-p');    
  27.     var new_price_mopt = Math.round(old_price_mopt * 0.80);
  28.     $(this).addClass("action_may").before('<span class="new_price_vew">' + new_price_mopt + '</span>');  
  29. }
  30. });  
  31. }
  32. if (cat_id == 165||cat_id == 176||cat_id == 184){
  33. // Для мобильной верстки
  34. $(".formdata-p > span").each(function (index, el){  
  35.     if (this.hasAttribute("data-rozn-p-mob")){    
  36.          var old_price_rozn_m = $(this).attr('data-rozn-p-mob');
  37.          var new_price_rozn_m = Math.round(old_price_rozn_m * 0.75);
  38.          $(this).addClass("action_may").after('<span class="new_price_vew_mob">&nbsp;' + new_price_rozn_m + '&nbsp;руб</span>');  
  39.     }
  40.     if (this.hasAttribute("data-mopt-p-mob")){
  41.          var old_price_mopt_m = $(this).attr('data-mopt-p-mob');    
  42.          var new_price_mopt_m = Math.round(old_price_mopt_m * 0.80);
  43.          $(this).addClass("action_may").after('<span class="new_price_vew_mob">&nbsp;' + new_price_mopt_m + '&nbsp;руб</span>');  
  44.     }}
  45.  
  46. )}
  47. }
  48.  
  49. setTimeout(magnum, 1000);
  50. setTimeout(showAtionPrice, 1500);
  51.         });
  52.     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement