Commit 8366883a by Tran Hoang Viet

VietTH: Update template email checkout

parent b24e4e5f
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
......
...@@ -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
......
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
...@@ -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
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment