PHP Classes

File: resources/views/frontend/partials/scripts.blade.php

Recommend this page to a friend!
  Classes of Maniruzzaman Akash   Laravel Ecommerce Site   resources/views/frontend/partials/scripts.blade.php   Download  
File: resources/views/frontend/partials/scripts.blade.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Laravel Ecommerce Site
Application to sell products using Laravel
Author: By
Last change:
Date: 1 year ago
Size: 955 bytes
 

Contents

Class file image Download
<script src="{{ asset('js/jquery-3.3.1.min.js') }}"></script>
<script src="{{ asset('js/popper.min.js') }}" ></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>

<!-- JavaScript -->
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.11.2/build/alertify.min.js"></script>


<script>
    $.ajaxSetup({
      headers: {
        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
      }
    });

    function addToCart(product_id){
        var url = "{{ url('/') }}";
        $.post( url+"/api/carts/store",
            {
                product_id: product_id
            })
          .done(function( data ) {
              data = JSON.parse(data);
            if(data.status == 'success'){
                // toast
                alertify.set('notifier','position', 'top-center');
                alertify.success('Item added to cart successfully !! Total Items: '+data.totalItems+ '<br />To checkout <a href="{{ route('carts') }}">go to checkout page</a>');
 
                $("#totalItems").html(data.totalItems);
            }
          });
    }
</script>