Facebook
From haris, 2 Years ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 76
  1. @extends('layouts.front')
  2.  
  3. @section('content')
  4.     <!-- entry-header-area-start -->
  5.     <div class="entry-header-area mt-60">
  6.         <div class="container">
  7.             <div class="row">
  8.                 <div class="col-lg-12">
  9.                     <div class="entry-header-title">
  10.                         <h2>Wishlist</h2>
  11.                     </div>
  12.                 </div>
  13.             </div>
  14.         </div>
  15.     </div>
  16.     <!-- entry-header-area-end -->
  17.     <!-- cart-main-area-start -->
  18.     <div class="cart-main-area mb-70">
  19.         <div class="container">
  20.             <div class="row">
  21.                 <div class="col-lg-12">
  22.                     <form action="#">
  23.                         <div class="table-content table-responsive mb-15 border-1">
  24.                             <table>
  25.                                 <thead>
  26.                                     <tr>
  27.                                         <th>No</th>
  28.                                         <th>Gambar</th>
  29.                                         <th class="product-thumbnail">{{ __('messages.label_product') }}</th>
  30.                                         <th class="product-name">{{ __('messages.label_photo') }}</th>
  31.                                         <th class="product-price">{{ __('messages.label_action') }}</th>
  32.                                     </tr>
  33.                                 </thead>
  34.                                 <tbody>
  35.                                     @php
  36.                                         $total = 0;
  37.                                     @endphp
  38.                                     @foreach ($items as $key=> $item)
  39.                                         @php
  40.                                             $price = $item->product->is_discount == 1 ? $item->product->price_striked : $item->product->price;
  41.                                             $subtotal = $item->quantity * $price;
  42.                                             $total += $subtotal;
  43.                                         @endphp
  44.                                         <tr id="{{ $item->id }}">
  45.                                            
  46.                                             <th>{{ $items->firstItem()+$key }}</th>
  47.                                             <td class="product-thumbnail"><a href="#"><img
  48.                                                         src="{{ MyHelper::get_uploaded_file_url($item->product->thumbnail) }}"
  49.                                                         alt="foto produk" /></a>
  50.                                             </td>
  51.                                             <td class="product-name">
  52.                                                 <a
  53.                                                     href="{{ route('product.show', $item->product->slug) }}">{{ $item->product->name }}</a>
  54.                                             </td>
  55.                                             <td class="product-price"><span class="amount">
  56.                                                     @if ($item->product->is_discount)
  57.                                                         <span class="old-price"
  58.                                                             style="font-size: 14px !important;"><span
  59.                                                                 style="font-size: 14px !important;">Rp</span>
  60.                                                             {{ MyHelper::rupiah($item->product->price) }}</span> <br>
  61.                                                         <span style="font-size:18px !important;"><span
  62.                                                                 style="font-size: 16px !important;">Rp</span>
  63.                                                             {{ MyHelper::rupiah($item->product->price_striked ?? 0) }}</span>
  64.                                                     @else
  65.                                                         <span style="font-size:18px !important;"><span
  66.                                                                 style="font-size: 16px !important;">Rp</span>
  67.                                                             {{ MyHelper::rupiah($item->product->price) }}</span>
  68.                                                     @endif
  69.                                                 </span></td>
  70.                                                 <th class="product-remove">
  71.                                                 <button class="delete_wishlist" type="button" id="{{ $item->id }}"><i
  72.                                                         class="fa fa-times"></i></button>
  73.                                             </th>
  74.                                         </tr>
  75.                                     @endforeach
  76.                                 </tbody>
  77.                             </table>
  78.                              <div class="pull-right">
  79.                                                     {{ $items->links() }}
  80.                                                     </div>
  81.                         </div>
  82.                     </form>
  83.                 </div>
  84.             </div>
  85.         </div>
  86.     </div>
  87.     <!-- cart-main-area-end -->
  88. @endsection
  89.  
  90. @push('js')
  91.     <script>
  92.         $(document).ready(function() {
  93.             var user_id = '{{ auth()->user()->id }}';
  94.             var the_total = 0;
  95.  
  96.             $(document).on('click', '.delete_wishlist', function(e) {
  97.                 var wishlist_id = $(this).attr('id');
  98.                 var the_data = {
  99.                     wishlist_id: wishlist_id,
  100.                     user_id: user_id
  101.                 };
  102.                 e.preventDefault();
  103.  
  104.                 swal({
  105.                     title: 'Hapus dari wishlist?',
  106.                     text: "Apakah anda yakin menghapus barang ini dari wishlist anda?",
  107.                     icon: 'warning',
  108.                     buttons: {
  109.                         confirm: {
  110.                             text: 'Ya!',
  111.                             className: 'btn btn-success'
  112.                         },
  113.                         cancel: {
  114.                             visible: true,
  115.                             className: 'btn btn-danger'
  116.                         }
  117.                     }
  118.                 }).then((Delete) => {
  119.                     if (Delete) {
  120.                         // do ajax delete
  121.                         $.ajax({
  122.                             type: "POST",
  123.                             url: "{{ route('v1.delete_wishlist_item') }}",
  124.                             data: the_data,
  125.                             dataType: "json",
  126.                             headers: {
  127.                                 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  128.                             },
  129.                             success: function(res) {
  130.                                 if (res.data.is_success == true) {
  131.                                     var sessionMessage = res.meta.message;
  132.                                     toastr.options = {
  133.                                         "closeButton": true,
  134.                                         "debug": false,
  135.                                         "newestOnTop": false,
  136.                                         "progressBar": true,
  137.                                         "positionClass": "toast-bottom-right",
  138.                                         "preventDuplicates": false,
  139.                                         "onclick": null,
  140.                                         "showDuration": "300",
  141.                                         "hideDuration": "1000",
  142.                                         "timeOut": "5000",
  143.                                         "extendedTimeOut": "1000",
  144.                                         "showEasing": "swing",
  145.                                         "hideEasing": "linear",
  146.                                         "showMethod": "fadeIn",
  147.                                         "hideMethod": "fadeOut"
  148.                                     }
  149.  
  150.                                     $(document).ready(function onDocumentReady() {
  151.                                         toastr.success(sessionMessage);
  152.                                     });
  153.                                     $('tr#' + wishlist_id).fadeOut();
  154.                                     reCalculateTotal(user_id)
  155.                                     reloadCartItems(user_id);
  156.                                 } else {
  157.                                     const el = document.createElement('div')
  158.                                     el.innerHTML =
  159.                                         "Silahkan <a href='{{ route('register') }}'>Registrasi</a> dahulu untuk melanjutkan"
  160.                                     swal({
  161.                                         title: 'Registrasi Dahulu',
  162.                                         content: el,
  163.                                         icon: 'warning',
  164.                                         buttons: {
  165.                                             confirm: {
  166.                                                 className: 'btn btn-warning'
  167.                                             }
  168.                                         }
  169.                                     });
  170.                                 }
  171.                             },
  172.                             error: function(res) {
  173.                                 console.log(res);
  174.                                 swal({
  175.                                     title: 'Gagal',
  176.                                     text: res.metamessage,
  177.                                     icon: 'error',
  178.                                     buttons: {
  179.                                         confirm: {
  180.                                             className: 'btn btn-warning'
  181.                                         }
  182.                                     }
  183.                                 });
  184.                             }
  185.                         })
  186.  
  187.  
  188.                     } else {
  189.                         swal.close();
  190.                     }
  191.                 });
  192.             })
  193.  
  194.         })
  195.     </script>
  196. @endpush
  197.