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 handy scopes to Price model - `with_currency`, `non_zero, and `discounted`

Damian Legawiec396d219b47ba
diff --git a/core/app/models/spree/price.rb b/core/app/models/spree/price.rb
index aea81da737..9495372149 100644
--- a/core/app/models/spree/price.rb
+++ b/core/app/models/spree/price.rb
@@ -23,6 +23,10 @@ module Spree
less_than_or_equal_to: MAXIMUM_AMOUNT
}
+ scope :with_currency, ->(currency) { where(currency: currency) }
+ scope :non_zero, -> { where.not(amount: [nil, 0]) }
+ scope :discounted, -> { where('compare_at_amount > amount') }
+
extend DisplayMoney
money_methods :amount, :price, :compare_at_amount
alias display_compare_at_price display_compare_at_amount