Rails : Spree : Zipcode, phonenumber required false

If you need the shipping address to be set any how, and want to skip the validations as set  in the spree’s address model, you can do it easily

module Spree
  class Address < Spree::Base
    require 'twitter_cldr'

    belongs_to :country, class_name: "Spree::Country"
    belongs_to :state, class_name: "Spree::State"

    has_many :shipments, inverse_of: :address

    validates :firstname, :lastname, :address1, :city, :country, presence: true
    validates :zipcode, presence: true, if: :require_zipcode?
    validates :phone, presence: true, if: :require_phone?

    validate :state_validate, :postal_code_validate

Solution:

# models/spree/address_decorator.rb
Spree::Address.class_eval do
  def require_phone?
    false
  end


  def require_zipcode?
    false
  end
end

 

And you are done