Skip to content

Commit

Permalink
Add checkout page and fields validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiril Kirkov committed Oct 11, 2017
1 parent 3e69dca commit c251209
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 30 deletions.
28 changes: 28 additions & 0 deletions app/Http/Controllers/Publics/CheckoutController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Http\Controllers\Publics;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Publics\ProductsModel;
use App\Models\Publics\HomeModel;

class CheckoutController extends Controller
{

public function index()
{
$productsModel = new ProductsModel();
$homeModel = new HomeModel();
$promoProducts = $productsModel->getProductsWithTags(['promo']);
$mostSelledProducts = $productsModel->getMostSelledProducts();
$carousel = $homeModel->getCarouselSliders();
return view('publics.checkout', [
'promoProducts' => $promoProducts,
'mostSelledProducts' => $mostSelledProducts,
'carousel' => $carousel,
'cartProducts' => $this->products
]);
}

}
16 changes: 1 addition & 15 deletions nbproject/private/private.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group>
<file>file:/var/www/html/laravel/resources/views/publics/products.blade.php</file>
<file>file:/var/www/html/laravel/resources/lang/bg/public_pages.php</file>
<file>file:/var/www/html/laravel/resources/lang/en/public_pages.php</file>
<file>file:/var/www/html/laravel/public/css/public.css</file>
<file>file:/var/www/html/laravel/resources/views/layouts/app_public.blade.php</file>
<file>file:/var/www/html/laravel/public/js/public.js</file>
<file>file:/var/www/html/laravel/app/Cart.php</file>
<file>file:/var/www/html/laravel/app/Http/Controllers/Controller.php</file>
<file>file:/var/www/html/laravel/resources/views/publics/preview.blade.php</file>
<file>file:/var/www/html/laravel/routes/web.php</file>
<file>file:/var/www/html/laravel/app/Http/Controllers/Publics/CartController.php</file>
<file>file:/var/www/html/laravel/app/Models/Publics/ProductsModel.php</file>
<file>file:/var/www/html/laravel/resources/views/publics/home.blade.php</file>
</group>
<group/>
</open-files>
</project-private>
19 changes: 14 additions & 5 deletions public/css/public.css
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ body {font-family: 'Roboto', sans-serif;}
.home-page .carousel-control i {top: 50%; position: absolute; font-size:48px;}
.home-page .promo {margin-bottom: 40px;}

