diff --git a/app/models/solidus_friendly_promotions/actions/create_discounted_item.rb b/app/models/solidus_friendly_promotions/actions/create_discounted_item.rb index c9d8cd81..1714dcb4 100644 --- a/app/models/solidus_friendly_promotions/actions/create_discounted_item.rb +++ b/app/models/solidus_friendly_promotions/actions/create_discounted_item.rb @@ -5,6 +5,7 @@ module Actions class CreateDiscountedItem < PromotionAction include Automation preference :variant_id, :integer + preference :quantity, :integer, default: 1 def perform(order) line_item = find_item(order) || create_item(order) @@ -23,7 +24,7 @@ def find_item(order) end def create_item(order) - order.line_items.create!(quantity: 1, variant: variant, managed_by_order_action: self) + order.line_items.create!(quantity: preferred_quantity, variant: variant, managed_by_order_action: self) end def variant diff --git a/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_create_discounted_item.html.erb b/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_create_discounted_item.html.erb index 9f759fdb..87da02ec 100644 --- a/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_create_discounted_item.html.erb +++ b/app/views/solidus_friendly_promotions/admin/promotion_actions/actions/_create_discounted_item.html.erb @@ -2,6 +2,8 @@
<%= form.label :preferred_variant_id %> <%= form.text_field :preferred_variant_id, class: "variant_autocomplete fullwidth" %> + <%= form.label :preferred_quantity %> + <%= form.number_field :preferred_quantity, class: "fullwidth" %>
<% end %>