Module: Workarea::Storefront::CurrentCheckout
- Extended by:
- ActiveSupport::Concern
- Included in:
- ApplicationController
- Defined in:
- app/controllers/workarea/storefront/current_checkout.rb
Instance Method Summary collapse
-
#clear_current_order ⇒ Object
Removes the current order from the session.
-
#completed_order ⇒ Order
Get the last completed order based on the cookie.
-
#completed_order=(order) ⇒ Object
Sets a temporary cookie of the order ID to represent an order that was just completed in checkout.
-
#current_checkout ⇒ Checkout
Get the current checkout for the session.
-
#current_order ⇒ Order
The current order for the current session.
-
#current_order=(order) ⇒ Object
Sets the current order on the session.
-
#current_shipping ⇒ Shipping
Get the current shipping for the session.
-
#current_shippings ⇒ Array<Shipping>
Get all shippings for the session.
Instance Method Details
#clear_current_order ⇒ Object
Removes the current order from the session.
31 32 33 34 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 31 def clear_current_order session.delete(:order_id) @current_order = nil end |
#completed_order ⇒ Order
Get the last completed order based on the cookie. Used to show the order confirmation page.
54 55 56 57 58 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 54 def completed_order if .signed[:completed_order].present? @completed_order ||= Order.find(.signed[:completed_order]) end end |
#completed_order=(order) ⇒ Object
Sets a temporary cookie of the order ID to represent an order that was just completed in checkout. Used to show the order confirmation page.
40 41 42 43 44 45 46 47 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 40 def completed_order=(order) .signed[:completed_order] = { value: order.id, expires: Workarea.config.completed_order_timeout.from_now } @completed_order = order end |
#current_checkout ⇒ Checkout
Get the current checkout for the session.
64 65 66 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 64 def current_checkout @current_checkout ||= Workarea::Checkout.new(current_order, current_user) end |
#current_order ⇒ Order
The current order for the current session.
15 16 17 18 19 20 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 15 def current_order @current_order ||= Order.find_current( id: session[:order_id], user_id: .signed[:user_id] ) end |
#current_order=(order) ⇒ Object
Sets the current order on the session.
24 25 26 27 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 24 def current_order=(order) @current_order = order session[:order_id] = order.try(:id) end |
#current_shipping ⇒ Shipping
Get the current shipping for the session.
72 73 74 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 72 def current_shipping current_checkout.shipping end |
#current_shippings ⇒ Array<Shipping>
Get all shippings for the session.
80 81 82 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 80 def current_shippings current_checkout.shippings end |