Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VietTH-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
4
Merge Requests
4
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
Tran Hoang Viet
VietTH-VenShop
Commits
8366883a
Commit
8366883a
authored
Jul 06, 2015
by
Tran Hoang Viet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VietTH: Update template email checkout
parent
b24e4e5f
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
12 additions
and
12 deletions
+12
-12
app/controllers/carts_controller.rb
+3
-1
app/controllers/products_controller.rb
+1
-1
app/mailers/cart_mailer.rb
+3
-5
app/views/cart_mailer/checkout.html.haml
+3
-3
db/schema.rb
+2
-2
No files found.
app/controllers/carts_controller.rb
View file @
8366883a
class
CartsController
<
ApplicationController
class
CartsController
<
ApplicationController
include
CartsManagement
include
CartsManagement
before_action
:authenticate_user!
def
index
def
index
@cart
=
Cart
.
new
@cart
=
Cart
.
new
end
end
...
@@ -32,7 +34,7 @@ class CartsController < ApplicationController
...
@@ -32,7 +34,7 @@ class CartsController < ApplicationController
end
end
def
send_checkout_email
(
cart
)
def
send_checkout_email
(
cart
)
CartMailer
.
checkout
(
current_user
.
email
,
cart
).
deliver_later
CartMailer
.
send_
checkout
(
current_user
.
email
,
cart
).
deliver_later
end
end
private
private
...
...
app/controllers/products_controller.rb
View file @
8366883a
...
@@ -4,6 +4,7 @@ class ProductsController < ApplicationController
...
@@ -4,6 +4,7 @@ class ProductsController < ApplicationController
before_action
:set_product
,
only:
[
:show
,
:add_cart
]
before_action
:set_product
,
only:
[
:show
,
:add_cart
]
before_action
:set_categories
,
only:
[
:new
]
before_action
:set_categories
,
only:
[
:new
]
before_action
:add_breadcrumb_home
before_action
:add_breadcrumb_home
before_action
:authenticate_user!
,
only:
[
:new
,
:create
]
def
new
def
new
@product
=
Product
.
new
@product
=
Product
.
new
...
@@ -25,7 +26,6 @@ class ProductsController < ApplicationController
...
@@ -25,7 +26,6 @@ class ProductsController < ApplicationController
end
end
def
add_cart
def
add_cart
# clear_cart
add_to_cart
@product
add_to_cart
@product
redirect_to
@product
redirect_to
@product
end
end
...
...
app/mailers/cart_mailer.rb
View file @
8366883a
class
CartMailer
<
ActionMailer
::
Base
class
CartMailer
<
ActionMailer
::
Base
default
from:
'demo@example.com'
default
from:
'demo@example.com'
def
checkout
(
email
,
cart
)
def
send_
checkout
(
email
,
cart
)
@cart
=
cart
@cart
=
cart
@cart_items
=
@cart
.
cart_items
.
includes
(
:product
)
@cart_items
=
@cart
.
cart_items
.
includes
(
:product
)
mail
(
mail
(
to:
email
,
subject:
"Order number
#{
cart
.
id
}
"
)
to:
email
,
subject:
"Order number
#{
cart
.
id
}
"
)
end
end
end
end
\ No newline at end of file
app/views/cart_mailer/checkout.html.haml
View file @
8366883a
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
%td
.number.text-right
%td
.number.text-right
=
index
+
1
=
index
+
1
%td
.title
%td
.title
=
link_to
cart_item
.
product
.
title
,
product_
path
(
cart_item
.
product
)
=
link_to
cart_item
.
product
.
title
,
product_
url
(
cart_item
.
product
)
%td
.price
%td
.price
=
cart_item
.
product
.
price
=
cart_item
.
product
.
price
%td
.quantity
%td
.quantity
=
cart_item
.
product
.
quantity
=
cart_item
.
quantity
\ No newline at end of file
\ No newline at end of file
db/schema.rb
View file @
8366883a
...
@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150706090027) do
...
@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150706090027) do
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"created_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
datetime
"updated_at"
,
null:
false
t
.
string
"asin"
,
limit:
255
t
.
string
"asin"
,
limit:
255
t
.
string
"title"
,
limit:
255
,
null:
false
t
.
string
"title"
,
limit:
255
t
.
string
"image_lg_url"
,
limit:
255
t
.
string
"image_lg_url"
,
limit:
255
t
.
string
"image_md_url"
,
limit:
255
t
.
string
"image_md_url"
,
limit:
255
t
.
string
"image_sm_url"
,
limit:
255
t
.
string
"image_sm_url"
,
limit:
255
t
.
decimal
"price"
,
precision:
10
,
default:
0
t
.
decimal
"price"
,
precision:
10
,
default:
0
t
.
integer
"category_id"
,
limit:
4
,
null:
false
t
.
integer
"category_id"
,
limit:
4
t
.
integer
"product_type"
,
limit:
4
,
default:
0
t
.
integer
"product_type"
,
limit:
4
,
default:
0
t
.
string
"image"
,
limit:
255
t
.
string
"image"
,
limit:
255
end
end
...
...
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