Skip to content

Commit

Permalink
New app configuration to control billing address being required
Browse files Browse the repository at this point in the history
Spree::Config.billing_address_required now can be used to force billing address
to be required and also gives the ability to custom payment methods to override
this method and specify what they need
  • Loading branch information
softr8 committed Jun 9, 2020
1 parent 7fb8e49 commit 05ef512
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/app/models/spree/payment_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ def source_required?
true
end

def billing_address_required?
Spree::Config.billing_address_required
end

# Custom gateways can redefine this method to return reusable sources for an order.
# See {Spree::PaymentMethod::CreditCard#reusable_sources} as an example
def reusable_sources(_order)
Expand Down
7 changes: 7 additions & 0 deletions core/lib/spree/app_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ class AppConfiguration < Preferences::Configuration
# @return [Boolean] Whether use of an address in checkout marks it as user's default
preference :automatic_default_address, :boolean, default: true

# @!attribute [rw] billing_address_required
# Controls whether billing address is required or not from payment methods
# by default, can be overridden at payment method.
# (default: +false+)
# @return [Boolean]
preference :billing_address_required, :boolean, default: false

# @!attribute [rw] binary_inventory_cache
# Only invalidate product caches when they change from in stock to out of
# stock. By default, caches are invalidated on any change of inventory
Expand Down

0 comments on commit 05ef512

Please sign in to comment.