app/controllers/plugins/ecommerce/front/orders_controller.rb in camaleon_ecommerce-1.2 vs app/controllers/plugins/ecommerce/front/orders_controller.rb in camaleon_ecommerce-1.2.1
- old
+ new
@@ -1,18 +1,17 @@
class Plugins::Ecommerce::Front::OrdersController < Plugins::Ecommerce::FrontController
before_action :commerce_authenticate
before_action :set_bread
def index
- @orders = current_site.orders.set_user(current_user).decorate
+ @orders = current_site.orders.set_user(cama_current_user).decorate
render "index"
end
def show
- @order = current_site.orders.find_by_slug(params[:order]).decorate
+ @order = current_site.orders.set_user(cama_current_user).find_by_slug(params[:order]).try(:decorate)
+ return redirect_to(url_for(action: :index), error: t('plugins.ecommerce.messages.order_not_found', default: "Order not found", order: params[:order])) unless @order.present?
@ecommerce_breadcrumb << [t('plugins.ecommerce.messages.detail_order', default: "Detail order: #%{order}", order: params[:order])]
end
-
-
private
def set_bread
@ecommerce_breadcrumb << [t('plugins.ecommerce.messages.my_orders', default: 'My Orders'), url_for(action: :index)]
end