Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. $(document).ready(function(){
  2. $('#delete-basket-item').live('click', function(){
  3. var deleted_products = [];
  4. $('.basket-item-checkbox:checked').each(function(){
  5. deleted_products.push($(this).attr('_code'))
  6. })
  7.  
  8. if(deleted_products.length > 0){
  9. $.post('ajax/deleteProductsFromBasket',
  10. {
  11. 'products': deleted_products
  12. }, function(data, responseCode){
  13. if(util.check_response_status(responseCode)){
  14. $('#content-inner').html(data);
  15. util.show_message(util.__('The product(s) have successfully removed from basket'));
  16. }
  17. }
  18. );
  19. }else{
  20. util.show_error(util.__('You should select at least one product'));
  21. }
  22. return false;
  23. });
  24.  
  25. $('#update-basket').live('click', function(){
  26. var products = [];
  27. $('.basket-item-checkbox').each(function(){
  28. var tmp = {};
  29. tmp.code = $(this).attr('_code');
  30. tmp.value = $(this).parent().find('.count').val();
  31. products.push(tmp)
  32. })
  33.  
  34. $.post('ajax/updateProductsInBasket',
  35. {
  36. 'products': products
  37. }, function(data, responseCode){
  38. if(util.check_response_status(responseCode)){
  39. $('#content-inner').html(data);
  40. util.show_message(util.__('The basket have successfully updated'));
  41. }
  42. }
  43. );
  44.  
  45. return false;
  46. });
  47.  
  48. //proceed-order
  49. $("#proceed-order").live("click",function(){
  50. $('#proceed_form').submit(function(){
  51. return false;
  52. });
  53. $("#dialog").dialog("open");
  54.  
  55. });
  56. $("#dialog").dialog({
  57. autoOpen: false,
  58. width: 700,
  59. buttons: {
  60. "I'd like to use an order number": function() {
  61. $(this).dialog("close");
  62. $("#confirm").dialog("open");
  63. },
  64. "No order number required - place order without": function() {
  65. $(this).dialog("close");
  66. proceed();
  67. }
  68. }
  69. });
  70.  
  71. $("#confirm").dialog({
  72. autoOpen: false,
  73. width: 700,
  74. buttons: {
  75. "Place order": function() {
  76. $(this).dialog("close");
  77. reference = $('#order_num').val();
  78. $('#reference').attr({value:reference});
  79. proceed();
  80. },
  81. "No order number required - place order without": function() {
  82. $(this).dialog("close");
  83. proceed();
  84. }
  85. }
  86. });
  87. function proceed(){
  88. var products = [];
  89. $('.basket-item-checkbox').each(function(){
  90. var tmp = {};
  91. tmp.code = $(this).attr('_code');
  92. tmp.value = $(this).parent().find('.count').val();
  93. tmp.reference = $('#reference').val();
  94. products.push(tmp)
  95. })
  96.  
  97. $('.preloader').show();
  98. $.post('ajax/proceedOrder',
  99. {
  100. 'products': products
  101. }, function(data, responseCode){
  102. if(util.check_response_status(responseCode)){
  103. $('#content-inner').html(data);
  104. util.show_message(util.__('Thank You! Your order has been processed, detailed information is below.'));
  105. }
  106. $('.preloader').hide();
  107. }
  108. );
  109. return false;
  110. }
  111. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement