forked from dexion/ShoppingCart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kirill Oleynik
committed
Aug 26, 2016
1 parent
282e0dd
commit 043c4b3
Showing
5 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module ShoppingCart | ||
class PlaceOrder < Rectify::Command | ||
def initialize(order, params) | ||
@order = order | ||
@params = params | ||
end | ||
|
||
def call | ||
place_order if order_valid? | ||
end | ||
|
||
private | ||
|
||
def order_valid? | ||
nested_models.all? { |model| @order.public_send(model).valid? } | ||
end | ||
|
||
def nested_models | ||
[:shipping, :billing, :credit_card, :delivery] | ||
end | ||
|
||
def place_order | ||
@order.completed | ||
@order.save | ||
end | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
app/views/shopping_cart/checkout/_completed_buttons.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.raw | ||
.col-md-12.text-left | ||
= f.hidden_field :id | ||
= back_to_shop_link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= render partial: 'ckeckout_header', locals: {step: @step} | ||
%main.raw | ||
= render partial: 'errors_messages', locals: {order: @order} | ||
= form_for @order, url: wizard_path do |f| | ||
= render partial: 'confirmation_details', locals: {order: @order, step: @step} | ||
= render partial: 'confirmation_order', locals: {order: @order} | ||
= render partial: template, locals: {f: f, order: @order} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
= render partial: 'final_step', locals: {template: 'completed_buttons'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
= render partial: 'ckeckout_header', locals: {step: @step} | ||
%main.raw | ||
= render partial: 'errors_messages', locals: {order: @order} | ||
= form_for @order, url: wizard_path do |f| | ||
= render partial: 'confirmation_details', locals: {order: @order, step: @step} | ||
= render partial: 'confirmation_order', locals: {order: @order} | ||
= render partial: 'confirmation_buttons', locals: {f: f, order: @order} | ||
= render partial: 'final_step', locals: {template: 'confirmation_buttons'} |