Add doc to methods and classes [skip ci]

This commit is contained in:
Pau Perez
2017-07-19 11:18:20 +02:00
committed by Rob Harrington
parent 62c5ccf904
commit 3a9b71bd1f
3 changed files with 15 additions and 0 deletions

View File

@@ -60,6 +60,9 @@ class CheckoutController < Spree::CheckoutController
end
end
# Clears the cached order. Required for #current_order to return a new order
# to serve as cart. See https://github.com/spree/spree/blob/1-3-stable/core/lib/spree/core/controller_helpers/order.rb#L14
# for details.
def expire_current_order
session[:order_id] = nil
@current_order = nil

View File

@@ -7,6 +7,9 @@ Spree::PaypalController.class_eval do
redirect_to main_app.checkout_path
end
# Clears the cached order. Required for #current_order to return a new order
# to serve as cart. See https://github.com/spree/spree/blob/1-3-stable/core/lib/spree/core/controller_helpers/order.rb#L14
# for details.
def expire_current_order
session[:order_id] = nil
@current_order = nil

View File

@@ -1,10 +1,18 @@
# Builds a new order based on the one specified. This implements the "continue
# shopping" feature once an order is completed.
class ResetOrderService
# Constructor
#
# @param controller [#expire_current_order, #current_order]
# @param order [Spree::Order]
def initialize(controller, order)
@controller = controller
@distributor = order.distributor
@token = order.token
end
# Expires the order currently in use and builds a new one based on it
def call
controller.expire_current_order
build_new_order
@@ -14,6 +22,7 @@ class ResetOrderService
attr_reader :controller, :distributor, :token
# Builds an order setting the token and distributor of the one specified
def build_new_order
new_order = controller.current_order(true)
new_order.set_distributor!(distributor)