EzDevInfo.com

spree

Spree is a complete open source e-commerce solution for Ruby on Rails. Ecommerce Storefront and Platform Solutions | Spree Commerce

Spree Commerce: any themes?

I searched whole morning, and find out that there aren't any themes either to purchase or download for Spree. It seems that I have to build custom store front myself.

Spree seems to be very limited in this aspect when compared to OpenCart and PrestaShops.

Am I right?


Source: (StackOverflow)

Spree as multilingual/bilingual site

Is spree suitable for multi/bilingual e-commerce site?

By default it supports internationalization (i18n - http://guides.spreecommerce.com/i18n.html). It gives an impression that spree is bilingual friendly but I'm missing one piece of the puzzle. Translation of product names, descriptions, attributes, categories.

What is your good practice when it comes to translation of products and categories (including metadata)?

gem version: Spree 1.1.1


Source: (StackOverflow)

Advertisements

Adding a step to the Spree checkout process

I'm trying to add an extra step to my Spree 1.2 store which will allow a customer to create a subscription. I've inserted the step, and rendered the correct view, but when the user clicks 'save and continue' the next step is rendered, but nothing is actually saved.

I understand that I need to add a state_callback, but I'm not sure how to do this and the Spree documentation is very lacking around this (presumably because it's quite new)

At present I've got the following in my extension:

models/spree/order_decorator.rb

Spree::Order.class_eval do
  belongs_to :subscription

  accepts_nested_attributes_for :subscription

  # This doesn't appear to be called
  Spree::Order.state_machine.after_transition :from => :subscription,
                                              :do => :valid_subs?

  checkout_flow do
    go_to_state :address
    go_to_state :subscription
    go_to_state :payment, :if => lambda { |order| order.payment_required? }
    go_to_state :confirm, :if => lambda { |order| order.confirmation_required? }
    go_to_state :complete
    remove_transition :from => :delivery, :to => :confirm
  end
end

Not entirely sure that accepts_nested_attributes is necessary, but my dev approach for this has been trial and error so far, so it ended up staying there.

In models/subscription.rb

class Subscription < ActiveRecord::Base

  attr_accessible :start_date, :frequency

  belongs_to :user 
  has_many :orders
  has_many :products

  validates :start_date, :frequency, :presence => true

  def schedule
    ...code that returns a list of dates rendered on FE...
  end

  private #----

  ... some methods used in schedule ...

  def valid_subs?
    binding.pry # never called
  end

  def after_subscription
    binding.pry # never called either...
  end
end

views/spree/checkout/_subscription.html.erb

<h1><%= t(:"subscription.title") %></h1>

<div class="columns alpha six" data-hook="subscription_calendar_fieldset_wrapper">
  <fieldset id="subscription_calendar" data-hook>
    <%= form.fields_for :subscription_picker do |subscription_picker| %>
      <legend><%= t(:"subscription.first_delivery") %></legend>
      <%= render :partial => 'subscription/picker' %>
    <% end %>
  </fieldset>
</div>

<div class="columns omega six" data-hook="subscription_dates_fieldset_wrapper">
  <fieldset id="subscription_dates" data-hook>
    <legend align="center"><%= t(:"subscription.next_deliveries") %></legend>
    <div class='dates'></div>
  </fieldset>
</div>

<div class="form-buttons" data-hook="buttons" style='clear:both;'>
  <%= submit_tag t(:save_and_continue), :class => 'continue button primary' %>
</div>

views/subscription/_picker.html.erb

<div class='row'>
  <label for="subscription_frequency">Occurs every:</label>
  <% frequency_options = [["2 Weeks", 14], ["3 Weeks", 21], ["Month", 30], ["2 Months", 60], ["3 Months", 90]] %>
  <%= select(:subscription, :frequency, options_for_select(frequency_options, 30), {}) %>
</div>
<div id="start-date-picker" class="calendar"></div>
<%= hidden_field(:subscription, :start_date, {value: (DateTime.now + 14).to_date.iso8601}) %>

... JS that creates the calendar ...

On clicking 'save and continue' I see the following params sent:

{
                  "utf8" => "✓",
               "_method" => "put",
    "authenticity_token" => "...BLAH...",
          "subscription" => {
         "frequency" => "30",
        "start_date" => "2012-11-17"
    },
                "commit" => "Save and Continue",
            "controller" => "spree/checkout",
                "action" => "update",
                 "state" => "subscription"
}

