Commit 8366883a by Tran Hoang Viet

VietTH: Update template email checkout

parent b24e4e5f
class CartsController < ApplicationController
include CartsManagement
before_action :authenticate_user!
def index
@cart = Cart.new
end
......@@ -32,7 +34,7 @@ class CartsController < ApplicationController
end
def send_checkout_email(cart)
CartMailer.checkout(current_user.email, cart).deliver_later
CartMailer.send_checkout(current_user.email, cart).deliver_later
end
private
......
......@@ -4,6 +4,7 @@ class ProductsController < ApplicationController
before_action :set_product, only: [:show, :add_cart]
before_action :set_categories, only: [:new]
before_action :add_breadcrumb_home
before_action :authenticate_user!, only: [:new, :create]
def new
@product = Product.new
......@@ -25,7 +26,6 @@ class ProductsController < ApplicationController
end
def add_cart
# clear_cart
add_to_cart @product
redirect_to @product
end
......
class CartMailer < ActionMailer::Base
default from: 'demo@example.com'
def checkout(email, cart)
def send_checkout(email, cart)
@cart = cart
@cart_items = @cart.cart_items.includes(:product)
mail(
to: email,
subject: "Order number #{cart.id}"
)
mail(to: email, subject: "Order number #{cart.id}")
end
end
\ No newline at end of file
......@@ -14,8 +14,8 @@
%td.number.text-right
= index + 1
%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
= cart_item.product.price
%td.quantity
= cart_item.product.quantity
\ No newline at end of file
= cart_item.quantity
\ No newline at end of file
......@@ -46,12 +46,12 @@ ActiveRecord::Schema.define(version: 20150706090027) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
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_md_url", limit: 255
t.string "image_sm_url", limit: 255
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.string "image", limit: 255
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