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.

Working settings off store based JSON settings.

Matthew Kennedy38cbaa4c4bbf
diff --git a/core/app/models/spree/digital_link.rb b/core/app/models/spree/digital_link.rb
index f512e95eb5..61c12e41c9 100644
--- a/core/app/models/spree/digital_link.rb
+++ b/core/app/models/spree/digital_link.rb
@@ -8,18 +8,16 @@ module Spree
before_validation :set_defaults, on: :create
validates :digital, presence: true
- # Can this link stil be used? It is valid if it's less than 24 hours
- # old and was not accessed more than 3 times
def authorizable?
!(expired? || access_limit_exceeded?)
end
def expired?
- created_at <= Spree::DigitalConfiguration[:authorized_days].day.ago
+ created_at <= line_item.order.store.digital_asset_authorized_days.day.ago
end
def access_limit_exceeded?
- access_counter >= Spree::DigitalConfiguration[:authorized_clicks]
+ access_counter >= line_item.order.store.digital_asset_authorized_clicks
end
# This method should be called when a download is initiated.
diff --git a/core/app/models/spree/store.rb b/core/app/models/spree/store.rb
index 9e9658ddb6..a75e154bf3 100644
--- a/core/app/models/spree/store.rb
+++ b/core/app/models/spree/store.rb
@@ -1,6 +1,5 @@
module Spree
class Store < Spree::Base
- # Spree Store Settings
typed_store :settings do |s|
# Spree Digital Asset Configurations
s.integer :digital_asset_authorized_clicks, default: 3, null: false # number of times a customer can download a digital file.
diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rb
index cda262ab20..5c772d6154 100644
--- a/core/lib/spree/permitted_attributes.rb
+++ b/core/lib/spree/permitted_attributes.rb
@@ -93,7 +93,8 @@ module Spree
@@property_attributes = [:name, :presentation]
- @@return_authorization_attributes = [:amount, :memo, :stock_location_id, :inventory_units_attributes, :return_authorization_reason_id]
+ @@return_authorization_attributes = [:amount, :memo, :stock_location_id, :inventory_units_attributes,
+ :return_authorization_reason_id]
@@shipment_attributes = [
:order, :special_instructions, :stock_location_id, :id,
@@ -124,7 +125,9 @@ module Spree
:customer_support_email, :facebook, :twitter, :instagram,
:description, :address, :contact_phone, :supported_locales,
:default_locale, :default_country_id, :supported_currencies,
- :new_order_notifications_email, :mailer_logo, :favicon_image, :checkout_zone_id, :seo_robots]
+ :new_order_notifications_email, :mailer_logo, :favicon_image,
+ :checkout_zone_id, :seo_robots, :digital_asset_authorized_clicks,
+ :digital_asset_authorized_days]
@@store_credit_attributes = %i[amount currency category_id memo]