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.

Added `ShippingMethod` `display_on` based scopes (#12093)

Damian Legawiecb207b0c6efce
diff --git a/core/app/models/spree/shipping_method.rb b/core/app/models/spree/shipping_method.rb
index 6ea496adf7..5a77baa7c0 100644
--- a/core/app/models/spree/shipping_method.rb
+++ b/core/app/models/spree/shipping_method.rb
@@ -33,6 +33,10 @@ module Spree
validate :at_least_one_shipping_category
+ scope :available, -> { where(display_on: [:front_end, :back_end, :both]) }
+ scope :available_on_front_end, -> { where(display_on: [:front_end, :both]) }
+ scope :available_on_back_end, -> { where(display_on: [:back_end, :both]) }
+
def include?(address)
return false unless address