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.
- #logout ⇒ Object
Instance Method Details
#clear_current_order ⇒ Object
Removes the current order from the session.
37 38 39 40 41 42 43 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 37 def clear_current_order # TODO session[:order_id] is deprecated in v3.5, remove in v3.6 session.delete(:order_id) .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.
59 60 61 62 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 59 def completed_order return @completed_order if defined?(@completed_order) @completed_order = Order.find(session[:completed_order_id]) rescue nil 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.
49 50 51 52 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 49 def completed_order=(order) session[:completed_order_id] = order&.id @completed_order = order end |
#current_checkout ⇒ Checkout
Get the current checkout for the session.
68 69 70 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 68 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 21 22 23 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 15 def current_order @current_order ||= Order.find_current( # TODO session[:order_id] is deprecated in v3.5, remove in v3.6 # TODO cookies.signed[:user_id] is deprecated in v3.5, remove in v3.6 id: .signed[:order_id].presence || session[:order_id], user_id: session[:user_id].presence || .signed[:user_id] ) end |
#current_order=(order) ⇒ Object
Sets the current order on the session.
27 28 29 30 31 32 33 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 27 def current_order=(order) @current_order = order if order.blank? || order.persisted? .permanent.signed[:order_id] = order&.id end end |
#current_shipping ⇒ Shipping
Get the current shipping for the session.
76 77 78 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 76 def current_shipping current_checkout.shipping end |
#current_shippings ⇒ Array<Shipping>
Get all shippings for the session.
84 85 86 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 84 def current_shippings current_checkout.shippings end |
#logout ⇒ Object
88 89 90 91 |
# File 'app/controllers/workarea/storefront/current_checkout.rb', line 88 def logout super clear_current_order end |