Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes #10

Open
wants to merge 5 commits into
base: 2-0-beta
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed a bug introduced by the previous commit that caused the reorder…
…ing process to halt when a checkout step is missing.

The user_id of the reorder is now properly saved.
christophertfoo committed Jan 4, 2014
commit 5a250ad88a6aea7f1d37f3dd94fc22c5cc1c0a5c
16 changes: 12 additions & 4 deletions app/models/spree/subscription.rb
Original file line number Diff line number Diff line change
@@ -55,21 +55,23 @@ def create_reorder
subscription_id: self.id,
email: self.user.email
)
self.new_order.user_id = self.user_id
self.new_order.user_id = self.user_id

# DD: make it work with spree_multi_domain
if self.new_order.respond_to?(:store_id)
self.new_order.store_id = self.line_item.order.store_id
end

# Persist changes to the new_order. They are not set properly otherwise
self.new_order.save!

variant = Spree::Variant.find(self.line_item.variant_id)

line_item = self.new_order.contents.add( variant, self.line_item.quantity )
line_item.price = self.line_item.price
line_item.save!

self.new_order.next # -> address
self.new_order.next # -> delivery
self.new_order.next && self.new_order.next # -> address -> delivery
end

def select_shipping
@@ -89,11 +91,17 @@ def add_payment
payment.save!

self.new_order.next # -> payment
else
true
end
end

def confirm_reorder
self.new_order.next if self.new_order.has_step? 'confirm' # -> confirm
if self.new_order.has_step? 'confirm'
self.new_order.next # -> confirm
else
true
end
end

def complete_reorder
2 changes: 1 addition & 1 deletion spree_subscribe.gemspec
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'spree_subscribe'
s.version = '0.1.3.beta'
s.version = '0.1.4.beta'
s.summary = ''
s.description = ''
s.required_ruby_version = '>= 1.9.3'