.products-title h2, .product-title h1 {margin: 0; padding-bottom:15px; margin-bottom: 15px; text-transform: uppercase; font-size:22px; font-weight: bold; border-bottom: 1px solid #e8e8e8; color:#333333;}
.section-title h2, .section-title h1 {margin: 0; padding-bottom:15px; margin-bottom: 15px; text-transform: uppercase; font-size:22px; font-weight: bold; border-bottom: 1px solid #e8e8e8; color:#333333;}

.product { box-shadow: 0; transition: box-shadow 0.3s ease-in-out; padding: 10px; }
.product:hover {box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12); }
Expand All @@ -62,7 +62,7 @@ body {font-family: 'Roboto', sans-serif;}
#modalBuyBtn .continue-shopping a {color:#666666; font-size:16px; text-transform: uppercase;}
#modalBuyBtn .continue-shopping a:hover {color:#00bcd4; text-decoration: none; -moz-transition: all .2s ease-in; -o-transition: all .2s ease-in; -webkit-transition: all .2s ease-in; transition: all .2s ease-in;}

.product-preview, .products-page, .contacts-page { padding-top: 40px; margin-bottom: 40px;}
.product-preview, .products-page, .contacts-page, .checkout-page { padding-top: 40px; margin-bottom: 40px;}
.product-preview .first-part { margin-bottom: 20px; }
.product-preview .category { margin-bottom: 20px; }
.product-preview .category span {color:#999999;}
Expand All @@ -79,7 +79,7 @@ body {font-family: 'Roboto', sans-serif;}
.product-preview .buy .buy-now {float: right; margin-top: 10px; background-color: #8ec63f; border:2px solid #7eb531; color:#ffffff; padding: 15px 50px; text-transform: uppercase; font-weight: bold;}
.product-preview .details {border:1px solid #e8e8e8; padding: 15px;}

.contacts-page .form-control { margin-bottom: 20px; border:2px solid #e8e8e8; box-shadow: none; border-radius: 0; padding: 15px 20px; color:#333333; height: auto;}
.form-control { margin-bottom: 20px; border:2px solid #e8e8e8; box-shadow: none; border-radius: 0; padding: 15px 20px; color:#333333; height: auto;}
.contacts-page .submit {background-color: #8ec63f; border:1px solid #74a62e; color:#ffffff; font-weight: 700; font-size:14px; text-transform: uppercase; display: block; padding: 10px; text-align: center;}

footer .social {background-color: #8ec63f; padding: 20px 0; color:#ffffff; text-align: center;}
Expand Down Expand Up @@ -126,11 +126,20 @@ footer .copy-rights {background-color: #212331; color:#616f7a; padding: 10px 0;}
.cart-products-fast-view .pay-sum {color:#99a9b5;font-size:20px; font-weight: bold; margin-bottom: 10px;}
.cart-products-fast-view .pay-sum .text {float:left;}
.cart-products-fast-view .pay-sum .sum {float:right;}
.cart-products-fast-view .buy-now-fast-cart {background-color: #8ec63f; border:1px solid #74a62e; display: block; padding: 10px; text-align: center; color:#ffffff; text-transform: uppercase;}
.cart-products-fast-view .buy-now-fast-cart:hover {text-decoration: none;}
.cart-products-fast-view .removeQantity {position: absolute; right:5px; top:5px; color:#fff;}
.cart-products-fast-view ul li .link:hover .price {color:#00bcd4; text-decoration: none; -moz-transition: all .2s ease-in; -o-transition: all .2s ease-in; -webkit-transition: all .2s ease-in; transition: all .2s ease-in;}

.green-btn {background-color: #8ec63f; border:1px solid #74a62e; display: block; padding: 10px; text-align: center; color:#ffffff; text-transform: uppercase;}
.green-btn:hover {text-decoration: none; color:#fff;}

.checkout-page .payment-types {margin-bottom: 30px;}
.checkout-page .radios {display: none;}
.checkout-page .box-type { text-align: center; padding: 10px; background-color: #f8f8f8; border:2px solid #e0e0e0; width:230px; height: 90px; cursor: pointer; -moz-transition: all .2s ease-in; -o-transition: all .2s ease-in; -webkit-transition: all .2s ease-in; transition: all .2s ease-in;}
.checkout-page .box-type img {margin: 0 auto; margin-bottom: 5px; height: 40px;}
.checkout-page .box-type span {text-transform: uppercase; font-weight: bold}
.checkout-page .box-type.active, .checkout-page .box-type:hover {border:2px solid #8ec63f; -moz-transition: all .2s ease-in; -o-transition: all .2s ease-in; -webkit-transition: all .2s ease-in; transition: all .2s ease-in;}
.checkout-page .errors {display: none;}

.alert{text-align: center;}
.alert.alert-danger {background-color: #f55a4e; border-radius: 3px; box-shadow: 0 12px 20px -10px rgba(244, 67, 54, 0.28), 0 4px 20px 0 rgba(0, 0, 0, 0.12), 0 7px 8px -5px rgba(244, 67, 54, 0.2); color: #ffffff; border-color: transparent;}
.alert.alert-success {background-color: #5cb860; border-radius: 3px; box-shadow: 0 12px 20px -10px rgba(76, 175, 80, 0.28), 0 4px 20px 0 rgba(0, 0, 0, 0.12), 0 7px 8px -5px rgba(76, 175, 80, 0.2); color: #ffffff; border-color: transparent;}
Expand Down
Binary file added public/img/cash_on_deliv.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 36 additions & 1 deletion public/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ $('.buy-now.to-cart').click(function () {
$('.cart-button').hover(function () {
$('.cart-products-fast-view').fadeIn(200);
});
/*
* change radio button selection for
* checkout payment type
*/
$('.box-type').click(function () {
var radio_val = $(this).data('radio-val');
$('input:radio[name="payment_type"][value="' + radio_val + '"]').prop('checked', true);
$(this).addClass('active');
});
/*
* Hide cart products in fast view
*/
Expand Down Expand Up @@ -135,5 +144,31 @@ function removeQuantity(id) {
}).done(function (data) {
renderCartProducts();
});


}
/*
* Complete order from checkout page - submit btn
*/
function completeOrder() {
$('#errors').empty().hide();
var errors = new Array();
var phone = $('[name="phone"]').val();
var address = $('[name="address"]').val();
if ($.trim(phone).length <= 0) {
errors[0] = variables.phoneReq;
}
if ($.trim(address).length <= 0) {
errors[1] = variables.addressReq;
}
if (errors.length > 0) {
$.each(errors, function (index, value) {
$('#errors').append(value + '<br>');
});
$('#errors').fadeIn(200);
$('html, body').animate({
scrollTop: $("#errors").offset().top - 100
}, 500);
} else {
document.getElementById('set-order').submit();
}
}
18 changes: 17 additions & 1 deletion resources/lang/bg/public_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,21 @@
'too_short_message' => 'Не сте въвели съобщение',
'problem_message_send' => 'Изглежда, че има проблем с изпращането на имейла. Моля обадете ни се!',
'subtotal' => 'Междинна сума',
'payment' => 'Плащане'
'payment' => 'Плащане',
'payment_type' => 'Избери начин на плащане',
'cash_on_delivery' => 'Наложен платеж',
'delivery_address' => 'Адрес за доставка',
'name' => 'Име',
'family' => 'Фамилия',
'email_address' => 'Имейл адрес',
'phone' => 'Телефон',
'address' => 'Адрес',
'city' => 'Град',
'post_code' => 'Пощенски код',
'notes' => 'Забележки',
'discount_code' => 'Въведи код за отстъпка',
'check_discount_code' => 'Провери',
'complete_order' => 'Завърши поръчката',
'address_field_req' => 'Полето за адрес е задължително',
'phone_field_req' => 'Полето за телефон е задължително'
];
18 changes: 17 additions & 1 deletion resources/lang/en/public_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,21 @@
'too_short_message' => 'Too short message',
'problem_message_send' => 'It seems have error with email send! Please call us!',
'subtotal' => 'Subtotal',
'payment' => 'Payment'
'payment' => 'Payment',
'payment_type' => 'Choose payment type',
'cash_on_delivery' => 'Cash on delivery',
'delivery_address' => 'Delivery address',
'name' => 'Name',
'family' => 'Family',
'email_address' => 'Email Address',
'phone' => 'Phone',
'address' => 'Address',
'city' => 'City',
'post_code' => 'Post code',
'notes' => 'Notes',
'discount_code' => 'Enter discount code',
'check_discount_code' => 'Check',
'complete_order' => 'Complete order',
'address_field_req' => 'Address field is required',
'phone_field_req' => 'Phone filed is required'
];
10 changes: 7 additions & 3 deletions resources/views/layouts/app_public.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
<span class="sum">{{$sum}}</span>
<div class="clearfix"></div>
</div>
<a href="{{lang_url('checkout')}}" class="buy-now-fast-cart">{{__('public_pages.payment')}}</a>
<a href="{{lang_url('checkout')}}" class="green-btn">{{__('public_pages.payment')}}</a>
</div>
</div>
@php
Expand Down Expand Up @@ -228,8 +228,12 @@
<script>
var urls = {
addProduct: "{{ url('addProduct') }}",
removeProductQuantity: "{{ url('removeProductQuantity') }}",
getProducts: "{{ url('getGartProducts') }}"
removeProductQuantity: "{{ url('removeProductQuantity') }}",
getProducts: "{{ url('getGartProducts') }}"
};
var variables = {
addressReq: "{{__('public_pages.address_field_req')}}",
phoneReq: "{{__('public_pages.phone_field_req')}}"
};
</script>
<script src="{{ asset('js/jquery-3.2.1.min.js') }}" type="text/javascript"></script>
Expand Down
57 changes: 57 additions & 0 deletions resources/views/publics/checkout.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@extends('layouts.app_public')

@section('content')
<div class="checkout-page">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="section-title">
<h2>{{__('public_pages.payment_type')}}</h2>
</div>
<div class="payment-types">
<div class="box-type" data-radio-val="econt">
<img src="{{ asset('img/cash_on_deliv.png') }}" alt="econt" class="img-responsive">
<span>{{__('public_pages.cash_on_delivery')}}</span>
</div>
<div class="radios">
<input type="radio" name="payment_type" value="cash_on_delivery">
</div>
</div>
<div class="section-title">
<h2>{{__('public_pages.delivery_address')}}</h2>
</div>
<div id="errors" class="alert alert-danger"></div>
<form method="POST" id="set-order">
<div class="row">
<div class="form-group col-sm-6">
<input class="form-control" name="first_name" value="" type="text" placeholder="{{__('public_pages.name')}}">
</div>
<div class="form-group col-sm-6">
<input class="form-control" name="last_name" value="" type="text" placeholder="{{__('public_pages.family')}}">
</div>
<div class="form-group col-sm-6">
<input class="form-control" name="email" value="" type="text" placeholder="{{__('public_pages.email_address')}}">
</div>
<div class="form-group col-sm-6">
<input class="form-control" name="phone" value="" type="text" placeholder="{{__('public_pages.phone')}}">
</div>
<div class="form-group col-sm-12">
<textarea name="address" placeholder="{{__('public_pages.address')}}" class="form-control" rows="3"></textarea>
</div>
<div class="form-group col-sm-6">
<input class="form-control" name="city" value="" type="text" placeholder="{{__('public_pages.city')}}">
</div>
<div class="form-group col-sm-6">
<input class="form-control" name="post_code" value="" type="text" placeholder="{{__('public_pages.post_code')}}">
</div>
<div class="form-group col-sm-12">
<textarea class="form-control" placeholder="{{__('public_pages.notes')}}" name="notes" rows="3"></textarea>
</div>
</div>
<a href="javascript:void(0);" onclick="completeOrder()" class="green-btn">{{__('public_pages.complete_order')}}</a>
</form>
</div>
</div>
</div>
</div>
@endsection
2 changes: 1 addition & 1 deletion resources/views/publics/contacts.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="contacts-page">
<div class="container">
<div class="row">
<div class="col-xs-12 products-title">
<div class="col-xs-12 section-title">
<h2>{{__('public_pages.contacts')}}</h2>
</div>
<div class="col-xs-12">
Expand Down
4 changes: 2 additions & 2 deletions resources/views/publics/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>
<div class="container">
<div class="row promo">
<div class="col-xs-12 products-title">
<div class="col-xs-12 section-title">
<h2>{{__('public_pages.promo_products')}}</h2>
</div>
@foreach ($promoProducts as $promoProduct)
Expand Down Expand Up @@ -69,7 +69,7 @@
@endforeach
</div>
<div class="row">
<div class="col-xs-12 products-title">
<div class="col-xs-12 section-title">
<h2>{{__('public_pages.most_selled')}}</h2>
</div>
@foreach ($mostSelledProducts as $mostSelledProduct)
Expand Down
2 changes: 1 addition & 1 deletion resources/views/publics/products.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="products-page">
<div class="container">
<div class="row">
<div class="col-xs-12 products-title">
<div class="col-xs-12 section-title">
<h2>{{__('public_pages.all_products')}}</h2>
</div>
@foreach ($products as $product)
Expand Down
5 changes: 5 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
Route::get('{locale}/products', 'Publics\\ProductsController@index')
->where('locale', implode('|', Config::get('app.locales')));

// checkout please
Route::get('checkout', 'Publics\\CheckoutController@index');
Route::get('{locale}/checkout', 'Publics\\CheckoutController@index')
->where('locale', implode('|', Config::get('app.locales')));

// open contacts
Route::get('contacts', 'Publics\\ContactsController@index');
Route::get('{locale}/contacts', 'Publics\\ContactsController@index')
Expand Down

0 comments on commit c251209

Please sign in to comment.