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

Disabling of before_payment state eliminates payment_sources #140

Closed
jkelleyj opened this issue Aug 24, 2016 · 3 comments
Closed

Disabling of before_payment state eliminates payment_sources #140

jkelleyj opened this issue Aug 24, 2016 · 3 comments

Comments

@jkelleyj
Copy link

This override of before_payment in the checkout controller breaks saved payment sources:

https://github.com/spree-contrib/spree-product-assembly/blob/master/app/controllers/spree/checkout_controller_decorator.rb#L6

In spree/frontend, the before_payment method does two things:

  1. handles removal of products for packaging
  2. loads @payment_sources for the current spree user

I'd propose that we find an alternative approach to allow the product assembly to opt out of being processed by the stock differentiator.

@bjsion
Copy link

bjsion commented Dec 1, 2016

I have the same issue as the OP. What I did for now is to override the remove method of the OrderContents class to ignore a product assemblies using the variant.product.assembly?, like so:

Spree::OrderContents.class_eval do
  def remove(variant, quantity = 1, options = {})
    if !variant.product.assembly?
      line_item = remove_from_line_item(variant, quantity, options)
      after_add_or_remove(line_item, options)
    end
  end
end

Then I re-enabled the before_payment on the CheckoutController

@jkelleyj
Copy link
Author

Noticed this is a duplicate of #98 thanks @bjsion for the approach. This seems better than "reoverriding" the checkout controller decorator.

@bjsion
Copy link

bjsion commented Jan 4, 2017

No worries. Hope it helps and can make it back into the mainline. I am too busy at the moment make a patch and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants