Class: Workarea::Api::Storefront::CartsController
Instance Method Summary
collapse
#current_checkout, #current_order
#assert_current_metrics_id, #cache_page, #skip_session
#authentication?, #current_user, find_user
Instance Method Details
34
35
36
37
38
39
40
41
42
43
|
# File 'app/controllers/workarea/api/storefront/carts_controller.rb', line 34
def add_promo_code
if Pricing.valid_promo_code?(params[:promo_code], current_checkout.email)
current_order.add_promo_code(params[:promo_code])
else
flash[:error] = t('workarea.storefront.flash_messages.promo_code_error')
end
Pricing.perform(current_order, current_checkout.shipping)
render :show
end
|
#create ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'app/controllers/workarea/api/storefront/carts_controller.rb', line 17
def create
order = Order.new
order.user_id = current_user.id if authentication?
order.save!
@order = Workarea::Storefront::OrderViewModel.new(
order,
view_model_options
)
render :show
end
|
#index ⇒ Object
11
12
13
14
15
|
# File 'app/controllers/workarea/api/storefront/carts_controller.rb', line 11
def index
@orders = Workarea::Storefront::OrderViewModel.wrap(
Order.carts.where(user_id: current_user.id).to_a
)
end
|
#show ⇒ Object
30
31
32
|
# File 'app/controllers/workarea/api/storefront/carts_controller.rb', line 30
def show
Pricing.perform(current_order, current_checkout.shipping)
end
|