Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
venshop
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huanvl
venshop
Commits
6a645571
Commit
6a645571
authored
Oct 24, 2013
by
hades
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkout and confirm page
parent
7a9b2700
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
10 deletions
+109
-10
venshop_app/app/assets/stylesheets/custom.css.scss
+9
-2
venshop_app/app/controllers/cards_controller.rb
+46
-0
venshop_app/app/views/cards/checkout.html.erb
+17
-6
venshop_app/app/views/cards/confirm_checkout.html.erb
+36
-2
venshop_app/config/routes.rb
+1
-0
No files found.
venshop_app/app/assets/stylesheets/custom.css.scss
View file @
6a645571
...
@@ -452,6 +452,12 @@ footer {
...
@@ -452,6 +452,12 @@ footer {
font-weight
:
bold
;
font-weight
:
bold
;
}
}
}
}
thead
{
font-weight
:
bold
;
.body-box
{
form
{
margin
:
10px
0
;
}
thead
{
font-weight
:
bold
;
}
}
}
\ No newline at end of file
venshop_app/app/controllers/cards_controller.rb
View file @
6a645571
...
@@ -67,9 +67,55 @@ class CardsController < ApplicationController
...
@@ -67,9 +67,55 @@ class CardsController < ApplicationController
if
@card_infos
.
empty?
if
@card_infos
.
empty?
redirect_to
cards_path
redirect_to
cards_path
end
end
if
request
.
post?
@errors
=
Array
.
new
customer_info
=
Hash
.
new
if
params
[
:full_name
].
empty?
@errors
.
push
(
"Full name is required"
)
end
if
params
[
:email
].
empty?
@errors
.
push
(
"Email is required"
)
else
if
params
[
:email
]
!~
/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
@errors
.
push
(
"Invalid email address"
)
end
end
if
params
[
:phone
].
empty?
@errors
.
push
(
"Phone is required"
)
end
if
params
[
:address
].
empty?
@errors
.
push
(
"Address is required"
)
end
if
@errors
.
count
==
0
customer_info
[
:full_name
]
=
params
[
:full_name
]
customer_info
[
:email
]
=
params
[
:email
]
customer_info
[
:phone
]
=
params
[
:phone
]
customer_info
[
:address
]
=
params
[
:address
]
customer_info
[
:note
]
=
params
[
:note
]
@card_infos
=
{
card_items:
@card_infos
[
:card_items
],
customer_info:
customer_info
}
session
[
:SHOPPING_CARD_SESSION_NAME
]
=
@card_infos
redirect_to
url_for
(
action:
'confirm_checkout'
)
end
else
customer_info
=
@card_infos
[
:customer_info
]
params
[
:full_name
]
=
customer_info
[
:full_name
]
params
[
:email
]
=
customer_info
[
:email
]
params
[
:phone
]
=
customer_info
[
:phone
]
params
[
:address
]
=
customer_info
[
:address
]
params
[
:note
]
=
customer_info
[
:note
]
end
end
end
def
confirm_checkout
def
confirm_checkout
add_breadcrumb
"Checkout"
,
url_for
(
action:
'checkout'
)
add_breadcrumb
"Confirm"
,
url_for
(
action:
'confirm_checkout'
)
@card_infos
=
Hash
.
new
if
session
[
:SHOPPING_CARD_SESSION_NAME
]
!=
nil
@card_infos
=
session
[
:SHOPPING_CARD_SESSION_NAME
]
end
if
@card_infos
.
empty?
redirect_to
cards_path
end
end
end
def
thankyou
def
thankyou
...
...
venshop_app/app/views/cards/checkout.html.erb
View file @
6a645571
...
@@ -4,19 +4,30 @@
...
@@ -4,19 +4,30 @@
Check out
<span
class=
"sprite-2"
></span>
Check out
<span
class=
"sprite-2"
></span>
</h2>
</h2>
<%=
form_tag
do
%>
<%=
form_tag
do
%>
<%
if
@errors
!=
nil
%>
<div
class=
"alert alert-error"
>
The form contains
<%=
pluralize
(
@errors
.
count
,
"error"
)
%>
.
<ul>
<%
@errors
.
each
do
|
error
|
%>
<li>
<%=
error
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<%=
label_tag
(
:full_name
,
"Full name:"
)
%>
<%=
label_tag
(
:full_name
,
"Full name:"
)
%>
<%=
text_field_tag
:full_name
,
nil
,
class:
"form-control"
%>
<%=
text_field_tag
:full_name
,
params
[
:full_name
]
,
class:
"form-control"
%>
<%=
label_tag
(
:email
,
"Email:"
)
%>
<%=
label_tag
(
:email
,
"Email:"
)
%>
<%=
text_field_tag
:email
,
nil
,
class:
"form-control"
%>
<%=
text_field_tag
:email
,
params
[
:email
]
,
class:
"form-control"
%>
<%=
label_tag
(
:phone
,
"Phone:"
)
%>
<%=
label_tag
(
:phone
,
"Phone:"
)
%>
<%=
text_field_tag
:phone
,
nil
,
class:
"form-control"
%>
<%=
text_field_tag
:phone
,
params
[
:phone
]
,
class:
"form-control"
%>
<%=
label_tag
(
:address
,
"Address:"
)
%>
<%=
label_tag
(
:address
,
"Address:"
)
%>
<%=
text_field_tag
:address
,
nil
,
class:
"form-control"
%>
<%=
text_field_tag
:address
,
params
[
:address
]
,
class:
"form-control"
%>
<%=
label_tag
(
:note
,
"Note:"
)
%>
<%=
label_tag
(
:note
,
"Note:"
)
%>
<%=
text_area_tag
:note
,
nil
,
class:
"form-control"
,
rows:
10
,
cols:
25
%>
<%=
text_area_tag
:note
,
params
[
:note
]
,
class:
"form-control"
,
rows:
10
,
cols:
25
%>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
<div
class=
"text-center"
>
<div
class=
"text-center"
>
<%=
submit_tag
"Check out"
,
class:
'btn btn-primary btn-submit'
%>
<a
href=
"
<%=
cards_path
%>
"
class=
"btn btn-default"
>
Back
</a>
<%=
submit_tag
"Continue"
,
class:
'btn btn-primary btn-submit'
%>
</div>
</div>
<%
end
%>
<%
end
%>
</div>
</div>
venshop_app/app/views/cards/confirm_checkout.html.erb
View file @
6a645571
<h1>
Cards#confirm_checkout
</h1>
<%
provide
(
:title
,
"Confirmation"
)
%>
<p>
Find me in app/views/cards/confirm_checkout.html.erb
</p>
<div
class=
"body-box"
>
<h2
class=
"sprite-2"
>
Confirmation
<span
class=
"sprite-2"
></span>
</h2>
<p><br
/>
Please check your information:
</p>
<%
customer_info
=
@card_infos
[
:customer_info
]
%>
<table
class=
"table"
>
<tr>
<td><b>
Full name
</b>
:
</td>
<td>
<%=
customer_info
[
:full_name
]
%>
</td>
</tr>
<tr>
<td>
Email:
</td>
<td>
<%=
customer_info
[
:email
]
%>
</td>
</tr>
<tr>
<td>
Phone:
</td>
<td>
<%=
customer_info
[
:phone
]
%>
</td>
</tr>
<tr>
<td>
Address:
</td>
<td>
<%=
customer_info
[
:address
]
%>
</td>
</tr>
<tr>
<td>
Note:
</td>
<td>
<%=
customer_info
[
:note
]
%>
</td>
</tr>
</table>
<%=
render
partial:
'cards/item_list'
,
locals:
{
card_infos:
@card_infos
,
can_edit:
false
}
%>
<div
class=
"text-center"
>
The information above
<a
href=
"
<%=
url_for
(
action:
'checkout'
)
%>
"
class=
"btn btn-default"
>
Incorrect, click here
</a>
<%=
submit_tag
"Correct, click here"
,
class:
'btn btn-primary btn-submit'
%>
</div>
</div>
venshop_app/config/routes.rb
View file @
6a645571
...
@@ -4,6 +4,7 @@ VenshopApp::Application.routes.draw do
...
@@ -4,6 +4,7 @@ VenshopApp::Application.routes.draw do
get
"products/show"
get
"products/show"
get
"cards/index"
get
"cards/index"
get
"cards/checkout"
get
"cards/checkout"
post
"cards/checkout"
get
"cards/confirm_checkout"
get
"cards/confirm_checkout"
get
"cards/thankyou"
get
"cards/thankyou"
resources
:users
resources
:users
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment