diff --git a/app/models/spree_cm_commissioner/line_item_decorator.rb b/app/models/spree_cm_commissioner/line_item_decorator.rb index f22a6879b..4ce3971a4 100644 --- a/app/models/spree_cm_commissioner/line_item_decorator.rb +++ b/app/models/spree_cm_commissioner/line_item_decorator.rb @@ -19,7 +19,7 @@ def self.prepended(base) # rubocop:disable Metrics/MethodLength base.validate :ensure_not_exceed_max_quantity_per_order, if: -> { variant&.max_quantity_per_order.present? } base.whitelisted_ransackable_associations |= %w[guests] - base.whitelisted_ransackable_attributes |= %w[number to_date from_date] + base.whitelisted_ransackable_attributes |= %w[number to_date from_date vendor_id] base.delegate :delivery_required?, :permanent_stock?, :high_demand, to: :variant diff --git a/app/models/spree_cm_commissioner/order_decorator.rb b/app/models/spree_cm_commissioner/order_decorator.rb index 1962b4e26..a75fde52c 100644 --- a/app/models/spree_cm_commissioner/order_decorator.rb +++ b/app/models/spree_cm_commissioner/order_decorator.rb @@ -17,6 +17,10 @@ def self.prepended(base) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize ) } + base.scope :filter_by_vendor, lambda { |vendor| + joins(:line_items).where(spree_line_items: { vendor_id: vendor }).distinct + } + base.before_create :link_by_phone_number base.before_create :associate_customer diff --git a/app/overrides/spree/admin/orders/_search/vendor_search_field.html.erb.deface b/app/overrides/spree/admin/orders/_search/vendor_search_field.html.erb.deface new file mode 100644 index 000000000..06f34a0de --- /dev/null +++ b/app/overrides/spree/admin/orders/_search/vendor_search_field.html.erb.deface @@ -0,0 +1,8 @@ + + +