summaryrefslogtreecommitdiff
path: root/lib/solidus_subscriptions
diff options
context:
space:
mode:
authorAlessandro Desantis <desa.alessandro@gmail.com>2021-01-22 13:59:59 +0100
committerAlessandro Desantis <desa.alessandro@gmail.com>2021-01-30 15:23:41 +0100
commit4717d24c0e7203210efe8c23b55467c3e728cdc5 (patch)
treeb7a57b183641d64d05e5e70e281fd78cb5e37ebd /lib/solidus_subscriptions
parentce4edc06e6079d8c098f1d0754e3c8e31b355e2d (diff)
Remove `dummy_order` and `dummy_line_item` helpers
These helpers are dangerous: they provide a false sense of assurance by making you think that the order and the line item they return can be used to infer the correct total value of future subscription orders. In reality, order calculation in Solidus is an extremely complex process that may take a ton of different parameters into account, and each store is better off calculating the subscription total with their custom logic rather than this extension trying to provide a solution that works for everyone. In the future, we may provide a way to compute a subscription's total, but for the time being it's better to remove the helpers altogether.
Diffstat (limited to 'lib/solidus_subscriptions')
-rw-r--r--lib/solidus_subscriptions/line_item_builder.rb36
1 files changed, 0 insertions, 36 deletions
diff --git a/lib/solidus_subscriptions/line_item_builder.rb b/lib/solidus_subscriptions/line_item_builder.rb
deleted file mode 100644
index c9aedb9..0000000
--- a/lib/solidus_subscriptions/line_item_builder.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-# This class is responsible for taking SubscriptionLineItems and building
-# them into Spree::LineItems which can be added to an order
-module SolidusSubscriptions
- class LineItemBuilder
- attr_reader :subscription_line_items
-
- # Get a new instance of a LineItemBuilder
- #
- # @param subscription_line_items[Array<SolidusSubscriptions::LineItem>] The
- # subscription line item to be converted into a Spree::LineItem
- #
- # @return [SolidusSubscriptions::LineItemBuilder]
- def initialize(subscription_line_items)
- @subscription_line_items = subscription_line_items
- end
-
- # Get a new (unpersisted) Spree::LineItem which matches the details of
- # :subscription_line_item
- #
- # @return [Array<Spree::LineItem>]
- def spree_line_items
- line_items = subscription_line_items.map do |subscription_line_item|
- variant = subscription_line_item.subscribable
-
- next unless variant.can_supply?(subscription_line_item.quantity)
-
- ::Spree::LineItem.new(variant: variant, quantity: subscription_line_item.quantity)
- end
-
- # Either all line items for an installment are fulfilled or none are
- line_items.all? ? line_items : []
- end
- end
-end