Class: Spree::RecurringOrdersController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/spree/recurring_orders_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/spree/recurring_orders_controller.rb', line 4

def create
  original_order = Spree::Order.find(recurring_order_params[:original_order_id])
  if original_order.recurring_order.nil?
    @recurring_order = Spree::RecurringOrder.new
    @recurring_order.orders << original_order

    if @recurring_order.save
      redirect_to(spree.recurring_order_url(@recurring_order.id))
    else
      flash[:notice] = "Hmmm... There was a problem creating your regular order. Please get in touch at [email protected] and we are going to sort it out for you."
      redirect_to(order_url(original_order.number))
    end
  else
    flash[:notice] = "Hmmm... It seems like this order already has a regular order associated with it. Please get in touch at [email protected] if you have any doubts about it"
    redirect_to(order_url(original_order.number))
  end
end

#showObject



22
23
24
# File 'app/controllers/spree/recurring_orders_controller.rb', line 22

def show
  @recurring_order = Spree::RecurringOrder.find(params[:id])
end