templates/frontend/index/js/add-to-cart.html.twig line 1

Open in your IDE?
  1. <script type="text/javascript">
  2.     $(document)
  3.         .on('click', '.clickable_area.area_free', function () {
  4.             let uuidArea = $(this).data('uuid-area');
  5.             let url = '{{ path("app_frontend_cart_modal_add", {'uuidArea': 'uuidArea'}) }}';
  6.             url = url.replace("uuidArea", uuidArea);
  7.             $.ajax({
  8.                 url : url,
  9.                 method: "GET",
  10.                 success: function(response) {
  11.                     let $modal = $('#addToCartModal')
  12.                     $modal.find('.modal-body').html(response);
  13.                     $modal.modal('show');
  14.                 }
  15.             });
  16.         })
  17.         .on('click', '.clickable_area.area_sold', function () {
  18.             let uuidArea = $(this).data('uuid-area');
  19.             let url = '{{ path("app_frontend_ajax_get_sponsor", {'uuidArea': 'uuidArea'}) }}';
  20.             url = url.replace("uuidArea", uuidArea);
  21.             $.ajax({
  22.                 url : url,
  23.                 method: "GET",
  24.                 success: function (modalContent) {
  25.                     let $modal = $('#areaSoldModal');
  26.                     $modal.find('.modal-content').html(modalContent);
  27.                     $modal.modal('show');
  28.                 }
  29.             });
  30.         })
  31.         .on('click', '.addToCartButton', function () {
  32.             let $modal = $('#addToCartModal');
  33.             let uuidCustomerAdvertisingArea = $modal.find('#uuid-area').val();
  34.             let withinSetupPrice = $modal.find('.withinSetupPrice').is(':checked');
  35.             $.ajax({
  36.                 url: '{{ path("app_frontend_cart_add_item") }}',
  37.                 method: "POST",
  38.                 data: {
  39.                     'uuidCustomerAdvertisingArea': uuidCustomerAdvertisingArea,
  40.                     'withinSetupPrice': withinSetupPrice
  41.                 },
  42.                 success: function (area) {
  43.                     markAreaAsSelected(uuidCustomerAdvertisingArea);
  44.                     let $shoppingCart = $('#shopping-cart');
  45.                     let template = getShoppingCartItem(area);
  46.                     $shoppingCart.find('.product-area').append(template);
  47.                     refreshCartTotalAndItemCount();
  48.                     $modal.modal('hide');
  49.                 }
  50.             });
  51.         })
  52.     ;
  53.     function markAreaAsSelected(uuidArea) {
  54.         let prefix = 'customer-advertising-area-'
  55.         let $area = $('#'+prefix+uuidArea);
  56.         $area
  57.             .addClass('area_selected')
  58.             .removeClass('area_free')
  59.         ;
  60.     }
  61. </script>