Advertisement
Guest User

Untitled

a guest
Sep 5th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. $('.element .dropdown li').on('click',function (e) {
  2. var id = $(this).attr('data-id');
  3. var btn = $('.btn-add[data-id="' + id + '"]');
  4. var count = $('.element .dropdown li.active[data-id="' + id + '"]').length;
  5. if(!btn.hasClass('no-active')){
  6. $(btn).click();
  7. $(this).closest('.element').find('.ingredients').click();
  8. }
  9. console.log(count);
  10. var price = parseFloat($(this).parent().find('.ing-price-all').text());
  11. if($(this).hasClass('active')){
  12. price -= parseFloat($(this).find('.ing-price').text());
  13. count -= 1;
  14. $.ajax({
  15. url: '/ing_basket.php',
  16. type: 'POST',
  17. data: {id:id,type:'min',price:parseFloat($(this).find('.ing-price').text())},
  18. success: function(data){
  19. console.log(data);
  20. }
  21. });
  22. $('.quan-price').text(parseFloat($('.quan-price').text()) - parseFloat($(this).find('.ing-price').text()));
  23. }else{
  24. price += parseFloat($(this).find('.ing-price').text());
  25. count += 1;
  26. $.ajax({
  27. url: '/ing_basket.php',
  28. type: 'POST',
  29. data: {id:id,type:'plus',price:parseFloat($(this).find('.ing-price').text())},
  30. success: function(data){
  31. console.log(data);
  32. }
  33. });
  34. $('.quan-price').text(parseFloat($('.quan-price').text()) + parseFloat($(this).find('.ing-price').text()));
  35. }
  36. $(this).parent().find('.ing-price-all').text(price);
  37. $.cookie('price_'+id, price);
  38. $.cookie('ing-count_'+id, count);
  39. $(this).toggleClass('active');
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement