If you want use Russian Ruble currency in Spree Commerce you should add this monay.rb
to config/initializer
directory of your project.
This file contains 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
function bestTick(largest, mostticks) { | |
var minimum = largest / mostticks; | |
var magnitude = Math.pow(10, Math.floor(Math.log(minimum) / Math.log(10))); | |
var residual = minimum / magnitude; | |
var tick; | |
if (residual > 5) { | |
tick = 10 * magnitude; | |
} else if (residual > 2) { | |
tick = 5 * magnitude; | |
} else if (residual > 1) { |
This file contains 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
function numDigits(x) { | |
return (Math.log10((x ^ (x >> 31)) - (x >> 31)) | 0) + 1; | |
} |
This file contains 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
UPDATE Entities SET depth = (LENGTH(path) - LENGTH(REPLACE(path, '/', ''))) + 2 WHERE path <> ''; |
This file contains 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
1. Dump the data only sql to file | |
$ pg_dump --data-only --inserts YOUR_DB_NAME > dump.sql | |
2. scp to local | |
3. Remove the SET statements at the top | |
such as: | |
SET statement_timeout = 0; | |
SET client_encoding = 'SQL_ASCII'; | |
4. Remove the setval sequence queries |
This file contains 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
#! /bin/sed -f | |
# add begin transaction | |
1s/^SET .*$/END;\nBEGIN;\n/ | |
1s/^-- .*$/END;\nBEGIN;\n/ | |
1s/^/BEGIN;\n/ | |
# remove configuration settings | |
/^SET /d |
This file contains 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
class AddBackgroundToSpreeTaxons < ActiveRecord::Migration | |
def change | |
add_column :spree_taxons, :background_file_name, :string | |
add_column :spree_taxons, :background_content_type, :string | |
add_column :spree_taxons, :background_file_size, :integer | |
add_column :spree_taxons, :background_updated_at, :timestamp | |
end | |
end |
This file contains 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
Order.class_eval do | |
checkout_flow do | |
go_to_state :address | |
go_to_state :delivery | |
go_to_state :payment, :if => lambda { payment_required? } | |
go_to_state :confirm, :if => lambda { confirmation_required? } | |
go_to_state :complete | |
remove_transition :from => :delivery, :to => :confirm | |
end | |
end |
If you wont confirmation page on the finish Spree checkout flow you need override confirmation_required?
as in example.
This file contains 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 | |
def before_delivery | |
@order.next | |
redirect_to checkout_state_path(@order.state) | |
end | |
end |