templates/frontend/index/js/remove-from-cart.html.twig line 1

Open in your IDE?
  1. <script type="text/javascript">
  2.     $(document).on('click', '.clickable_area.area_selected', function () {
  3.         let uuidArea = $(this).data('uuid-area');
  4.         let url = '{{ path("app_frontend_ajax_get_area", {'uuidArea': 'uuidArea'}) }}';
  5.         url = url.replace("uuidArea", uuidArea);
  6.         $.ajax({
  7.             url: url,
  8.             method: "GET",
  9.             dataType: 'json',
  10.             success: function (area) {
  11.                 let $modal = $('#removeFromCartModal');
  12.                 let description = $modal.find('.description').text();
  13.                 $modal.find('.modal-title').text(area.name);
  14.                 $modal.find('.description').text(description.replace('%areaName%', area.name));
  15.                 $modal.find('#input__idArea').val(area.id);
  16.                 $modal.find('.removeFromCartButton').attr('data-uuid-area', area.uuid);
  17.                 $modal.modal('show');
  18.             }
  19.         });
  20.     })
  21.     .on('click', '.removeFromCartButton', function () {
  22.         let $modal = $('#removeFromCartModal');
  23.         let uuidArea = $(this).attr('data-uuid-area');
  24.         let url = '{{ path("app_frontend_cart_remove_item", {'uuidCustomerAdvertisingArea': 'uuidCustomerAdvertisingArea'}) }}';
  25.         let button = $(this);
  26.         url = url.replace("uuidCustomerAdvertisingArea", uuidArea);
  27.         $.ajax({
  28.             url: url,
  29.             method: "GET",
  30.             dataType: 'json',
  31.             success: function (data) {
  32.                 markAreaAsSelectable(uuidArea);
  33.                 $('#sponsor_customerAdvertisingArea option[value='+uuidArea+']').attr('selected','');
  34.                 button.closest('.product-item').fadeOut();
  35.                 $('#shopping-cart').find('.product-area').children('.product-item').each(function (index, item) {
  36.                     if ($(item).data('uuid') === data.uuid) {
  37.                         $(item).fadeOut();
  38.                     }
  39.                 });
  40.                 refreshCartTotalAndItemCount();
  41.                 $modal.modal('hide');
  42.             }
  43.         });
  44.     });
  45.     function markAreaAsSelectable(uuidArea) {
  46.         let prefix = 'customer-advertising-area-'
  47.         let $area = $('#'+prefix+uuidArea);
  48.         $area
  49.             .addClass('area_free')
  50.             .removeClass('area_selected')
  51.         ;
  52.     }
  53. </script>