This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Generate completed orders on a fresh Spree install. e.g. rake make_orders[10]" | |
task :make_orders, [:number] => :environment do |t, args| | |
address_attributes = { | |
firstname: "Spree", | |
lastname: "Commerce", | |
address1: "4600 East West Highway, Suite 800", | |
city: "Bethesda", | |
country_id: Spree::Country.find_by(iso: "US").id, | |
state_id: Spree::State.find_by(abbr: "MD").id, | |
zipcode: "20814", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
initializer 'spree.register.calculators' do |app| | |
app.config.spree.calculators.shipping_methods << Spree::Calculator::Shipping::MyCalc | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::Promotion::Rules::User.class_eval do | |
def eligible?(order, options = {}) | |
user = order.user | |
promotion_count = Spree::Adjustment.promotion.where(source_id: Spree::Order.select(:id).where(user_id: user.id).collect(&:id) ).count | |
users.include?(user) && promotion_count == 0 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if rate.respond_to(:pickup_date) %> | |
<%= ship_form.text_field :pickup_date %> | |
<% end %> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- insert_before "[data-hook='taxon_products']" --> | |
<%=render_snippet('sample')%> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def compute(computable) | |
# Spree::LineItem -> :compute_line_item | |
computable_name = computable.class.name.demodulize.underscore | |
method = "compute_#{computable_name}".to_sym | |
calculator_class = self.class | |
begin | |
self.send(method, computable) | |
rescue NoMethodError | |
raise NotImplementedError, "Please implement '#{method}(#{computable_name})' in your calculator: #{calculator_class.name}" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::PrintInvoice.config do |config| | |
config.print_invoice_logo_path = "store/logo.png" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spree::CheckoutController.class_eval do | |
before_filter :check_current_user | |
protected | |
def check_current_user | |
return if spree_current_user or current_order.email | |
store_location | |
redirect_to spree.login_path | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let(:package) do | |
mock_model( | |
Stock::Package.extend(ActiveModel::Naming), | |
order: mock_model(Order), | |
contents: [ | |
Stock::Package::ContentItem.new(line_item1, variant1, 2), | |
Stock::Package::ContentItem.new(line_item2, variant2, 1) | |
] | |
) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'spree', github: 'spree/spree', branch: '2-1-stable' | |
bundle update spree | |
bundle exec rake railties:install:migrations | |
bundle exec rake db:migrate |