$('#checkout').click(function() {
        event.preventDefault();

        // Retrieve the products in order
        var cartItems = getCartItemsFromLocalStorage();
        var cartDetails = JSON.stringify(cartItems);
        $('#cart-details-input').val(cartDetails);

        // Retrieve the total amount
        var totalAmount = parseFloat($('.cart-total').text());
        $('#total-amount-input').val(totalAmount);
        //console.log(totalAmount);

    // Handle User Details form submission
    var form = $('#checkout-form')[0];
    var formData = new FormData(form);
    $.ajax({
        type: "POST",
        url: base_url +"shop/save/order",
        dataType: "JSON",
        data: formData,
        processData: false,
        contentType: false,
        headers: {'X-Requested-With': 'XMLHttpRequest'},
        success: function(data)
        {
            if(data.success == true)
            {
                start_load()
                toastr.success(data.msg);
                window.location.href = base_url +"shop";
                end_load()
                
            }else{
                //toastr.error(data.msg);
                var errorHtml = '<div class="alert alert-danger"><ul>';
                for (var key in data.validation) {
                    if (data.validation.hasOwnProperty(key)) {
                        errorHtml += '<li>' + data.validation[key] + '</li>';
                    }
                }
                errorHtml += '</ul></div>';
                $('#error-container').html(errorHtml);
            }
        }
    });

    });