Source: (StackOverflow)

Spree - i18n gem issue

I got a problem with a new version of spree gem (branch: '2-3-stable'). When i try to install it, I receive this error.

my_store$ rails server
The git source https://github.com/spree/spree_gateway.git is not yet checked out. Please  run `bundle install` before trying to start your application

my_store$ bundle install
Bundler could not find compatible versions for gem "i18n":
 In Gemfile:
  spree (= 2.3.1) ruby depends on
   spree_core (= 2.3.1) ruby depends on
    i18n (= 0.6.9) ruby

 rails (= 4.1.2) ruby depends on
  activesupport (= 4.1.2) ruby depends on
    i18n (0.6.11)

But according to gem list i got both of this gems installed i18n (0.6.11, 0.6.9). Can someone help me to fix this problem


Source: (StackOverflow)

Upgrade spree to 1.0.0

I'm trying to upgrade Spree from 0.7.0 to 1.0.0, I added in my gemfile

gem 'spree', '1.0.0'

and mounted the routes by adding this in routes.rb

Store::Application.routes.draw do
  mount Spree::Core::Engine, :at => "/"
end

after that I had override some controllers and model and I added the namespace Spree:: in this way

Spree::ProductsController.class_eval do

now I'm stuck on this error

Mysql2::Error: Table 'store_development.spree_product_groups' doesn't exist: SHOW FIELDS FROM `spree_product_groups`

and it is totally right cause the table does not exists, but it is named without the spree_ prefix, how can i quickly fix it? I suppose that some new column or table has been added to the database, how can i check this? Is there a procedure to upgrade safely spree?


Source: (StackOverflow)

Running Rails in Rubymine from subproject

I'm using RubyMine 3.1.1 with Rails 3.0.9.

I have the Spree project cloned from Github, and I want to debug the server while working on the code. To do this, Spree includes a sandbox rake command that creates a subfolder (called sandbox) that contains an instance of the rails app, one that refers to the parent directory containing the source as its spree gem.

If I close the original project and open the sandbox subfolder as a new probect, I get the correct run configurations for development and production and I can successfully debug. However, this doesn't let me edit the spree code in the parent directory.

If I'm in the parent directory, the subfolder is there of course, but there's no rails run configurations and you can't add one as it says there is no rails server launcher in the project (or some facsimile of that message).

Anyone know how to make RubyMine recognize the run configurations for a subfolder?


Source: (StackOverflow)

Rails 4 - strong parameters concept involvement in spree-2.1

How to add new fields for spree::user in Spree-2.1 + Rails4 ?

Like my old customization: ==========================

Spree::User.class_eval do

attr_accessible :f_name, :l_name :gender
validates :f_name, :presence => true, :length => {:maximum => 25}
validates :l_name, :presence => true, :length => {:maximum => 20}

end

new work with strong parameters: ================================

module Spree UserRegistrationsController.class_eval do

private
 def spree_user_params
   params.require(:spree_user).permit(:f_name, :l_name)
 end

end

end

Even though its not working as it got rollback..

Please let me know your comments.


Source: (StackOverflow)

How to access the admin section of Spree in production?

I have followed the Spree instructions for setting up, and I got it working in development mode. I deployed with Capistrano to rackspace to a production server, but the same default login ("spree@example.com"/"spree123") does not work. I created a user in the web interface, but of course it would not have admin priveleges.

There is nothing in the guide that takes this into account - how can I create an admin user in production when there are no users at all initially? Maybe I deployed incorrectly? I am using a very standard deploy.rb, must there be some spree-specific code for setting this up?


Source: (StackOverflow)

Spree 's latest version does this on remote - undefined method `set_preference' for nil:NilClass

Everything works perfect on my local. I installed everything appropriately on the server, and when I run rake db:bootstrap or rake db:migrate, I get this :

