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.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Add scope for resulting promotions
Rafal Cymerys1a176cf03818
diff --git a/core/app/models/spree/promotion.rb b/core/app/models/spree/promotion.rbindex 841352e76a..f93b834bc1 100644--- a/core/app/models/spree/promotion.rb+++ b/core/app/models/spree/promotion.rb@@ -30,6 +30,7 @@ module Spreehas_many :stores, class_name: 'Spree::Store', through: :store_promotionshas_many :promotion_batches, foreign_key: 'template_promotion_id'+ has_many :promotions_from_template, through: :promotion_batches, class_name: 'Spree::Promotion', source: :promotionsaccepts_nested_attributes_for :promotion_actions, :promotion_rules@@ -51,8 +52,10 @@ module SpreeSQL}scope :templates, -> { where(template: true) }+ scope :for_template_promotion_id, ->(id) { joins(:promotion_batch).where(promotion_batch: { template_promotion_id: id }) }- self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id', 'code']+ self.whitelisted_ransackable_attributes = ['path', 'promotion_category_id', 'promotion_batch_id', 'code']+ self.whitelisted_ransackable_scopes = ['for_template_promotion_id']def self.with_coupon_code(coupon_code)where("lower(#{table_name}.code) = ?", coupon_code.strip.downcase).