Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add channel column to admin checkouts and orders tables (#14346)

Damian Legawiec94122aa00e1c
diff --git a/spree/admin/app/controllers/spree/admin/checkouts_controller.rb b/spree/admin/app/controllers/spree/admin/checkouts_controller.rb
index 9946b535fa..d3c1f91df7 100644
--- a/spree/admin/app/controllers/spree/admin/checkouts_controller.rb
+++ b/spree/admin/app/controllers/spree/admin/checkouts_controller.rb
@@ -25,7 +25,7 @@ module Spree
end
def collection_includes
- { user: [] }
+ { user: [], channel: [] }
end
def edit_object_url(object, options = {})
diff --git a/spree/admin/app/controllers/spree/admin/orders_controller.rb b/spree/admin/app/controllers/spree/admin/orders_controller.rb
index 84a2562239..59b4764db6 100644
--- a/spree/admin/app/controllers/spree/admin/orders_controller.rb
+++ b/spree/admin/app/controllers/spree/admin/orders_controller.rb
@@ -97,7 +97,7 @@ module Spree
end
def collection_includes
- { user: [], payments: [], refunds: [], shipments: :stock_location }
+ { user: [], channel: [], payments: [], refunds: [], shipments: :stock_location }
end
def order_params
diff --git a/spree/admin/config/initializers/spree_admin_tables.rb b/spree/admin/config/initializers/spree_admin_tables.rb
index 909e7402aa..a6a258294c 100644
--- a/spree/admin/config/initializers/spree_admin_tables.rb
+++ b/spree/admin/config/initializers/spree_admin_tables.rb
@@ -405,6 +405,19 @@ Rails.application.config.after_initialize do
partial: 'spree/admin/orders/customer_summary',
partial_locals: ->(record) { { order: record } }
+ Spree.admin.tables.checkouts.add :channel,
+ label: :channel,
+ type: :association,
+ filter_type: :select,
+ sortable: true,
+ filterable: true,
+ default: true,
+ position: 35,
+ ransack_attribute: 'channel_id',
+ operators: %i[eq not_eq in not_in],
+ value_options: -> { Spree::Current.store&.channels&.order(:name)&.pluck(:name, :id)&.map { |name, id| { value: id, label: name } } || [] },
+ method: ->(order) { order.channel&.name }
+
Spree.admin.tables.checkouts.add :state,
label: :state,
type: :status,
diff --git a/spree/admin/config/locales/en.yml b/spree/admin/config/locales/en.yml
index 961450259d..466dc56bce 100644
--- a/spree/admin/config/locales/en.yml
+++ b/spree/admin/config/locales/en.yml
@@ -937,7 +937,7 @@ en:
order_email_resent_error: Order confirmation mail can only be sent for completed orders
order_line_items: Order Line Items
overview: Overview
- package_from: package from
+ package_from: Package from
page_not_found: Sorry! Page you are looking can’t be found.
page_not_found_message: This page just doesn't exist.
paste: Paste