rake aborted!
undefined method `set_preference' for nil:NilClass
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/whiny_nil.rb:48:in `method_missing'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:18:in `set'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:17:in `each'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/spree/preference_access.rb:17:in `set'
/home/chrisisraw/webapps/rails/Live-Jolly-Foods/config/initializers/jolly.rb:1
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:235:in `load'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/engine.rb:201
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/engine.rb:200:in `each'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/engine.rb:200
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `instance_exec'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `run'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:50:in `run_initializers'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `each'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `run_initializers'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:134:in `initialize!'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:77:in `send'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
/home/chrisisraw/webapps/rails/Live-Jolly-Foods/config/environment.rb:5
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:596:in `new_constants_in'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:225:in `load_dependency'
/home/chrisisraw/webapps/rails/gems/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:103:in `require_environment!'
/home/chrisisraw/webapps/rails/gems/gems/railties-3.0.5/lib/rails/application.rb:216
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:607:in `invoke_prerequisites'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:604:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:604:in `invoke_prerequisites'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:596:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/chrisisraw/webapps/rails/gems/bundler/gems/spree-17e74dd1e908/core/lib/tasks/core.rake:71
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/usr/local/ruby1.8.7ee/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/home/chrisisraw/webapps/rails/gems/gems/rake-0.8.7/bin/rake:31
/home/chrisisraw/webapps/rails/bin/rake:19:in `load'
/home/chrisisraw/webapps/rails/bin/rake:19

Anyone figure this out?


Source: (StackOverflow)

Spree, Rails 3, and theming

Well, I've been trying to change the default theme of spree by following this tutorial

http://blog.endpoint.com/2010/01/rails-ecommerce-spree-hooks-tutorial.html

But the homepage doesn't change at all, well since the tutorial is meant for rails 2, I'm just wondering what do I need to change from the tutorial to make it work with rails 3?

Simpler solution than using hooks is welcomed. Also while I'm at it, is there a way to undo the command you run in rails like maybe uninstalling an extension.


Source: (StackOverflow)

Integrating Payment Gateway (activemerchant based) with spree

I am trying to integrate payu.in payment gateway into my rails app. I have integrated their gem in the application but when i go to

/admin/payment_methods/new

I am not able to see the payment gateway under the provider options.

I have followed the steps as prescribed in http://guides.spreecommerce.com/payment_gateways.html

My app/models/spree/gateway/payu.rb looks like this:

module Spree
  class Gateway::Payu < Gateway
    def provider_class
      ActiveMerchant::Billing::Integrations::PayuIn
    end
  end
end

Source: (StackOverflow)

Registering a custom Spree Calculator not working

Following the docs on this page... http://guides.spreecommerce.com/developer/calculators.html

I've created a class in models/spree/calculators/

module Spree 
class Calculator::ZipTax <  Calculator
  def self.description
  "Calculates Tax Rates From Zipcode in TaxRates Table"
   end
    def compute(computable)
  case computable
    when Spree::Order
      compute_order(computable)
    when Spree::LineItem
      compute_line_item(computable)
  end
end
    def compute_order(order)
    zipcode = order.bill_address.zipcode[0,5]
    zip = TaxTable.where(:zipcode => zipcode).first
    if(zip.present?)
      rate = zip.combined_rate
        order.line_items.sum(&:total) * rate
    else 
      0
    end

end
  end
end

And in initializers/spree.rb I've added:

config = Rails.application.config
config.spree.calculators.tax_rates << Spree::Calculator::ZipTax

But I can not get Rails to start. I get undefined method `<<' for nil:NilClass (NoMethodError) on the initializer/spree.rb file.

How do I register a custom Calculator? Using Spree 1.3.2.


Source: (StackOverflow)

Extend spree to have functionalities as Shopify?

I'm new to spree. I'm not sure whether is that possible to extend spree to have a functionality like Shopify. The user signups to create a store. He owns everything to that store. Each owner is not able to edit other stores.

How can I extend it? Which is the best strategy?

  • through database sharding, each store has it own database, connect to different based on domain name?

  • add store_id to every table, that would need to change a lot of code, right?

Any ideas?


Source: (StackOverflow)

Best way to customize Spree?

I need to modify Spree (functionality and views). But Spree installs as a gem (it's not simple application), I believe it's actually a Rails engine right? I'm pretty new at all of this.

But what is exactly the best way to grab Spree and customize it entirely to create your own ecommerce solution?

Thank you.

PS: Using Ruby 1.8.7 and Rails 3.


Source: (StackOverflow)

Connection refused - connect(2) (Errno::ECONNREFUSED)

I am developing a spree application ,I recently removed and reinstalled ruby 1.9.3, now whenever I try rails s on terminal I get the following error :

/home/swapnil/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:762:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)


Source: (StackOverflow)