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

One-time purchase not added to cart if product was already in cart as subscription #47

Open
femmestem opened this issue Dec 29, 2016 · 3 comments

Comments

@femmestem
Copy link

Setup: Ruby 2.1.5, Rails 4.2, Spree 3.1

If a product is already in cart as a subscription, and then a user adds the same product to cart as a one-time purchase, the cart line item remains a subscription. Recommend one-time purchase and subscription purchase should be added to cart as separate line items.

@nishant-cyro
Copy link

@femmestem - One solution seems to me. We shouldn't show subscription option for the product if the product is already in the cart. There should be only one option 'Add to cart' and the product will get added to the cart whether it is subscribed or not.

What say?

@femmestem
Copy link
Author

femmestem commented Jan 12, 2017

Your proposed solution will make a confusing user experience for customers because major online retail stores do not work that way. A user will have no way of changing a line item in the cart from one-time purchase to subscription, or subscription to one-time purchase. A customer would have to remove item from cart and then go back to the product page to get the options to show up again, and that requires them to think too much. If they become confused or frustrated they will probably leave the store.

Right now, Spree checks to see if a line_item for order (cart) has a variant_id matching the variant that the user submitted from 'Add to Cart' form, and updates the quantity of that line item. Instead, we should check to see if the user chose a subscription or one-time purchase variant, then check if the line_item variant is subscription. If the item in cart is not a subscription variant then we create a new line item in the cart. User should be able to update the quantity for one-time purchase line_items and subscription line_items independently of each other.

I'm exploring possible solutions using the below hook provided in spree/core/app/models/spree/order.rb

    # This method enables extensions to participate in the
    # "Are these line items equal" decision.
    #
    # When adding to cart, an extension would send something like:
    # params[:product_customizations]={...}
    #
    # and would provide:
    #
    # def product_customizations_match
    def line_item_options_match(line_item, options)
      return true unless options

      self.line_item_comparison_hooks.all? { |hook|
        self.send(hook, line_item, options)
      }
    end

@nishant-cyro
Copy link

@femmestem - That makes sense to me. Will think about it more and will get back on this.

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