diff --git a/app/controllers/admin/accessories_controller.rb b/app/controllers/admin/accessories_controller.rb index 3e1a2bf..c1d40e6 100644 --- a/app/controllers/admin/accessories_controller.rb +++ b/app/controllers/admin/accessories_controller.rb @@ -7,49 +7,49 @@ def edit @product_accessories = @product.product_accessories @categories = Category.root.all_children end - + def show @product = Product.find(params[:product_id]) @category = Category.find(params[:category_id]) @products = @category.products end - + def create @product = Product.find(params[:product_id]) accessory = Product.find(params[:accessory_id]) @product.accessories << accessory @product_accessories = @product.product_accessories respond_to do |format| - format.js { + format.js { render :partial => 'accessories' } end - + end - + def update @product = Product.find(params[:product_id]) @product_accessory = ProductAccessory.find(params[:id]) @product_accessory.update_attributes(params[:product_accessory]) @product_accessories = @product.product_accessories respond_to do |format| - format.js { + format.js { render :partial => 'accessories' } end end - + def destroy @product = Product.find(params[:product_id]) @product_accessory = ProductAccessory.find(params[:id]) @product_accessory.destroy @product_accessories = @product.product_accessories respond_to do |format| - format.js { + format.js { render :partial => 'accessories' } end end - + end end diff --git a/app/controllers/admin/authorizations_controller.rb b/app/controllers/admin/authorizations_controller.rb index b9aec45..f5bd37e 100644 --- a/app/controllers/admin/authorizations_controller.rb +++ b/app/controllers/admin/authorizations_controller.rb @@ -1,13 +1,13 @@ module Admin class AuthorizationsController < ApplicationController - + def update @order = Order.find(params[:id]) - # set amount if exists, else use order total + # set amount if exists, else use order total amount = params[:post_authorize_amount].to_d unless params[:post_authorize_amount].blank? amount ||= @order.total_in_cents - + if @order.authorized? @order.capture_payment({:amount => amount}) else @@ -17,8 +17,8 @@ def update render :partial => 'admin/orders/order_transactions' end - - + + end diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 7a6a492..3f48c0f 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -12,7 +12,7 @@ def index def new @category = Category.new end - + def create @category = Category.new(params[:category]) respond_to do |format| @@ -27,11 +27,11 @@ def create end end end - + def edit @category = Category.find(params[:id]) end - + def update @category = Category.find(params[:id]) @@ -42,10 +42,10 @@ def update flash[:notice] = 'Category was successfully updated.' end format.html { render :action => "edit" } - + end end - + def show @category = Category.find(params[:id]) @@ -58,12 +58,12 @@ def show def destroy category = Category.find(params[:id]) category.destroy - + respond_to do |format| format.html { redirect_to(admin_categories_url) } end end - + def reorder category = Category.find(params[:id]) category.reorder(params) diff --git a/app/controllers/admin/category_icon_hovers_controller.rb b/app/controllers/admin/category_icon_hovers_controller.rb index aa74a23..6bda6f9 100644 --- a/app/controllers/admin/category_icon_hovers_controller.rb +++ b/app/controllers/admin/category_icon_hovers_controller.rb @@ -1,20 +1,20 @@ class Admin::CategoryIconHoversController < ApplicationController layout "admin" require_role "admin" - - def create + + def create category_icon = CategoryIcon.find(params[:category_icon_id]) category_icon.create_category_icon_hover(params[:category_icon_hover]) - render :partial => '/admin/categories/icon_hover', + render :partial => '/admin/categories/icon_hover', :locals => { :icon => category_icon } end - + def destroy category_icon = CategoryIcon.find(params[:category_icon_id]) category_icon_hover = CategoryIconHover.find(params[:id]) category_icon_hover.destroy - render :partial => '/admin/categories/icon_hover', + render :partial => '/admin/categories/icon_hover', :locals => { :icon => category_icon } - end + end end diff --git a/app/controllers/admin/category_icons_controller.rb b/app/controllers/admin/category_icons_controller.rb index eb2df65..b8c637c 100644 --- a/app/controllers/admin/category_icons_controller.rb +++ b/app/controllers/admin/category_icons_controller.rb @@ -1,21 +1,21 @@ class Admin::CategoryIconsController < ApplicationController layout "admin" require_role "admin" - - def create + + def create category = Category.find(params[:category_id]) category.create_category_icon(params[:category_icon]) - - render :partial => '/admin/categories/icon', + + render :partial => '/admin/categories/icon', :locals => { :category => category } end - + def destroy category = Category.find(params[:category_id]) category_icon = CategoryIcon.find(params[:id]) category_icon.destroy - render :partial => '/admin/categories/icon', + render :partial => '/admin/categories/icon', :locals => { :category => category } - end + end end diff --git a/app/controllers/admin/category_images_controller.rb b/app/controllers/admin/category_images_controller.rb index 8eb267b..290b898 100644 --- a/app/controllers/admin/category_images_controller.rb +++ b/app/controllers/admin/category_images_controller.rb @@ -1,21 +1,21 @@ class Admin::CategoryImagesController < ApplicationController layout "admin" require_role "admin" - - def create + + def create category = Category.find(params[:category_id]) category.category_images.create(params[:category_image]) category = Category.find(params[:category_id]) - render :partial => '/admin/categories/image_list', + render :partial => '/admin/categories/image_list', :locals => { :category => category } end - + def destroy category = Category.find(params[:category_id]) category_image = CategoryImage.find(params[:id]) category_image.destroy - render :partial => '/admin/categories/image_list', + render :partial => '/admin/categories/image_list', :locals => { :category => category } - end + end end diff --git a/app/controllers/admin/configurations_controller.rb b/app/controllers/admin/configurations_controller.rb index 56ff1e3..80880c8 100644 --- a/app/controllers/admin/configurations_controller.rb +++ b/app/controllers/admin/configurations_controller.rb @@ -3,22 +3,22 @@ module Admin class ConfigurationsController < ApplicationController layout "admin" require_role "admin" - + def index @configuration = Configuration.first || Configuration.create - + respond_to do |format| format.html # index.rhtml format.xml { render :xml => @optimization.to_xml } end end - + def edit @configuration = Configuration.first || Configuration.create end - + def update - @configuration = Configuration.first + @configuration = Configuration.first respond_to do |format| if @configuration.update_attributes(params[:configuration]) flash[:notice] = 'configuration was successfully updated.' @@ -31,6 +31,6 @@ def update end end end - + end end \ No newline at end of file diff --git a/app/controllers/admin/flat_rate_shipping_controller.rb b/app/controllers/admin/flat_rate_shipping_controller.rb index 4c5e42f..b6d2fe2 100644 --- a/app/controllers/admin/flat_rate_shipping_controller.rb +++ b/app/controllers/admin/flat_rate_shipping_controller.rb @@ -1,12 +1,12 @@ module Admin - - + + class FlatRateShippingController < ApplicationController layout 'admin' require_role "admin" - + def index - + end diff --git a/app/controllers/admin/optimizations_controller.rb b/app/controllers/admin/optimizations_controller.rb index bcff03f..71f9868 100644 --- a/app/controllers/admin/optimizations_controller.rb +++ b/app/controllers/admin/optimizations_controller.rb @@ -3,20 +3,20 @@ module Admin class OptimizationsController < ApplicationController layout "admin" require_role "admin" - + def index @optimization = Optimization.first || Optimization.create - + respond_to do |format| format.html # index.rhtml format.xml { render :xml => @optimization.to_xml } end end - + def edit - @optimization = Optimization.first + @optimization = Optimization.first end - + def update @optimization = Optimization.first respond_to do |format| @@ -31,6 +31,6 @@ def update end end end - + end end \ No newline at end of file diff --git a/app/controllers/admin/out_of_stock_options_controller.rb b/app/controllers/admin/out_of_stock_options_controller.rb index b9207be..cbe8bdf 100644 --- a/app/controllers/admin/out_of_stock_options_controller.rb +++ b/app/controllers/admin/out_of_stock_options_controller.rb @@ -2,13 +2,13 @@ module Admin class OutOfStockOptionsController < ApplicationController require_role "admin" - + # add a new out of stock option def create puts params.to_yaml product = Product.find(params[:product_id]) out_of_stock_option = OutOfStockOption.new - + # adds out of stock selections selections = params[:selections] unless product.out_of_stock?(selections) @@ -22,21 +22,21 @@ def create out_of_stock_option.out_of_stock_option_selections << out_of_stock_selection end end - + product.out_of_stock_options << out_of_stock_option end - + render :partial => 'admin/products/out_of_stock_options/out_of_stock_options', :locals => { :out_of_stock_options => product.out_of_stock_options } end - - + + # delete a out of stock option def destroy - product = Product.find(params[:product_id]) + product = Product.find(params[:product_id]) out_of_stock_option = OutOfStockOption.find(params[:id]) product.out_of_stock_options.delete(out_of_stock_option) - + render :partial => 'admin/products/out_of_stock_options/out_of_stock_options', :locals => { :out_of_stock_options => product.out_of_stock_options } end diff --git a/app/controllers/admin/product_options_controller.rb b/app/controllers/admin/product_options_controller.rb index 389a64e..f9eea4d 100644 --- a/app/controllers/admin/product_options_controller.rb +++ b/app/controllers/admin/product_options_controller.rb @@ -4,11 +4,11 @@ module Admin class ProductOptionsController < ApplicationController require_role "admin" - + # TODO: move option selection methods to nested ProductOptionSelectionController - + # add a new product selection to the product option - def add_option_selection + def add_option_selection @product = Product.find(params[:product_id]) @product_option = ProductOption.find(params[:product_option_id]) name = params[:product_option_selection][:name] @@ -22,34 +22,34 @@ def add_option_selection @product_option.product_option_selections << @selection end - + # add an image to the product option selection def add_option_selection_image image = ProductOptionSelectionImage.new(params[:option_selection_image]) option_selection = ProductOptionSelection.find(params[:id]) option_selection.images << image responds_to_parent do - render :update do |page| - page[:image_list].replace_html :partial => '/admin/product_options/option_selection_image_list', + render :update do |page| + page[:image_list].replace_html :partial => '/admin/product_options/option_selection_image_list', :locals => { :option_selection => option_selection } end end end - + # remove an image from the product option selection def remove_option_selection_image option_selection = ProductOptionSelection.find(params[:id]) image = ProductOptionSelectionImage.find(params[:image_id]) - option_selection.images.delete(image) + option_selection.images.delete(image) respond_to do |format| - format.js { - render :partial => '/admin/product_options/option_selection_image_list', + format.js { + render :partial => '/admin/product_options/option_selection_image_list', :locals => { :option_selection => option_selection } } - end + end end - + # edit the option selection def edit_option_selection @product = Product.find(params[:product_id]) @@ -65,48 +65,48 @@ def edit_option_selection @option_selection.images << image end end - + # remove product selection to the product option - def remove_option_selection + def remove_option_selection @product = Product.find(params[:product_id]) @product_option = ProductOption.find(params[:product_option_id]) @selection = ProductOptionSelection.find(params[:selection_id]) - + @product_option.product_option_selections.delete(@selection) end - + # add the existing product option to the product def apply_option_to_product @product = Product.find(params[:product_id]) - + @product_option = ProductOption.find(params[:product_option][:id]) @product_option.update_attributes(params[:product_option]) - product_option_instance = ProductOptionInstance.new(:product => @product, + product_option_instance = ProductOptionInstance.new(:product => @product, :product_option => @product_option) - + product_option_instance.save @available_options = ProductOption.find(:all, :order => 'name') end - + # add a new product option def create @product = Product.find(params[:product_id]) - + @product_option = ProductOption.new(params[:product_option]) - product_option_instance = ProductOptionInstance.new(:product => @product, + product_option_instance = ProductOptionInstance.new(:product => @product, :product_option => @product_option) @product_option_selection = ProductOptionSelection.new @available_options = ProductOption.find(:all, :order => 'name') - + if product_option_instance.save flash[:notice] = 'New Product Option Saved' - else + else flash[:notice] = 'Product Option Not Saved' end end - + # edit a current product option def edit @product = Product.find(params[:id]) @@ -117,25 +117,25 @@ def edit end @product_option = ProductOption.find(product_option_id) end - - + + # update a current product option def update @product_option = ProductOption.find(params[:product_option][:id]) @product = Product.find(params[:product_id]) @product_option.update_attributes(params[:product_option]) - + @available_options = ProductOption.find(:all, :order => 'name') end - - + + # delete a product option def destroy - @product = Product.find(params[:product_id]) + @product = Product.find(params[:product_id]) @product_option = ProductOption.find(params[:id]) @product.product_options.delete(@product_option) - - @available_options = ProductOption.find(:all, :order => 'name') + + @available_options = ProductOption.find(:all, :order => 'name') end end diff --git a/app/controllers/admin/products_controller.rb b/app/controllers/admin/products_controller.rb index 0adedf9..ad2eaf5 100644 --- a/app/controllers/admin/products_controller.rb +++ b/app/controllers/admin/products_controller.rb @@ -4,42 +4,42 @@ module Admin class ProductsController < ApplicationController layout "admin" require_role "admin" - + # add a product to the category def add_to_category @product = Product.find(params[:id]) @category = Category.find(params[:category_select]) @product.categories << @category end - + # remove product from category def remove_from_category product = Product.find(params[:id]) category = Category.find(params[:category_id]) product.categories.delete(category) respond_to do |format| - format.js { - render :partial => 'category_list', + format.js { + render :partial => 'category_list', :locals => { :product_id => product.id, :categories => product.categories } } end end - + # upload an image fu def upload_image @image = ProductImage.new(params[:mugshot]) if @image.save - flash[:notice] = 'Mugshot was successfully created.' + flash[:notice] = 'Mugshot was successfully created.' else render :action => :new end end - + # The REST: - + def index @products = Product.paginate(:page => params[:page], :order => 'name') - + respond_to do |format| format.html # index.rhtml format.xml { render :xml => @products.to_xml } @@ -60,7 +60,7 @@ def show def new @product = Product.new 3.times { @product.quantity_discounts.build } - + @vendors = Vendor.find(:all) @categories = Category.find(:all) end @@ -96,7 +96,7 @@ def update if @product.update_attributes(params[:product]) flash[:notice] = "Product #{@product.name} was successfully updated." format.html { redirect_to edit_admin_product_path(@product.id) } - format.js + format.js else @vendors = Vendor.find(:all) @categories = Category.root.descendants @@ -112,7 +112,7 @@ def update def destroy @product = Product.find(params[:id]) @product.destroy - redirect_to admin_products_url + redirect_to admin_products_url end end diff --git a/app/controllers/admin/promo_codes_controller.rb b/app/controllers/admin/promo_codes_controller.rb index 6d014b2..03397d0 100644 --- a/app/controllers/admin/promo_codes_controller.rb +++ b/app/controllers/admin/promo_codes_controller.rb @@ -1,21 +1,21 @@ module Admin - + class PromoCodesController < ApplicationController layout 'admin' require_role 'admin' - + def index @promo_codes = PromoCode.find(:all, :order => 'name') end - + def new @promo_code = PromoCode.new end - + def create @promo_code = PromoCode.new(params[:promo_code]) - @promo_code.code = @promo_code.code.upcase - + @promo_code.code = @promo_code.code.upcase + respond_to do |format| if @promo_code.save flash[:notice] = 'Promo Code was successfully created.' @@ -25,11 +25,11 @@ def create end end end - + def edit @promo_code = PromoCode.find(params[:id]) end - + def update @promo_code = PromoCode.find(params[:id]) @@ -43,7 +43,7 @@ def update end end end - + def destroy @promo_code = PromoCode.find(params[:id]) @promo_code.destroy @@ -53,7 +53,7 @@ def destroy format.xml { head :ok } end end - + end - + end \ No newline at end of file diff --git a/app/controllers/admin/reporting/order_reports_controller.rb b/app/controllers/admin/reporting/order_reports_controller.rb index cf84679..4c93b48 100644 --- a/app/controllers/admin/reporting/order_reports_controller.rb +++ b/app/controllers/admin/reporting/order_reports_controller.rb @@ -2,31 +2,31 @@ class Admin::Reporting::OrderReportsController < ApplicationController layout 'admin' require_role 'admin' - + def create generate_report = params[:generate_report] if generate_report session[:start_date] = params[:start_date] session[:end_date] = params[:end_date] - + csv = render_order_report_as :csv send_data csv, :type => "text/csv", - :filename => "orders#{session[:start_date]}.csv" + :filename => "orders#{session[:start_date]}.csv" end end - + def csv_list csv = render_order_report_as :csv send_data csv, :type => "text/csv", - :filename => "orders.csv" + :filename => "orders.csv" end - + def pdf pdf = render_order_report_as :pdf send_data pdf, :type => "application/pdf", - :filename => "orders.pdf" + :filename => "orders.pdf" end - + protected def render_order_report_as(format) diff --git a/app/controllers/admin/reporting/reports_controller.rb b/app/controllers/admin/reporting/reports_controller.rb index fb1c425..9ec7ba1 100644 --- a/app/controllers/admin/reporting/reports_controller.rb +++ b/app/controllers/admin/reporting/reports_controller.rb @@ -2,10 +2,10 @@ class Admin::Reporting::ReportsController < ApplicationController layout 'admin' require_role 'admin' - + def index - + end - + end diff --git a/app/controllers/admin/shipping_rates_controller.rb b/app/controllers/admin/shipping_rates_controller.rb index e2912cf..2912f33 100644 --- a/app/controllers/admin/shipping_rates_controller.rb +++ b/app/controllers/admin/shipping_rates_controller.rb @@ -1,10 +1,10 @@ module Admin - - + + class ShippingRatesController < ApplicationController layout 'admin' require_role "admin" - + # GET /shipping_rates def index @shipping_rates = ShippingRate.find(:all) @@ -18,7 +18,7 @@ def index # GET /shipping_rates/1.xml def show @shipping_rate = ShippingRate.find(params[:id]) - + respond_to do |format| format.html # show.rhtml end @@ -27,7 +27,7 @@ def show # GET /shipping_rates/new def new puts params - + @shipping_rate = ShippingRate.new end diff --git a/app/controllers/admin/variant_image_thumbnails_controller.rb b/app/controllers/admin/variant_image_thumbnails_controller.rb index 743b212..0a6ae04 100644 --- a/app/controllers/admin/variant_image_thumbnails_controller.rb +++ b/app/controllers/admin/variant_image_thumbnails_controller.rb @@ -1,15 +1,15 @@ class Admin::VariantImageThumbnailsController < ApplicationController layout "admin" require_role "admin" - - def create + + def create variant_image = VariantImage.find(params[:variant_image_id]) - variant_image.create_variant_image_thumbnail(params[:variant_image_thumbnail]) - render :partial => "admin/products/variant_thumbnail", + variant_image.create_variant_image_thumbnail(params[:variant_image_thumbnail]) + render :partial => "admin/products/variant_thumbnail", :locals => { :thumbnail => variant_image.variant_image_thumbnail, :variant_image => variant_image } end - + def destroy variant_image = VariantImage.find(params[:variant_image_id]) thumbnail = VariantImageThumbnail.find(params[:id]) diff --git a/app/controllers/admin/variant_images_controller.rb b/app/controllers/admin/variant_images_controller.rb index beca739..2baba9d 100644 --- a/app/controllers/admin/variant_images_controller.rb +++ b/app/controllers/admin/variant_images_controller.rb @@ -1,40 +1,40 @@ class Admin::VariantImagesController < ApplicationController layout "admin" require_role "admin" - + def new variant_image = VariantImage.new variant_image.build_variant_large_image variant_image.build_variant_image_thumbnail render :partial => "admin/products/variant_image", :locals => { :variant_image => variant_image } end - + def show variant_image = VariantImage.find(params[:id]) variant_image.build_variant_large_image unless variant_image.variant_large_image variant_image.build_variant_image_thumbnail unless variant_image.variant_image_thumbnail render :partial => "admin/products/variant_image", :locals => { :variant_image => variant_image } end - - def create + + def create variants = Variant.find(params[:variant_ids].split(',').map{|s| s.to_i}) product = variants.first.product variant_image = VariantImage.create(params[:variant_image]) variant_image.variants << variants variant_image.build_variant_large_image variant_image.build_variant_image_thumbnail - render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, + render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, :variant_image => variant_image} end - + def destroy variant_image = VariantImage.find(params[:id]) product = variant_image.product variants = product.variants variant_image.destroy - render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, + render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, :variant_image => VariantImage.new} - - end + + end end \ No newline at end of file diff --git a/app/controllers/admin/variant_large_images_controller.rb b/app/controllers/admin/variant_large_images_controller.rb index e7fc2cf..0c990e5 100644 --- a/app/controllers/admin/variant_large_images_controller.rb +++ b/app/controllers/admin/variant_large_images_controller.rb @@ -1,22 +1,22 @@ class Admin::VariantLargeImagesController < ApplicationController layout "admin" require_role "admin" - - def create + + def create variant_image = VariantImage.find(params[:variant_image_id]) - variant_image.create_variant_large_image(params[:variant_large_image]) - render :partial => "admin/products/variant_large_image", + variant_image.create_variant_large_image(params[:variant_large_image]) + render :partial => "admin/products/variant_large_image", :locals => { :large_image => variant_image.variant_large_image, :variant_image => variant_image } end - + def destroy variant_image = VariantImage.find(params[:variant_image_id]) large_image = VariantLargeImage.find(params[:id]) large_image.destroy - render :partial => "admin/products/variant_large_image", + render :partial => "admin/products/variant_large_image", :locals => { :large_image => variant_image.build_variant_large_image, :variant_image => variant_image } end - + end diff --git a/app/controllers/admin/variants_controller.rb b/app/controllers/admin/variants_controller.rb index bf5bb8d..c9382b7 100644 --- a/app/controllers/admin/variants_controller.rb +++ b/app/controllers/admin/variants_controller.rb @@ -1,15 +1,15 @@ class Admin::VariantsController < ApplicationController layout "admin" require_role "admin" - + def update variant = Variant.find(params[:id]) variant.variant_image_id = nil variant.save! product = variant.product variants = product.variants - render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, + render :partial => "admin/products/variants", :locals => { :variants => variants, :product => product, :variant_image => VariantImage.new} - end + end end \ No newline at end of file diff --git a/app/controllers/admin/vendors_controller.rb b/app/controllers/admin/vendors_controller.rb index bdb7fdc..5b2676c 100644 --- a/app/controllers/admin/vendors_controller.rb +++ b/app/controllers/admin/vendors_controller.rb @@ -3,7 +3,7 @@ module Admin class VendorsController < ApplicationController layout "admin" require_role "admin" - + # GET /vendors # GET /vendors.xml def index diff --git a/app/controllers/carts_controller.rb b/app/controllers/carts_controller.rb index 18efc23..9589d57 100644 --- a/app/controllers/carts_controller.rb +++ b/app/controllers/carts_controller.rb @@ -33,7 +33,7 @@ def refresh_totals def show @cart = current_cart - @cart.validate + @cart.validate refresh_cart end @@ -47,7 +47,7 @@ def update render :action => 'show' end end - + def refresh_cart region = Region.find(active_shipping_region_id) method = active_shipping_method_id diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb index b6c46d9..e31ba7c 100644 --- a/app/controllers/categories_controller.rb +++ b/app/controllers/categories_controller.rb @@ -24,7 +24,7 @@ def show private - def ensure_current_post_show_url + def ensure_current_post_show_url @category = Category.find(params[:id]) unless @category.friendly_id_status.best? redirect_to @category, :status => :moved_permanently diff --git a/app/controllers/contacts_controller.rb b/app/controllers/contacts_controller.rb index cfd1f9d..9f33941 100644 --- a/app/controllers/contacts_controller.rb +++ b/app/controllers/contacts_controller.rb @@ -1,10 +1,10 @@ class ContactsController < ApplicationController - + def create begin ContactNotifier.deliver_contact_confirmation(params[:name], params[:email], params[:phone], params[:extension], - params[:comment]) + params[:comment]) rescue render :text => 'Sorry there was a problem sending your message. Please try again later' end diff --git a/app/controllers/index_controller.rb b/app/controllers/index_controller.rb index 9ae2b5b..1339c75 100644 --- a/app/controllers/index_controller.rb +++ b/app/controllers/index_controller.rb @@ -7,17 +7,17 @@ def index @featured_products = Product.find(:all, :conditions => { :is_featured => true }) #render :layout => 'splash' end - + def send_contact ContactNotifier.deliver_contact_confirmation(params[:name], params[:email], params[:phone], params[:extension], - params[:comment]) + params[:comment]) end - + def about; end def charity; end def return_policy; end def shipping_information; end - + end diff --git a/app/controllers/paypal_ipn_controller.rb b/app/controllers/paypal_ipn_controller.rb index ada217b..077e0f5 100644 --- a/app/controllers/paypal_ipn_controller.rb +++ b/app/controllers/paypal_ipn_controller.rb @@ -1,24 +1,24 @@ class PayPal_IPN_Controller < ApplicationController - + def paypal_ipn notify = Paypal::Notification.new(request.raw_post) - + # order = Order.find(notify.item_id) - # + # # if notify.acknowledge # begin - # + # # if notify.complete? and order.total == notify.amount # order.status = 'success' - # + # # shop.ship(order) # else # logger.error("Failed to verify Paypal's notification, please investigate") # end - # + # # rescue => e # order.status = 'failed' # raise @@ -26,7 +26,7 @@ def paypal_ipn # order.save # end # end - # + # # render :nothing end diff --git a/app/controllers/promo_codes_controller.rb b/app/controllers/promo_codes_controller.rb index 7e963ac..98ec0a0 100644 --- a/app/controllers/promo_codes_controller.rb +++ b/app/controllers/promo_codes_controller.rb @@ -1,8 +1,8 @@ class PromoCodesController < ApplicationController include ActionView::Helpers::NumberHelper - + ssl_allowed :create - + def create cart = current_cart @@ -17,16 +17,16 @@ def create method = ShippingMethod.find(active_shipping_method_id) shipping_total = cart.shipping_total(method) grand_total = cart.grand_total(shipping_total) - + render :json => { :promo_code_message => promo_code_message, :promo_code_note => promo_code_note, - :no_discount => discount == 0, - :discount => number_to_currency(discount), + :no_discount => discount == 0, + :discount => number_to_currency(discount), :no_tax => tax_total == 0, - :tax_total => number_to_currency(tax_total), + :tax_total => number_to_currency(tax_total), :shipping_total => number_to_currency(shipping_total), :grand_total => number_to_currency(grand_total) } - + end end diff --git a/app/controllers/shipping_methods_controller.rb b/app/controllers/shipping_methods_controller.rb index 7758242..135b402 100644 --- a/app/controllers/shipping_methods_controller.rb +++ b/app/controllers/shipping_methods_controller.rb @@ -1,7 +1,7 @@ class ShippingMethodsController < ApplicationController include ActionView::Helpers::NumberHelper ssl_allowed :index, :update - + def index region = Region.find(params[:region_id]) @shipping_methods = region.shipping_methods @@ -18,7 +18,7 @@ def index self.active_shipping_method_id = @default_method.id render :layout => false end - + def update method = ShippingMethod.find(params[:id]) @@ -28,11 +28,11 @@ def update # change active shipping rate depending on selection self.active_shipping_method_id = method.id - - render :json => { :shipping_total => number_to_currency(shipping_total), + + render :json => { :shipping_total => number_to_currency(shipping_total), :grand_total => number_to_currency(grand_total) } - - end - + + end + end diff --git a/app/controllers/shippings_controller.rb b/app/controllers/shippings_controller.rb index b057a4e..e39fb6e 100644 --- a/app/controllers/shippings_controller.rb +++ b/app/controllers/shippings_controller.rb @@ -6,10 +6,10 @@ def create quantity = params[:quantity].to_i product_id = params[:id] # create an array of selected accessory ids; note that it helps to reject the collected nil - accessories = ProductAccessory.selected_accessories(params[:accessories]) if params[:accessories] + accessories = ProductAccessory.selected_accessories(params[:accessories]) if params[:accessories] @shipping = ShippingCalculations.product_quote(product_id, quantity, zipcode, accessories) render :partial => 'products/shipping' end - + end diff --git a/app/controllers/taxes_controller.rb b/app/controllers/taxes_controller.rb index 8896933..4936032 100644 --- a/app/controllers/taxes_controller.rb +++ b/app/controllers/taxes_controller.rb @@ -1,7 +1,7 @@ class TaxesController < ApplicationController include ActionView::Helpers::NumberHelper - - ssl_allowed :update + + ssl_allowed :update def update cart = current_cart @@ -9,15 +9,15 @@ def update cart.save(false) method = ShippingMethod.find(active_shipping_method_id) shipping_total = cart.shipping_total(method) - + tax_total = cart.tax_total grand_total = cart.grand_total(shipping_total) - + render :json => { :no_tax => tax_total == 0, - :tax_total => number_to_currency(tax_total), + :tax_total => number_to_currency(tax_total), :grand_total => number_to_currency(grand_total) } - - end - + + end + end \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9197b8b..1daf1ba 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,13 +1,13 @@ class UsersController < ApplicationController - + # render new.rhtml def new end def create cookies.delete :auth_token - # protects against session fixation attacks, wreaks havoc with + # protects against session fixation attacks, wreaks havoc with # request forgery protection. # uncomment at your own risk # reset_session diff --git a/app/controllers/variant_images_controller.rb b/app/controllers/variant_images_controller.rb index bfe7fae..9eaeac0 100644 --- a/app/controllers/variant_images_controller.rb +++ b/app/controllers/variant_images_controller.rb @@ -1,13 +1,13 @@ class VariantImagesController < ApplicationController - + def index product = Product.find(params[:product_id]) render :partial => 'products/variant_images', :locals => { :product => product } - end - + end + def show variant_image = VariantImage.find(params[:id]) render :partial => 'products/product_image', :locals => { :image => variant_image } end - + end diff --git a/app/controllers/variants_controller.rb b/app/controllers/variants_controller.rb index af71786..5bc5fa9 100644 --- a/app/controllers/variants_controller.rb +++ b/app/controllers/variants_controller.rb @@ -1,14 +1,14 @@ class VariantsController < ApplicationController include ActionView::Helpers::NumberHelper - + def show product = Product.find(params[:product_id]) variant = product.find_variant_by_selection_ids(params[:selection_ids].split(',').map{|s| s.to_i}) inventory = Inventory.new.inventory_remaining(current_cart, product, variant) - render :json => { :price => number_to_currency(variant.price), + render :json => { :price => number_to_currency(variant.price), :out_of_stock => variant.out_of_stock_check, - :variant_image_id => variant.variant_image_id, + :variant_image_id => variant.variant_image_id, :inventory => inventory } end - + end diff --git a/app/helpers/pebbles/admin/shipping_methods_helper.rb b/app/helpers/pebbles/admin/shipping_methods_helper.rb index b7dd08f..c0af050 100644 --- a/app/helpers/pebbles/admin/shipping_methods_helper.rb +++ b/app/helpers/pebbles/admin/shipping_methods_helper.rb @@ -1,19 +1,19 @@ module Pebbles::Admin::ShippingMethodsHelper def add_fulfillment_link(name) link_to_function name do |page| - page.insert_html :bottom, :fulfillment_codes, + page.insert_html :bottom, :fulfillment_codes, :partial => 'fulfillment_code', :object => FulfillmentCode.new end end - + def set_up_shippping_method(shipping_method) returning(shipping_method) do |m| - 10.times do + 10.times do m.flat_rate_shippings.build end end end - - + + end diff --git a/app/helpers/pebbles/inventory_helper.rb b/app/helpers/pebbles/inventory_helper.rb index e94c705..346170e 100644 --- a/app/helpers/pebbles/inventory_helper.rb +++ b/app/helpers/pebbles/inventory_helper.rb @@ -13,8 +13,8 @@ def validate_inventory? "inventory" end end - - + + ## # def inventory_management_hidden_field(inventory) diff --git a/app/helpers/pebbles/products_helper.rb b/app/helpers/pebbles/products_helper.rb index e740aac..1a738ff 100644 --- a/app/helpers/pebbles/products_helper.rb +++ b/app/helpers/pebbles/products_helper.rb @@ -4,20 +4,20 @@ module Pebbles::ProductsHelper # Add a image magnifier if the large image exists. # # @param[String] image The name of the image to use as a magnifier. - # @param[String] image_url The url of the image being magnifed. - # @param[Hash] options Additonal options, class, etc. - def image_magnify(image, image_url, options={}) + # @param[String] image_url The url of the image being magnifed. + # @param[Hash] options Additonal options, class, etc. + def image_magnify(image, image_url, options={}) if image_url.present? image_tag image, options end end ## - # Creates a light boxed image link if the image to lightbox exists. + # Creates a light boxed image link if the image to lightbox exists. # - # @param[String] image_url The image url to link to a lightbox. - # @param[String] light_boxed_image The image url of the image to lightbox. - # @param[Hash] options Options to pass to the image tag. + # @param[String] image_url The image url to link to a lightbox. + # @param[String] light_boxed_image The image url of the image to lightbox. + # @param[Hash] options Options to pass to the image tag. def light_box(image_url, light_boxed_image, options={}) if light_boxed_image.blank? # just show image @@ -32,5 +32,5 @@ def light_box(image_url, light_boxed_image, options={}) def disable(category, product) 'disabled="disabled"' if product.category_ids.include?(category.id) end - + end diff --git a/app/helpers/pebbles/variants_helper.rb b/app/helpers/pebbles/variants_helper.rb index f993d1f..2bc9a56 100644 --- a/app/helpers/pebbles/variants_helper.rb +++ b/app/helpers/pebbles/variants_helper.rb @@ -8,5 +8,5 @@ def variant_thumbnail(image) thumbnail = image.variant_image_thumbnail || image thumbnail.filename.url end - + end diff --git a/app/lib/exceptions.rb b/app/lib/exceptions.rb index 21bec80..133b26c 100644 --- a/app/lib/exceptions.rb +++ b/app/lib/exceptions.rb @@ -2,6 +2,6 @@ module Exceptions class OrderException < RuntimeError; end class EbayOrderException < RuntimeError; end class WebOrderException < RuntimeError; end - + class FulfillmentException < RuntimeError; end end \ No newline at end of file diff --git a/app/lib/inventory.rb b/app/lib/inventory.rb index 6c272b7..853e112 100644 --- a/app/lib/inventory.rb +++ b/app/lib/inventory.rb @@ -1,17 +1,17 @@ class Inventory - + def initialize @inventory_managed = inventory_managed? end - + def inventory_managed? GeneralConfiguration.instance.inventory_management? end - + ## # Validates a cart adding errors when cart_items exceed current inventory for product or variant # - # @param [Cart] cart cart to validate + # @param [Cart] cart cart to validate def validate_cart(cart) if @inventory_managed cart.cart_items.each do |cart_item| @@ -27,7 +27,7 @@ def validate_cart(cart) end end end - + ## # Decreases the inventory for the products and or variants for items in an order # @@ -39,7 +39,7 @@ def decrease_order_inventory(order) end end end - + ## # returns the inventory remaining for a product or variant minus any existing cart_item quantities # @@ -50,7 +50,7 @@ def decrease_order_inventory(order) # @return [] the inventory remaining or nil if no inventory is being managed def inventory_remaining(cart, product, variant = nil) if @inventory_managed - inventory = (variant || product).inventory + inventory = (variant || product).inventory existing_cart_item = cart.find_product_or_variant(product, variant) inventory -= existing_cart_item.quantity if existing_cart_item inventory @@ -60,7 +60,7 @@ def inventory_remaining(cart, product, variant = nil) end private - + ## # Validates a cart_item adjusting its quantity and adding an error if quantity exceeds inventory # @@ -78,7 +78,7 @@ def validate_cart_item(cart_item) return true end end - + ## # Decreases the inventory for the product or variant of an order_item # diff --git a/app/lib/order_calculations.rb b/app/lib/order_calculations.rb index 9f63aa5..ae5d31d 100644 --- a/app/lib/order_calculations.rb +++ b/app/lib/order_calculations.rb @@ -8,21 +8,21 @@ def product_total def sub_total product_total - promo_discount end - + def total - total_cost = self.product_cost + self.shipping_cost + + total_cost = self.product_cost + self.shipping_cost + self.drop_shipping_cost + self.tax - self.promo_discount sprintf("%.2f", total_cost).to_f end - + def total_in_cents self.total * 100 end - + def shipping_handling self.shipping_cost + self.drop_shipping_cost end - + def calculate_order_costs self.shipment_weight_total = 1.0 # default to one right now self.product_cost = product_total @@ -33,39 +33,39 @@ def calculate_order_costs # drop_ship_vendors = Array.new # self.order_items.each do |item| # self.product_cost += item.quantity * item.adjusted_price - # + # # if item.drop_ship # unless drop_ship_vendors.include?(item.supplier_id) # # vendor does not exist in the array, so # # add the drop ship amount for this vendor # # to the order's total drop ship amount # self.drop_shipping_cost += item.drop_shipping_cost - # - # # add vendor to the array, so drop ship amount isn't re-added + # + # # add vendor to the array, so drop ship amount isn't re-added # # if the customer has another item in his cart from this vendor - # drop_ship_vendors.push(item.supplier_id) + # drop_ship_vendors.push(item.supplier_id) # end # else # #TODO: if free shipping # #self.shipment_weight_total += item.quantity * item.adjusted_weight # end # end - # #calculate_quantity_discounts + # #calculate_quantity_discounts # #calculate_tax total end - - + + def calculate_quantity_discounts - # quantity discounts + # quantity discounts discount = 0 - self.order_items.each do |order_item| + self.order_items.each do |order_item| # discount += QuantityDiscount.determine_discount(order_item) end self.product_cost -= discount end - - + + def calculate_tax t = 0 unless billing_address.nil? diff --git a/app/lib/order_factory.rb b/app/lib/order_factory.rb index ebac83c..083618c 100644 --- a/app/lib/order_factory.rb +++ b/app/lib/order_factory.rb @@ -1,12 +1,12 @@ include ActiveMerchant::Billing class OrderFactory - + WEB_ORDER_DEFAULTS = { :order_type => OrderType::WEB, :payment_type => 'credit_card', :delivery_status => 1 } - + class << self - - # create an order from a paypal notification + + # create an order from a paypal notification # Exception::EbayOrderException thrown if an issue is encountered def create_ebay_order(notify) @@ -26,7 +26,7 @@ def create_ebay_order(notify) :postal_code => notify.address_zip, :country => notify.address_country_code ) - + order = Order.new order.order_type = OrderType::EBAY order.build_order_number('E') @@ -34,17 +34,17 @@ def create_ebay_order(notify) unless billing_address.save errors = billing_address.errors.collect { |e| e } msg = "eBay Error: Invalid billing address: #{errors}, - #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, + #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, item number: #{notify.item_number}." order.admin_notes = msg order.issue_raised! order.issue_raised! - raise Exceptions::EbayOrderException, msg, caller + raise Exceptions::EbayOrderException, msg, caller end unless shipping_address.save errors = billing_address.errors.collect { |e| e } msg = "eBay Error: Invalid billing address: #{errors}, - #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, + #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, item number: #{notify.item_number}." order.admin_notes = msg order.issue_raised! @@ -59,7 +59,7 @@ def create_ebay_order(notify) order.ebay_auction_id = notify.auction_buyer_id order.ebay_item_number = notify.item_number order.phone_number = '555-555-5555' - + # create order items for i in (1...notify.num_cart_items+1) name = notify.item_name(i) @@ -70,25 +70,25 @@ def create_ebay_order(notify) order.order_items << OrderItem.from_ebay_order(product, quantity) else msg = "eBay Error: Product received from eBay is not a valid product: #{notify.item_name(i)}, - #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, - item number: #{notify.item_number}." + #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, + item number: #{notify.item_number}." order.admin_notes = msg order.issue_raised! order.issue_raised! raise Exceptions::EbayOrderException, msg, caller end end - order = shipping_method_translation(order, billing_address.country, notify) + order = shipping_method_translation(order, billing_address.country, notify) order.calculate_order_costs - + order.save! # raise exception if error - + order end - + # build a paypal order def create_paypal_order(cart, details, active_shipping_region_id, active_shipping_method_id) - order = Order.new + order = Order.new order.order_type = OrderType::WEB billing_address = Address.new( :address_1 => details.address['address1'], @@ -112,28 +112,28 @@ def create_paypal_order(cart, details, active_shipping_region_id, active_shippin order.full_name = details.name order.phone_number = '555-555-5555' order.email = details.email - + order.shipping_method_id = active_shipping_method_id order.region_id = active_shipping_region_id order.add_order_items_from_cart(cart) order.calculate_order_costs - + order.payment_type = 'paypal' - - order.save! - + + order.save! + order end - - + + # build a web order def create_web_order(cart, options = {}) - - order = Order.new(WEB_ORDER_DEFAULTS.merge(options[:order])) + + order = Order.new(WEB_ORDER_DEFAULTS.merge(options[:order])) billing_address = Address.new(options[:billing_address]) - + # piece-meal validation so user sees validation in steps - + # shipping address? shipping_same = true unless options[:address_choice].nil? unless shipping_same @@ -141,11 +141,11 @@ def create_web_order(cart, options = {}) else shipping_address = billing_address.clone end - - order.shipping_address = shipping_address + + order.shipping_address = shipping_address order.billing_address = billing_address - # CC validation + # CC validation credit_card = CreditCard.new(options[:credit_card]) credit_card.require_verification_value = true order.credit_card = credit_card @@ -153,7 +153,7 @@ def create_web_order(cart, options = {}) billing_address.valid? && shipping_address.valid? if valid order.credit_card_display = order.credit_card.display_number - + order.shipping_method_id = options[:active_shipping_method_id] order.region_id = options[:active_shipping_region_id] order.add_order_items_from_cart(cart) @@ -165,9 +165,9 @@ def create_web_order(cart, options = {}) end order end - - private - + + private + # set the region and shipping method by region def shipping_method_translation(order, country, notify) # shipping method is same as standard shipping, United States @@ -193,8 +193,8 @@ def shipping_method_translation(order, country, notify) order.region_id = region.id else msg = "eBay Error: Region not found: #{order.billing_address.country}, - #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, - trying region #{trying_region}, trying method #{trying_method}" + #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, + trying region #{trying_region}, trying method #{trying_method}" order.admin_notes = msg order.issue_raised! order.issue_raised! @@ -205,24 +205,24 @@ def shipping_method_translation(order, country, notify) order.shipping_method = shipping_method.name else msg = "eBay Error: Shipping Method not found: #{order.billing_address.country}, - #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, - trying region #{trying_region}, trying method #{trying_method}" + #{DateTime.now}, auction buyer id: #{notify.auction_buyer_id}, + trying region #{trying_region}, trying method #{trying_method}" order.admin_notes = msg order.issue_raised! order.issue_raised! raise Exceptions::EbayOrderException, msg, caller - end + end order end - + # find a product by sku def product_from(sku) product = Product.find(:first, :conditions => { :sku => sku }) end - + # parse a sku out of the ebay product subject def grab_sku(name) - if name + if name # TODO: use regexp i1 = name.index('(') i2 = name.index(')') @@ -233,6 +233,6 @@ def grab_sku(name) sku.gsub(/\s/, '') # remove spaces end end - + end end diff --git a/app/lib/order_processing.rb b/app/lib/order_processing.rb index 1d90e93..5cb3acc 100644 --- a/app/lib/order_processing.rb +++ b/app/lib/order_processing.rb @@ -1,9 +1,9 @@ # Handle processing of an order -module OrderProcessing - +module OrderProcessing + # process the order with the current merchant def process - if self.order_items.size > 0 + if self.order_items.size > 0 case self.order_type when OrderType::WEB process_web_order @@ -14,13 +14,13 @@ def process end end end - + # make an authorization on a payment def authorize_payment(options = {}) options = populate_options if options.size == 0 options[:order_id] = self.order_number transaction do - authorization = OrderTransaction.authorize(self.total_in_cents, + authorization = OrderTransaction.authorize(self.total_in_cents, self.credit_card, options ) self.transactions << authorization @@ -35,7 +35,7 @@ def authorize_payment(options = {}) # return the authorized reference for further use def authorization_reference - if authorization = transactions.find_by_action_and_success('authorization', + if authorization = transactions.find_by_action_and_success('authorization', true, :order => 'id ASC') authorization.reference end @@ -49,7 +49,7 @@ def authorization_reference def capture_payment(options = {}) options = populate_options if options.size == 0 - amount = if options[:amount] + amount = if options[:amount] options[:amount] * 100 else self.total_in_cents @@ -66,9 +66,9 @@ def capture_payment(options = {}) capture end end - + private - + # TODO: move to acts_as_state_machine transitions def initialize_order save! @@ -82,23 +82,23 @@ def initialize_order end build_order_number(prefix) end - + def process_ebay_order initialize_order # send off to integration ShippingFulfillment.fulfill_order(self) end - + def process_web_order initialize_order if self.payment_type == 'credit_card' - process_with_active_merchant + process_with_active_merchant unless self.paid? || self.authorized? msg = self.transactions[0].params['error'] raise Exceptions::OrderException, msg, caller end - + if APP_CONFIG['fulfillment'] == true if self.paid? ShippingFulfillment.fulfill_order(self) @@ -107,13 +107,13 @@ def process_web_order raise Exceptions::OrderException, msg, caller end elsif self.payment_type == 'paypal' - begin + begin ShippingFulfillment.fulfill_order(self) - rescue + rescue end - end + end end - + OrderNotifier.deliver_order_confirmation(self, self.email, '128.9.0.0') OrderNotifier.deliver_supplier_confirmation(self, self.email, '128.9.0.0') end @@ -138,13 +138,13 @@ def populate_options :country => self.shipping_address.country, :phone => self.phone_number }, - :company => self.business, + :company => self.business, :order_id => self.id, :customer => self.full_name, :email => self.email } end - + # Active Merchant order processing def process_with_active_merchant options = populate_options @@ -157,5 +157,5 @@ def process_with_active_merchant end end end - + end diff --git a/app/lib/order_state_machine.rb b/app/lib/order_state_machine.rb index 1aab85d..93eb99e 100644 --- a/app/lib/order_state_machine.rb +++ b/app/lib/order_state_machine.rb @@ -1,14 +1,14 @@ module OrderStateMachine - + def self.included(base) - base.class_eval do + base.class_eval do aasm_column :state aasm_initial_state :pending - aasm_state :pending + aasm_state :pending aasm_state :authorized - aasm_state :paid, :enter => :decrease_inventory - aasm_state :payment_declined + aasm_state :paid, :enter => :decrease_inventory + aasm_state :payment_declined aasm_state :refunded aasm_state :disputed aasm_state :shipping_delayed @@ -16,7 +16,7 @@ def self.included(base) aasm_state :shipped aasm_state :issue - # state events + # state events aasm_event :payment_authorized do transitions :from => :pending, :to => :authorized @@ -36,10 +36,10 @@ def self.included(base) transitions :from => :payment_declined, :to => :payment_declined - + transitions :from => :authorized, :to => :payment_declined - + end aasm_event :issue_raised do @@ -49,7 +49,7 @@ def self.included(base) transitions :from => :paid, :to => :issue - transitions :from => :authorized, + transitions :from => :authorized, :to => :issue end @@ -76,9 +76,9 @@ def self.included(base) end end end - + def decrease_inventory Inventory.new.decrease_order_inventory(self) end - + end diff --git a/app/lib/shipping_calculations.rb b/app/lib/shipping_calculations.rb index 9fb24c8..a7854c0 100644 --- a/app/lib/shipping_calculations.rb +++ b/app/lib/shipping_calculations.rb @@ -10,13 +10,13 @@ def calculate_shipping_costs end price end - + def shipping_weight_total self.line_items.to_a.sum {|i| i.product.free_shipping? ? 0 : i.product.weight * i.quantity} end - + private - + ## # Calculate shipping cost using flat rates of order total. # @@ -25,25 +25,25 @@ def calculate_flat_rate_shipping shipping_method = ShippingMethod.find(self.shipping_method_id) price = shipping_method.flat_rate_shipping_cost(self) end - + ### #### REFACTOR: All of this is from people powered machines and needs review ### - + # calculate cost for product item def self.product_quote(product_id, quantity, zipcode, accessories = []) product = Product.find(product_id) - quote = case product.determined_shipping_type + quote = case product.determined_shipping_type when ShippingType::FREE_SHIPPING 0 when ShippingType::FLAT_RATE_SHIPPING self.flat_rate_shipping_quote(product, accessories, zipcode, quantity) when ShippingType::REAL_TIME_SHIPPING self.real_time_shipping_quote(product, accessories, zipcode, quantity) - end + end quote end @@ -63,19 +63,19 @@ def calculate_real_time_shipping(items, zipcode) end shipping_total end - + def self.flat_rate_shipping_quote(product, accessories, zipcode, quantity) quote = product.flat_rate_shipping * quantity specifications = Array.new quote += self.accessory_quote(specifications, accessories, zipcode, product.vendor.zipcode) end - + def self.real_time_shipping_quote(product, accessories, zipcode, quantity) specifications = quantity_specifications(product, quantity) quote = self.accessory_quote(specifications, accessories, zipcode, product.vendor.zipcode) end - + def self.accessory_quote(specifications, accessories, zipcode, vendor_zipcode) quote = 0 accessories.each do |accessory| @@ -84,8 +84,8 @@ def self.accessory_quote(specifications, accessories, zipcode, vendor_zipcode) quote += 0 when ShippingType::FLAT_RATE_SHIPPING quote += accessory.flat_rate_shipping - when ShippingType::REAL_TIME_SHIPPING - # for now we are assuming that only one accessory is added otherwise this will need to + when ShippingType::REAL_TIME_SHIPPING + # for now we are assuming that only one accessory is added otherwise this will need to # do something like quantity.times do... specifications << accessory.specification end @@ -93,12 +93,12 @@ def self.accessory_quote(specifications, accessories, zipcode, vendor_zipcode) quote += self.shipping_quote(specifications, zipcode, vendor_zipcode) unless specifications.empty? quote end - + def self.shipping_quote(specifications, zipcode, vendor_zipcode) packages = build_packages(specifications) quote = quote_packages(packages, zipcode, vendor_zipcode) end - + def self.build_packages(specifications) packages = Array.new specifications.each do |specification| @@ -107,28 +107,28 @@ def self.build_packages(specifications) end packages end - + def self.quote_packages(packages, zipcode, vendor_zipcode) origin = Location.new(:country => 'US', :zip => vendor_zipcode) country = /^\d{5}([\-]\d{4})?$/.match(zipcode)? 'US' : 'CA' destination = Location.new(:country => country, :postal_code => zipcode) - ups = UPS.new(:login => APP_CONFIG['ups_login'], :password => APP_CONFIG['ups_password'], + ups = UPS.new(:login => APP_CONFIG['ups_login'], :password => APP_CONFIG['ups_password'], :key => APP_CONFIG['ups_key']) response = ups.find_rates(origin, destination, packages) quote = response.rates.sort_by(&:price).first.price * 0.01 end - + def self.quantity_specifications(product, quantity) specifications = Array.new - quantity.times do + quantity.times do specification = product.specification specifications << specification end specifications end - + def calculate_shipping_per_vendor(items, zipcode, vendor_zipcode) - # we create a separate package for each quantity of each item + # we create a separate package for each quantity of each item specifications = Array.new shipping_total = 0 items.each do |item| @@ -138,18 +138,18 @@ def calculate_shipping_per_vendor(items, zipcode, vendor_zipcode) shipping_total += 0 when ShippingType::FLAT_RATE_SHIPPING shipping_total += product.flat_rate_shipping - when ShippingType::REAL_TIME_SHIPPING + when ShippingType::REAL_TIME_SHIPPING specifications += ShippingCalculations.quantity_specifications(product, item.quantity) end end - unless specifications.empty? + unless specifications.empty? shipping_total += ShippingCalculations.shipping_quote(specifications, zipcode, vendor_zipcode) end shipping_total end - + def total_weight(items) sum = items.sum {|item| item.quantity * item.product.weight} end - + end diff --git a/app/lib/shipping_type.rb b/app/lib/shipping_type.rb index 37f67d4..ee90565 100644 --- a/app/lib/shipping_type.rb +++ b/app/lib/shipping_type.rb @@ -3,10 +3,10 @@ class ShippingType FLAT_RATE_SHIPPING = 1 REAL_TIME_SHIPPING = 2 FREE_SHIPPING = 3 - + CONFIGURATION_SHIPPING_TYPES = { 1 => "flat rate shipping" , 2 => "real time shipping"} VENDOR_SHIPPING_TYPES = { 1 => "flat rate shipping" , 2 => "real time shipping", 3 => "free shipping"} - PRODUCT_SHIPPING_TYPES = { 0 => "default vendor shipping", 1 => "flat rate shipping", + PRODUCT_SHIPPING_TYPES = { 0 => "default vendor shipping", 1 => "flat rate shipping", 2 => "real time shipping", 3 => "free shipping" } end \ No newline at end of file diff --git a/app/lib/wholesaler.rb b/app/lib/wholesaler.rb index 6a1eeb1..f5f4099 100644 --- a/app/lib/wholesaler.rb +++ b/app/lib/wholesaler.rb @@ -1,16 +1,16 @@ module Wholesaler - + def verify_wholesaler @is_wholesaler = false - unless session[:wholesaler] == nil + unless session[:wholesaler] == nil @is_wholesaler = true - end + end @is_wholesaler end - + def download_file send_file("public/TestingDownload.txt", :disposition => "attachment") end - - + + end \ No newline at end of file diff --git a/app/models/cart.rb b/app/models/cart.rb index d6b45c9..a44aa83 100644 --- a/app/models/cart.rb +++ b/app/models/cart.rb @@ -2,29 +2,29 @@ # should be extracted/abstracted out someway to share common impl class Cart < ActiveRecord::Base include ShippingCalculations - + has_many :cart_items, :order => 'product_id, variant_id' has_many :products, :through => :cart_items - + validates_length_of :name, :in => 1..40 - + accepts_nested_attributes_for :cart_items - + attr_accessor :shipping_method_id - + def validate Inventory.new.validate_cart(self) end - + def line_items cart_items end - + # order cart items def ordered_cart_items cart_items.find(:all, :order => 'product_id') end - + def product_total cart_items.inject(0) {|sum, n| n.price * n.quantity + sum} end @@ -32,18 +32,18 @@ def product_total def sub_total product_total - promo_discount end - + # shipping totals def shipping_total(shipping_method) self.shipping_method_id = shipping_method calculate_shipping_costs end - + # calculate total price def grand_total(shipping_total) product_total + shipping_total + tax_total - self.promo_discount end - + # calculate total price in cents def grand_total_in_cents(shipping_total) (sub_total + shipping_total) * 100 @@ -53,9 +53,9 @@ def grand_total_in_cents(shipping_total) # Add the product to the cart with any options selected. # # @param [Integer] product_id Id of product to add. # TODO change to product - # @param [Integer] quantity The number of products to add. - # @param [Array] options List of options that were selected for the product. - # @return [CartItem] The newly created or existing cart item. + # @param [Integer] quantity The number of products to add. + # @param [Array] options List of options that were selected for the product. + # @return [CartItem] The newly created or existing cart item. def add_product(product_id, quantity, options) cart_item = nil Cart.transaction do @@ -67,7 +67,7 @@ def add_product(product_id, quantity, options) end cart_item end - + ## # returns the cart item that matches the product or variant # @@ -78,7 +78,7 @@ def add_product(product_id, quantity, options) def find_product_or_variant(product, variant) cart_items.find(:first, :conditions => { :product_id => product, :variant_id => variant }) end - + def tax_total tax = 0 @@ -89,7 +89,7 @@ def tax_total private ## - # Add a cart item to the cart. + # Add a cart item to the cart. # # @param [CartItem] cart_item An existing cart item or a new one will be created. # @param [Product] product The product to add to the cart. @@ -111,6 +111,6 @@ def add_to_cart(cart_item, product, quantity, variant) end cart_item end - -end + +end diff --git a/app/models/cart_item.rb b/app/models/cart_item.rb index 2eb439b..6bf1656 100644 --- a/app/models/cart_item.rb +++ b/app/models/cart_item.rb @@ -3,26 +3,26 @@ class CartItem < ActiveRecord::Base belongs_to :cart belongs_to :product belongs_to :variant - - has_many :option_selections, + + has_many :option_selections, :class_name => 'CartItemSelection' - - validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0 - - cattr_accessor :discounted - + + validates_numericality_of :quantity, :only_integer => true, :greater_than_or_equal_to => 0 + + cattr_accessor :discounted + def price # take quantity discount into consideration # self.discounted = false # unless @price - # # TODO: if wholesale module + # # TODO: if wholesale module # @price = QuantityDiscount.discounted_price(self) # self.discounted = true if @price != product.price # end # @price self.discounted = false if variant - self.variant.price + self.variant.price else self.product.price end @@ -41,8 +41,8 @@ def valid_quantity(quantity) # default to one quantity <= 0 ? 1 : quantity end - + private - + end end diff --git a/app/models/category_icon.rb b/app/models/category_icon.rb index 6f97aa9..a542314 100644 --- a/app/models/category_icon.rb +++ b/app/models/category_icon.rb @@ -1,10 +1,10 @@ class CategoryIcon < ActiveRecord::Base - + belongs_to :category has_one :category_icon_hover, :dependent => :destroy - + mount_uploader :filename, CategoryIconUploader - + validates_presence_of :filename - + end \ No newline at end of file diff --git a/app/models/category_icon_hover.rb b/app/models/category_icon_hover.rb index 70d6d30..a715ab5 100644 --- a/app/models/category_icon_hover.rb +++ b/app/models/category_icon_hover.rb @@ -1,9 +1,9 @@ class CategoryIconHover < ActiveRecord::Base - + belongs_to :category_icon - + mount_uploader :filename, CategoryIconUploader validates_presence_of :filename - + end \ No newline at end of file diff --git a/app/models/category_image.rb b/app/models/category_image.rb index f25f83b..1ac72ea 100644 --- a/app/models/category_image.rb +++ b/app/models/category_image.rb @@ -1,9 +1,9 @@ class CategoryImage < ActiveRecord::Base - + belongs_to :category - + mount_uploader :filename, ImageUploader - + validates_presence_of :filename - + end \ No newline at end of file diff --git a/app/models/configuration.rb b/app/models/configuration.rb index 9a2c72e..7d0b388 100644 --- a/app/models/configuration.rb +++ b/app/models/configuration.rb @@ -1,3 +1,3 @@ class Configuration < ActiveRecord::Base - + end \ No newline at end of file diff --git a/app/models/fulfilllment_code.rb b/app/models/fulfilllment_code.rb index 64d8bc4..b86d59f 100644 --- a/app/models/fulfilllment_code.rb +++ b/app/models/fulfilllment_code.rb @@ -1,4 +1,4 @@ class FulfillmentCode < ActiveRecord::Base belongs_to :flat_rate_shipping - + end diff --git a/app/models/optimization.rb b/app/models/optimization.rb index 56fc527..a64404e 100644 --- a/app/models/optimization.rb +++ b/app/models/optimization.rb @@ -1,3 +1,3 @@ class Optimization < ActiveRecord::Base - + end \ No newline at end of file diff --git a/app/models/order_address.rb b/app/models/order_address.rb index d11790f..10e1f4e 100644 --- a/app/models/order_address.rb +++ b/app/models/order_address.rb @@ -1,9 +1,9 @@ class OrderAddress < ActiveRecord::Base - + validates_length_of :address_1, :in => 2..50 validates_length_of :city, :in => 2..50 validates_length_of :state, :is => 2 validates_format_of :postal_code, :with => /^\d{5}([\-]\d{4})?$/, :message => 'should be in the format "12345" or "12345-1234"' - + end diff --git a/app/models/order_item_selection.rb b/app/models/order_item_selection.rb index 6f8d2e6..fb308a1 100644 --- a/app/models/order_item_selection.rb +++ b/app/models/order_item_selection.rb @@ -1,16 +1,16 @@ class OrderItemSelection < ActiveRecord::Base belongs_to :order_item - - + + def self.from_product_option_selection(product_option_selection) ois = self.new - + ois.product_option_name = product_option_selection.product_option.name ois.option_selection_name = product_option_selection.name ois.price_adjustment = product_option_selection.price_adjustment ois.weight_adjustment = product_option_selection.weight_adjustment - ois.sku_adjustment = product_option_selection.sku_adjustment - + ois.sku_adjustment = product_option_selection.sku_adjustment + ois end end diff --git a/app/models/out_of_stock_option.rb b/app/models/out_of_stock_option.rb index 6212dec..7bac0d1 100644 --- a/app/models/out_of_stock_option.rb +++ b/app/models/out_of_stock_option.rb @@ -1,34 +1,34 @@ class OutOfStockOption < ActiveRecord::Base - + belongs_to :product has_many :out_of_stock_option_selections, :dependent => :destroy - + def self.out_of_stock?(product_id, product_option_selection_ids) # first find all the product_options with that product_id and include # and preload the selections - out_of_stock_options = + out_of_stock_options = OutOfStockOption.find(:all, :conditions => { :product_id => product_id }, - :include => :out_of_stock_option_selections ) + :include => :out_of_stock_option_selections ) selection_found = false - + # now generate an array of product_option_selection_ids for each out_of_stock # product and compare with the passed selection array. out_of_stock_options.each do |item| out_of_stock_option_selection_ids = Array.new - item.out_of_stock_option_selections.each do |selection| - out_of_stock_option_selection_ids << + item.out_of_stock_option_selections.each do |selection| + out_of_stock_option_selection_ids << selection.product_option_selection_id.to_s end - if out_of_stock_option_selection_ids.sort == + if out_of_stock_option_selection_ids.sort == product_option_selection_ids.sort selection_found = true end end - + selection_found end - + # return all the out of stock selections as a concated string def out_of_stock_selection_string out_of_stock_option_selections.collect { |x| x.product_option_selection.name + ', ' } diff --git a/app/models/product_accessory.rb b/app/models/product_accessory.rb index fddbd61..d9756d6 100644 --- a/app/models/product_accessory.rb +++ b/app/models/product_accessory.rb @@ -1,19 +1,19 @@ class ProductAccessory < ActiveRecord::Base - + belongs_to :product belongs_to :accessory, :class_name => 'Product' has_many :cart_items - + def name accessory.name end - + def price accessory.accessory_price(product) end - + # finds accessories from the crazy hash generated by the combined products/_product_accessories - # and products/_accessory_options views. An accessories_hash for a selected_accessory id 82 with + # and products/_accessory_options views. An accessories_hash for a selected_accessory id 82 with # an option selection of id 45 looks like this: {"82"=>{"options"=>"45", "82"=>"1"}} def self.selected_accessories(accessories_hash) selected_accessories = Array.new @@ -22,7 +22,7 @@ def self.selected_accessories(accessories_hash) accessory = Product.find(k.to_i) selected_accessories << accessory end - end + end selected_accessories - end + end end \ No newline at end of file diff --git a/app/models/product_option_instance.rb b/app/models/product_option_instance.rb index 72ba0d0..04a7c7d 100644 --- a/app/models/product_option_instance.rb +++ b/app/models/product_option_instance.rb @@ -1,13 +1,13 @@ class ProductOptionInstance < ActiveRecord::Base - belongs_to :product_option + belongs_to :product_option belongs_to :product - + after_create :regenerate_product_variants after_destroy :regenerate_product_variants - - + + def regenerate_product_variants self.product.generate_variants end - + end diff --git a/app/models/product_option_selection.rb b/app/models/product_option_selection.rb index 67665ca..a33370c 100644 --- a/app/models/product_option_selection.rb +++ b/app/models/product_option_selection.rb @@ -2,22 +2,22 @@ class ProductOptionSelection < ActiveRecord::Base belongs_to :product_option has_many :variant_selections has_many :variants, :through => :variant_selections, :dependent => :destroy - + has_many :images, :class_name => 'ProductOptionSelectionImage' - + after_create :generate_product_variants after_update :update_variants - - - def product + + + def product self.product_option.products.first - end - + end + ## # generates all the selection variation variants for the selection's product def generate_product_variants # the associated product does not yet exist when the product option is first created - # we do not want to generate variants in such a case since they will be created by the + # we do not want to generate variants in such a case since they will be created by the # product_option_instance callback later unless product.nil? selection_id_arrays = [[self.id]] @@ -28,16 +28,16 @@ def generate_product_variants product.generate_variants_from_selection_ids(selection_id_arrays) end end - + ## # updates the weight and price of the selection's variants if the adjustments have changed def update_variants - if price_adjustment_changed? + if price_adjustment_changed? self.variants.each {|v| v.update_price} end if weight_adjustment_changed? self.variants.each {|v| v.update_weight} end end - + end diff --git a/app/models/product_variant.rb b/app/models/product_variant.rb index 9171e76..85d8e44 100644 --- a/app/models/product_variant.rb +++ b/app/models/product_variant.rb @@ -9,7 +9,7 @@ module ProductVariant def has_variants !self.variants.empty? end - + ## # Returns either the price of the product or for the first variant as ordered by product_options' # selections' default order @@ -22,7 +22,7 @@ def product_or_first_variant_price price end end - + ## # Returns first variant as ordered by product_options' selections' default order # @@ -31,7 +31,7 @@ def first_variant selection_ids = self.product_options.map { |o| o.product_option_selections.first.id } find_variant_by_selection_ids(selection_ids) end - + ## # Returns variant which associates with the Array of product_option_selection ids # @@ -40,7 +40,7 @@ def first_variant def find_variant_by_selection_ids(selection_ids) self.variants.detect{ |v| v.product_option_selection_ids.sort == selection_ids.sort } if selection_ids end - + ## # Regenerates all the variants for the product @@ -53,7 +53,7 @@ def generate_variants end generate_variants_from_selection_ids(selection_id_arrays) end - + ## # Generates variants from the array list of selection ids # @@ -64,7 +64,7 @@ def generate_variants_from_selection_ids(selection_id_arrays) generate_variant(variant_selection_ids) end end - + ## # Generates an variant and the relations to its product_option_selections # @@ -73,19 +73,19 @@ def generate_variant(selection_ids) selections = ProductOptionSelection.find(selection_ids) variant_price = self.price + selections.inject(0){|sum, s| sum + s.price_adjustment } variant_weight = (self.weight || 0) + selections.inject(0){|sum, s| sum + s.weight_adjustment } - variant = self.variants.create(:price => variant_price, :weight => variant_weight, + variant = self.variants.create(:price => variant_price, :weight => variant_weight, :inventory => 0, :sku => self.sku) selections.each do |s| s.variants << variant end end -private - +private + ## # Generates an array of array objects that are a cartesian product of a list of array objects # e.g. [1,2], [3,4], [5,6]=> [[1,3,5],[1,3,6],[1,4,5],[1,4,6],[2,3,5],[2,3,6],[2,4,5],[2,4,6]] - # + # # @param [Array] args a variable amount of Arrays for the cartesian product def cartprod(*args) result = [[]] diff --git a/app/models/promo_code.rb b/app/models/promo_code.rb index 56a8589..10778d1 100644 --- a/app/models/promo_code.rb +++ b/app/models/promo_code.rb @@ -2,49 +2,49 @@ class PromoCode < ActiveRecord::Base validates_presence_of :name validates_presence_of :code - - attr_accessor :message - + + attr_accessor :message + SUCCESS_MESSAGE = "Promo Code successfully applied, enjoy." NOT_APPLIED_MESSAGE = "Promo Code not applied." MINIMUM_AMOUNT_MESSAGE = "Your order did not reach the minimum amount required of " INVALID_MESSAGE = "This is not a valid promo code, please check and reapply." - + # apply a specific promo code to an order def self.apply(order, promo_code) begin - promo_code = promo_code.upcase + promo_code = promo_code.upcase promo = PromoCode.find_by_code(promo_code) rescue order.promo_code = '' order.free_shipping = false order.promo_discount = '' order.save! - end + end if promo promo.apply(order) else promo = PromoCode.new promo.message = INVALID_MESSAGE end - + promo end - + # apply the promo code to a particular order def apply(order) self.message = INVALID_MESSAGE - + if order.sub_total >= self.minimum_order_amount # order is the minimum amount if self.percent_discount && self.percent_discount > 0 discount = self.calculate_percent_discount(order) else - discount = self.dollar_discount + discount = self.dollar_discount end discount ||= 0 self.message = SUCCESS_MESSAGE - + if order order.promo_code = self.code.upcase order.free_shipping = true if self.free_shipping @@ -54,17 +54,17 @@ def apply(order) else self.message = minimum_amount_required_message end - + self.message end - + def calculate_percent_discount(order) (self.percent_discount / 100) * order.product_total end - + def minimum_amount_required_message MINIMUM_AMOUNT_MESSAGE + '$' + self.minimum_order_amount.to_s end - - + + end diff --git a/app/models/region.rb b/app/models/region.rb index 743d66c..2990661 100644 --- a/app/models/region.rb +++ b/app/models/region.rb @@ -1,12 +1,12 @@ class Region < ActiveRecord::Base has_many :shipping_methods - + # couldn't get :first to work right with has_finder - #has_finder :default_method, + #has_finder :default_method, # :conditions => { :default_selection => true } - + def default_shipping_method shipping_methods.find(:first, :conditions => { :default_selection => true }) end - + end diff --git a/app/models/shipping_method.rb b/app/models/shipping_method.rb index f4de74d..82a731b 100644 --- a/app/models/shipping_method.rb +++ b/app/models/shipping_method.rb @@ -15,7 +15,7 @@ class ShippingMethod < ActiveRecord::Base def is_base_rate? !(GeneralConfiguration.shipping_calculated_by_weight? || is_order_range_flat_rated?) end - + def is_order_range_flat_rated? flat_rate_shippings.select{|rate| !rate.new_record? }.size > 0 end diff --git a/app/models/shipping_provider.rb b/app/models/shipping_provider.rb index 358aec4..d9b875a 100644 --- a/app/models/shipping_provider.rb +++ b/app/models/shipping_provider.rb @@ -1,7 +1,7 @@ -# currently not used +# currently not used class ShippingProvider < ActiveRecord::Base belongs_to :shipping_rate - + has_one :flat_rate_shipping - + end diff --git a/app/models/tax_rate.rb b/app/models/tax_rate.rb index 5a1056c..80c5244 100644 --- a/app/models/tax_rate.rb +++ b/app/models/tax_rate.rb @@ -1,5 +1,5 @@ class TaxRate < ActiveRecord::Base - + def self.calculate_tax(state, sub_total) t = 0 taxrate = TaxRate.find_by_state(state) diff --git a/app/models/user.rb b/app/models/user.rb index 42453c8..c13f825 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -17,14 +17,14 @@ class User < ActiveRecord::Base # anything else you want your user to change should be added here. attr_accessible :login, :email, :password, :password_confirmation attr_accessible :role - - # has_role? simply needs to return true or false whether a user has a role or not. + + # has_role? simply needs to return true or false whether a user has a role or not. # It may be a good idea to have "admin" roles return true always def has_role?(role_in_question) return true if self.role=="admin" self.role == role_in_question.to_s end - + # Authenticates a user by their login name and unencrypted password. Returns the user or nil. def self.authenticate(login, password) u = find_by_login(login) # need to get the salt @@ -46,7 +46,7 @@ def authenticated?(password) end def remember_token? - remember_token_expires_at && Time.now.utc < remember_token_expires_at + remember_token_expires_at && Time.now.utc < remember_token_expires_at end # These create and unset the fields required for remembering users between browser closes @@ -63,13 +63,13 @@ def forget_me end protected - # before filter + # before filter def encrypt_password return if password.blank? self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{login}--") if new_record? self.crypted_password = encrypt(password) end - + def password_required? crypted_password.blank? || !password.blank? end diff --git a/app/models/variant.rb b/app/models/variant.rb index c3f48a4..8304a27 100644 --- a/app/models/variant.rb +++ b/app/models/variant.rb @@ -1,23 +1,23 @@ class Variant < ActiveRecord::Base belongs_to :product - + has_many :variant_selections has_many :product_option_selections, :through => :variant_selections, :order => 'product_option_id' has_many :cart_items has_many :order_items - + belongs_to :variant_image, :dependent => :destroy - + default_scope :order => :id - - + + validates_numericality_of :weight, :greater_than_or_equal_to => 0 validates_numericality_of :price, :greater_than => 0 - validates_numericality_of :inventory, :only_integer => true, :greater_than_or_equal_to => 0 - + validates_numericality_of :inventory, :only_integer => true, :greater_than_or_equal_to => 0 + ## - # updates the weight of the variant by combining product weight with the sum of the + # updates the weight of the variant by combining product weight with the sum of the # adjustments of its option selections def update_weight self.weight = product.weight + product_option_selections.inject(0){|sum, s| sum + s.weight_adjustment } @@ -25,13 +25,13 @@ def update_weight end ## - # updates the price of the variant by combining product price with the sum of the + # updates the price of the variant by combining product price with the sum of the # adjustments of its option selections def update_price self.price = product.price + product_option_selections.inject(0){|sum, s| sum + s.price_adjustment } self.save! end - + def out_of_stock_check if GeneralConfiguration.instance.inventory_management self.inventory <= 0 @@ -39,5 +39,5 @@ def out_of_stock_check self.out_of_stock end end - + end diff --git a/app/models/variant_image.rb b/app/models/variant_image.rb index 97f27f0..cdbc844 100644 --- a/app/models/variant_image.rb +++ b/app/models/variant_image.rb @@ -1,21 +1,21 @@ class VariantImage < ActiveRecord::Base has_many :variants, :dependent => :nullify - + has_one :variant_image_thumbnail, :dependent => :destroy has_one :variant_large_image, :dependent => :destroy mount_uploader :filename, ImageUploader - + def product variants.first.product end - + ## # The url for the variant image. # - # @return [String] The image url for the variant or an empty string if one doesn't exist. + # @return [String] The image url for the variant or an empty string if one doesn't exist. def image_url - self.filename.url + self.filename.url end ## @@ -30,7 +30,7 @@ def thumbnail_url ## # The url for the variant large image. # - # @return [String] The url of the large variant or empty string if one doesn't exist. + # @return [String] The url of the large variant or empty string if one doesn't exist. def large_image_url return '' if self.variant_large_image.blank? self.variant_large_image.filename.url diff --git a/app/notifiers/contact_notifier.rb b/app/notifiers/contact_notifier.rb index 2de8b69..95c209c 100644 --- a/app/notifiers/contact_notifier.rb +++ b/app/notifiers/contact_notifier.rb @@ -1,5 +1,5 @@ class ContactNotifier < ActionMailer::Base - + def contact_confirmation(name, email, phone, extension, comment) recipients APP_CONFIG['support_email'] from APP_CONFIG['contact_email'] @@ -8,6 +8,6 @@ def contact_confirmation(name, email, phone, extension, comment) content_type "text/html" body :name => name, :email => email, :phone => phone, :extension => extension, :comment => comment - end - + end + end \ No newline at end of file diff --git a/app/reports/order_report.rb b/app/reports/order_report.rb index b9623b9..6538846 100644 --- a/app/reports/order_report.rb +++ b/app/reports/order_report.rb @@ -1,23 +1,23 @@ class OrderReport < Ruport::Controller - + stage :list def setup - start_date = options.start_date.empty? ? - Date.parse('2007-01-01') : + start_date = options.start_date.empty? ? + Date.parse('2007-01-01') : Date.parse(options.start_date) - end_date = options.end_date.empty? ? + end_date = options.end_date.empty? ? Date.today : Date.parse(options.end_date) # create range string to grab orders range = "created_at #{(start_date..end_date).to_s(:db)}" - - self.data = Order.report_table(:all, + + self.data = Order.report_table(:all, :only => ['created_at', 'order_number', 'full_name', 'business', 'product_cost', 'shipping_cost'], :methods => [:total], :include => - { + { :shipping_address => { :only => ['state', 'country'] }, :order_items => { :only => ['product_name', 'quantity'], :include => { @@ -30,17 +30,17 @@ def setup "fulfilled"]) if self.data.size > 0 self.data.reorder('created_at', 'order_number', 'full_name', 'business', 'shipping_address.state', - 'shipping_address.country', 'product_cost', 'shipping_cost', - 'total','order_items.quantity', 'product.sku', + 'shipping_address.country', 'product_cost', 'shipping_cost', + 'total','order_items.quantity', 'product.sku', 'order_items.product_name') end self.data.rename_columns('created_at' => 'Order Date', 'order_number' => 'Order Number', 'full_name' => 'Full Name', 'business' => 'Company', 'product_cost' => 'SubTotal', 'shipping_cost' => 'Shipping Cost', - 'product.sku' => 'Sku', + 'product.sku' => 'Sku', 'total' => 'Total', - 'order_items.product_name' => 'Product Name', + 'order_items.product_name' => 'Product Name', 'order_items.quantity' => 'Quantity', 'shipping_address.country' => 'Country', 'shipping_address.state' => 'State') @@ -54,18 +54,18 @@ def setup output << '' end end - + formatter :pdf do build :list do pad(10) { add_text "Orders" } draw_table data end end - + formatter :csv do build :list do output << data.to_csv end end - + end diff --git a/app/views/admin/accessories/_category_selection.html.erb b/app/views/admin/accessories/_category_selection.html.erb index 32a3913..4fb219d 100644 --- a/app/views/admin/accessories/_category_selection.html.erb +++ b/app/views/admin/accessories/_category_selection.html.erb @@ -1,11 +1,11 @@ -<% form_tag(admin_product_accessory_path(@product), :id => 'category_selection_form') do |f| %> +<% form_tag(admin_product_accessory_path(@product), :id => 'category_selection_form') do |f| %> - <% for product in @products %> + <% for product in @products %> @@ -8,4 +8,3 @@ <%= link_to 'add accessory', admin_product_accessories_path(@product), :id => 'add_accessory_link' %> - \ No newline at end of file diff --git a/app/views/admin/accessories/edit.html.erb b/app/views/admin/accessories/edit.html.erb index 200827a..cfe3756 100644 --- a/app/views/admin/accessories/edit.html.erb +++ b/app/views/admin/accessories/edit.html.erb @@ -9,7 +9,7 @@ Select Category of accessory to add
- +
<%= render :partial =>'accessories' %>
diff --git a/app/views/admin/accessories/show.rjs b/app/views/admin/accessories/show.rjs index e4ea79b..935f90a 100644 --- a/app/views/admin/accessories/show.rjs +++ b/app/views/admin/accessories/show.rjs @@ -1 +1 @@ -page[:product_list].replace_html :partial => 'product_list' +page[:product_list].replace_html :partial => 'product_list' diff --git a/app/views/admin/authorizations/update.rjs b/app/views/admin/authorizations/update.rjs index 83cfdc8..9d5cbc4 100644 --- a/app/views/admin/authorizations/update.rjs +++ b/app/views/admin/authorizations/update.rjs @@ -1,4 +1,4 @@ - + page[:post_authorize].hide -page[:order_transactions].replace_html :partial => 'admin/orders/order_transactions', +page[:order_transactions].replace_html :partial => 'admin/orders/order_transactions', :object => @order \ No newline at end of file diff --git a/app/views/admin/categories/_category_selection.html.erb b/app/views/admin/categories/_category_selection.html.erb index 4abdb1f..f81b179 100644 --- a/app/views/admin/categories/_category_selection.html.erb +++ b/app/views/admin/categories/_category_selection.html.erb @@ -1,22 +1,22 @@ - +

diff --git a/app/views/admin/categories/_icon_form.html.erb b/app/views/admin/categories/_icon_form.html.erb index 3a400b1..f063299 100644 --- a/app/views/admin/categories/_icon_form.html.erb +++ b/app/views/admin/categories/_icon_form.html.erb @@ -1,5 +1,5 @@
- + <% form_for [:admin, category, CategoryIcon.new], :html => { :multipart => true, :id => 'category_icon_add' } do |form| %>

diff --git a/app/views/admin/categories/_icon_hover.html.erb b/app/views/admin/categories/_icon_hover.html.erb index 4b3d530..8f43141 100644 --- a/app/views/admin/categories/_icon_hover.html.erb +++ b/app/views/admin/categories/_icon_hover.html.erb @@ -1,7 +1,7 @@ <% if icon.category_icon_hover %>

<%= image_tag icon.category_icon_hover.filename.url %> - <%= link_to 'Remove Image', admin_category_icon_category_icon_hover_path(icon, icon.category_icon_hover), + <%= link_to 'Remove Image', admin_category_icon_category_icon_hover_path(icon, icon.category_icon_hover), :id => "destroy-category-icon-hover" %>
<% else %> diff --git a/app/views/admin/categories/_icon_list.html.erb b/app/views/admin/categories/_icon_list.html.erb index 7539347..8b8ce69 100644 --- a/app/views/admin/categories/_icon_list.html.erb +++ b/app/views/admin/categories/_icon_list.html.erb @@ -1,6 +1,6 @@
<%= image_tag icon.filename.url %> - <%= link_to 'Remove Image', admin_category_category_icon_path(category, icon), + <%= link_to 'Remove Image', admin_category_category_icon_path(category, icon), :class => "destroy-category-icon" %>


diff --git a/app/views/admin/categories/_image_form.html.erb b/app/views/admin/categories/_image_form.html.erb index a3a9ebb..92699f3 100644 --- a/app/views/admin/categories/_image_form.html.erb +++ b/app/views/admin/categories/_image_form.html.erb @@ -1,5 +1,5 @@
- + <% form_for [:admin, category, CategoryImage.new], :html => { :multipart => true, :id => 'category_image_add' } do |form| %>

diff --git a/app/views/admin/categories/_image_list.html.erb b/app/views/admin/categories/_image_list.html.erb index 47d5833..510e5d2 100644 --- a/app/views/admin/categories/_image_list.html.erb +++ b/app/views/admin/categories/_image_list.html.erb @@ -4,7 +4,7 @@ <% category.category_images.each do |image| %>

<%= image_tag image.filename.url %> - <%= link_to 'Remove Image', admin_category_category_image_path(category, image), + <%= link_to 'Remove Image', admin_category_category_image_path(category, image), :class => "destroy-category-image" %>
<% end %> diff --git a/app/views/admin/categories/edit.html.erb b/app/views/admin/categories/edit.html.erb index 0e8b289..ca6bc61 100644 --- a/app/views/admin/categories/edit.html.erb +++ b/app/views/admin/categories/edit.html.erb @@ -1,6 +1,6 @@ <%= javascript('pebbles/jquery/form', 'pebbles/jquery/livequery') %> -<%= link_to "Delete the Category '#{@category.name}'", admin_category_path(@category), +<%= link_to "Delete the Category '#{@category.name}'", admin_category_path(@category), :confirm => "Are you sure you want to delete the category #{@category.name}?", :method => :delete %>

<%= render 'form', :category => @category %> diff --git a/app/views/admin/configurations/_details.html.erb b/app/views/admin/configurations/_details.html.erb index 8ef2035..6548ebb 100644 --- a/app/views/admin/configurations/_details.html.erb +++ b/app/views/admin/configurations/_details.html.erb @@ -3,7 +3,7 @@ <% form_for :configuration, @configuration, :url => admin_configuration_path(1), :html => { :method => :put } do |form| %>

- <%= form.select :shipping_type || 1, ShippingType::CONFIGURATION_SHIPPING_TYPES.invert %>
+ <%= form.select :shipping_type || 1, ShippingType::CONFIGURATION_SHIPPING_TYPES.invert %>
<%= submit_tag "Update" %>

<% end %> \ No newline at end of file diff --git a/app/views/admin/configurations/edit.html.erb b/app/views/admin/configurations/edit.html.erb index 271448e..392b1e1 100644 --- a/app/views/admin/configurations/edit.html.erb +++ b/app/views/admin/configurations/edit.html.erb @@ -13,7 +13,7 @@

Details

<%= render :partial => "details", :locals => { :configuration => @configuration}%> -
+
-<%= link_to 'Show', admin_configurations_path %> +<%= link_to 'Show', admin_configurations_path %> diff --git a/app/views/admin/optimizations/_details.html.erb b/app/views/admin/optimizations/_details.html.erb index f32be1e..c50cd23 100644 --- a/app/views/admin/optimizations/_details.html.erb +++ b/app/views/admin/optimizations/_details.html.erb @@ -3,7 +3,7 @@ <% form_for :optimization, @optimization, :url => admin_optimization_path(1), :html => { :method => :put } do |form| %>

- <%= form.text_field :title, :size => 20 %>
+ <%= form.text_field :title, :size => 20 %>
<%= form.text_area :keywords, :rows => 10 %>
diff --git a/app/views/admin/optimizations/edit.html.erb b/app/views/admin/optimizations/edit.html.erb index 464b75d..bc0a010 100644 --- a/app/views/admin/optimizations/edit.html.erb +++ b/app/views/admin/optimizations/edit.html.erb @@ -13,7 +13,7 @@

Details

<%= render :partial => "details", :locals => { :optimization => @optimization}%> -
+ -<%= link_to 'Show', admin_optimizations_path %> +<%= link_to 'Show', admin_optimizations_path %> diff --git a/app/views/admin/order_items/destroy.rjs b/app/views/admin/order_items/destroy.rjs index 11c1651..b296aa0 100644 --- a/app/views/admin/order_items/destroy.rjs +++ b/app/views/admin/order_items/destroy.rjs @@ -1,7 +1,7 @@ -page[:order_totals].replace_html :partial => "admin/orders/order_totals", +page[:order_totals].replace_html :partial => "admin/orders/order_totals", :object => @order - -page[:order_items].replace_html :partial => "admin/orders/edit_order_items", - :object => @order + +page[:order_items].replace_html :partial => "admin/orders/edit_order_items", + :object => @order diff --git a/app/views/admin/order_items/update.rjs b/app/views/admin/order_items/update.rjs index f2159bb..cb6c045 100644 --- a/app/views/admin/order_items/update.rjs +++ b/app/views/admin/order_items/update.rjs @@ -1,6 +1,6 @@ -page[:order_totals].replace_html :partial => "admin/orders/order_totals", +page[:order_totals].replace_html :partial => "admin/orders/order_totals", :object => @order - -page[:order_items].replace_html :partial => "admin/orders/edit_order_items", - :object => @order + +page[:order_items].replace_html :partial => "admin/orders/edit_order_items", + :object => @order diff --git a/app/views/admin/orders/_delivery_status.html.erb b/app/views/admin/orders/_delivery_status.html.erb index aee75e7..63dc130 100644 --- a/app/views/admin/orders/_delivery_status.html.erb +++ b/app/views/admin/orders/_delivery_status.html.erb @@ -1,6 +1,6 @@ <%= select_tag( "delivery_status_#{order.id}", - options_for_select(OrderDeliveryStatus::LIST, order.delivery_status), + options_for_select(OrderDeliveryStatus::LIST, order.delivery_status), :class => "delivery_status" ) %> diff --git a/app/views/admin/orders/_edit_order_items.html.erb b/app/views/admin/orders/_edit_order_items.html.erb index 025e513..784a4e4 100644 --- a/app/views/admin/orders/_edit_order_items.html.erb +++ b/app/views/admin/orders/_edit_order_items.html.erb @@ -16,9 +16,9 @@ <%= text_field_tag 'quantity', order_item.quantity.to_s, :size => 3 %> - <%= link_to_remote 'Update', - { :url => admin_order_item_path(order_item), - :method => :put, + <%= link_to_remote 'Update', + { :url => admin_order_item_path(order_item), + :method => :put, :submit => dom_id(order_item) } %> @@ -36,9 +36,9 @@ <%= number_to_currency(order_item.price * order_item.quantity) %> - <%= link_to_remote 'Remove', - { :url => admin_order_item_path(order_item), - :confirm => "Are you sure you want to remove #{order_item.product_name}?", + <%= link_to_remote 'Remove', + { :url => admin_order_item_path(order_item), + :confirm => "Are you sure you want to remove #{order_item.product_name}?", :method => :delete } %> <% end %> @@ -47,5 +47,5 @@ SubTotal: <%= number_to_currency(@order.product_cost) %>
- + diff --git a/app/views/admin/orders/_order_transactions.html.erb b/app/views/admin/orders/_order_transactions.html.erb index b8b5e4f..37decc1 100644 --- a/app/views/admin/orders/_order_transactions.html.erb +++ b/app/views/admin/orders/_order_transactions.html.erb @@ -3,7 +3,7 @@ Transactions
<% end %> - \ No newline at end of file diff --git a/app/views/admin/product_options/_option_selection_form.html.erb b/app/views/admin/product_options/_option_selection_form.html.erb index 8cb287d..fbeaad9 100644 --- a/app/views/admin/product_options/_option_selection_form.html.erb +++ b/app/views/admin/product_options/_option_selection_form.html.erb @@ -2,31 +2,31 @@ - <%= option_selection.text_field :name, :size => 20, + <%= option_selection.text_field :name, :size => 20, :class => 'gt-form-text' %>
- <%= option_selection.text_field :price_adjustment, :size => 20, + <%= option_selection.text_field :price_adjustment, :size => 20, :class => 'gt-form-text' %>
- <%= option_selection.text_field :weight_adjustment, :size => 20, + <%= option_selection.text_field :weight_adjustment, :size => 20, :class => 'gt-form-text' %>
- <%= option_selection.text_field :sku_adjustment, :size => 20, + <%= option_selection.text_field :sku_adjustment, :size => 20, :class => 'gt-form-text' %>
<% end %> <% if product_option_selection.new_record? %>

- <%= link_to_remote "Add New Selection", + <%= link_to_remote "Add New Selection", :submit => 'selection_form', - :url => { :action => 'add_option_selection', + :url => { :action => 'add_option_selection', :controller => 'product_options' } %> <% else %> <%= render :partial => '/admin/product_options/option_selection_images', :locals => { :option_selection => product_option_selection } %>

- <%= link_to_remote "Save Selection", + <%= link_to_remote "Save Selection", :submit => 'selection_form', - :url => { :action => 'edit_option_selection', + :url => { :action => 'edit_option_selection', :controller => 'product_options' } %> <% end %> diff --git a/app/views/admin/product_options/_option_selection_image_form.html.erb b/app/views/admin/product_options/_option_selection_image_form.html.erb index 15d6592..f276b6a 100644 --- a/app/views/admin/product_options/_option_selection_image_form.html.erb +++ b/app/views/admin/product_options/_option_selection_image_form.html.erb @@ -1,8 +1,8 @@
- <% form_for :option_selection_image, - :url => { :action => 'add_option_selection_image', + <% form_for :option_selection_image, + :url => { :action => 'add_option_selection_image', :controller => 'product_options', - :id => option_selection.id }, + :id => option_selection.id }, :html => { :multipart => true, :target => 'option_upload_frame' } do |form| %> <%= form.file_field :uploaded_data, :value => "Browse", :size => 15 %>
diff --git a/app/views/admin/product_options/_option_selection_image_list.html.erb b/app/views/admin/product_options/_option_selection_image_list.html.erb index c6dfb90..29b4003 100644 --- a/app/views/admin/product_options/_option_selection_image_list.html.erb +++ b/app/views/admin/product_options/_option_selection_image_list.html.erb @@ -3,10 +3,10 @@
<%= image_tag image.filename.url, :name => "image_id" %> - <%= link_to_remote 'Remove Image', :submit => dom_id(image, 'id'), + <%= link_to_remote 'Remove Image', :submit => dom_id(image, 'id'), :update => 'image_list', - :confirm => "Are you sure you want to remove the image?", - :url => { :action => 'remove_option_selection_image', + :confirm => "Are you sure you want to remove the image?", + :url => { :action => 'remove_option_selection_image', :id => option_selection.id } %>
<% end %> diff --git a/app/views/admin/product_options/_option_selection_images.html.erb b/app/views/admin/product_options/_option_selection_images.html.erb index 05c543c..a99c288 100644 --- a/app/views/admin/product_options/_option_selection_images.html.erb +++ b/app/views/admin/product_options/_option_selection_images.html.erb @@ -1,8 +1,8 @@ <%= error_messages_for :option_selection_image %> -<%= render :partial => '/admin/product_options/option_selection_image_form', +<%= render :partial => '/admin/product_options/option_selection_image_form', :locals => { :option_selection => option_selection } -%>
- <%= render :partial => '/admin/product_options/option_selection_image_list', + <%= render :partial => '/admin/product_options/option_selection_image_list', :locals => { :option_selection => option_selection } -%>
diff --git a/app/views/admin/product_options/_option_selection_list.html.erb b/app/views/admin/product_options/_option_selection_list.html.erb index 5960227..74b33ca 100644 --- a/app/views/admin/product_options/_option_selection_list.html.erb +++ b/app/views/admin/product_options/_option_selection_list.html.erb @@ -1,4 +1,4 @@ -<% if product_option.product_option_selections.size > 0 %> +<% if product_option.product_option_selections.size > 0 %>

Current Selections:


@@ -24,15 +24,15 @@ <%= selection.sku_adjustment %> - <%= link_to_remote "Edit", + <%= link_to_remote "Edit", :with => "'product_option_id=' + #{product_option.id} + '&product_id=' + #{product.id}", :method => 'get', :url => { :action => 'edit_option_selection', :controller => 'product_options', :id => selection.id } %> - <%= link_to_remote 'Remove', :submit => dom_id(selection, 'id'), - :confirm => "Are you sure you want to remove the option #{selection.name}", + <%= link_to_remote 'Remove', :submit => dom_id(selection, 'id'), + :confirm => "Are you sure you want to remove the option #{selection.name}", :url => { :action => 'remove_option_selection' } %> <% end %> diff --git a/app/views/admin/product_options/_product_option_select.html.erb b/app/views/admin/product_options/_product_option_select.html.erb index 90b9a28..a487b59 100644 --- a/app/views/admin/product_options/_product_option_select.html.erb +++ b/app/views/admin/product_options/_product_option_select.html.erb @@ -1,6 +1,6 @@ -<%= collection_select 'product_option', :id, available_options, - :id, :name %> -<%= link_to_remote "Select Option", +<%= collection_select 'product_option', :id, available_options, + :id, :name %> +<%= link_to_remote "Select Option", :submit => 'product_option_select', :method => 'get', :url => { :action => 'edit', diff --git a/app/views/admin/product_options/add_option_selection.rjs b/app/views/admin/product_options/add_option_selection.rjs index 5524052..0325668 100644 --- a/app/views/admin/product_options/add_option_selection.rjs +++ b/app/views/admin/product_options/add_option_selection.rjs @@ -1,14 +1,14 @@ -page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', +page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', :locals => { :product_option => @product_option, :product => @product } -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, :product => @product, :product_option_selection => @selection } - -page[dom_id(@selection, 'name')].visual_effect :highlight, :duration => 3 -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } - +page[dom_id(@selection, 'name')].visual_effect :highlight, :duration => 3 + +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } + diff --git a/app/views/admin/product_options/apply_option_to_product.rjs b/app/views/admin/product_options/apply_option_to_product.rjs index 5a5faf6..4924d02 100644 --- a/app/views/admin/product_options/apply_option_to_product.rjs +++ b/app/views/admin/product_options/apply_option_to_product.rjs @@ -1,13 +1,13 @@ -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } -page[dom_id(@product_option, 'name')].visual_effect :highlight, :duration => 3 +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } +page[dom_id(@product_option, 'name')].visual_effect :highlight, :duration => 3 page[:product_option_selections].show - -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', + +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, - :product => @product } - + :product => @product } + page[:product_option_select].replace_html :partial => '/admin/product_options/product_option_select', :locals => { :product => @product, :available_options => @available_options } \ No newline at end of file diff --git a/app/views/admin/product_options/create.rjs b/app/views/admin/product_options/create.rjs index 766bc70..ba25209 100644 --- a/app/views/admin/product_options/create.rjs +++ b/app/views/admin/product_options/create.rjs @@ -1,14 +1,14 @@ -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } -page[dom_id(@product_option, 'name')].visual_effect :highlight, :duration => 3 +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } +page[dom_id(@product_option, 'name')].visual_effect :highlight, :duration => 3 page[:product_option_selections].show - -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', + +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, :product => @product, - :product_option_selection => @product_option_selection } - + :product_option_selection => @product_option_selection } + #page[:product_option_select].replace_html :partial => '/admin/product_options/product_option_select', # :locals => { :product => @product, # :available_options => @available_options } \ No newline at end of file diff --git a/app/views/admin/product_options/destroy.rjs b/app/views/admin/product_options/destroy.rjs index ab560df..f84176e 100644 --- a/app/views/admin/product_options/destroy.rjs +++ b/app/views/admin/product_options/destroy.rjs @@ -1,6 +1,6 @@ -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } - +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } + #page[:product_option_select].replace_html :partial => 'product_option_select', # :locals => { :product => @product, # :available_options => @available_options } \ No newline at end of file diff --git a/app/views/admin/product_options/edit.rjs b/app/views/admin/product_options/edit.rjs index 5d3caf8..6065c33 100644 --- a/app/views/admin/product_options/edit.rjs +++ b/app/views/admin/product_options/edit.rjs @@ -1,15 +1,15 @@ page[:options_form].replace_html :partial => '/admin/product_options/options_form', :locals => { :product_option => @product_option, :product => @product } - + page[:product_option_selections].show -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, :product => @product, :product_option_selection => ProductOptionSelection.new } - -page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', + +page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', :locals => { :product_option => @product_option, :product => @product } \ No newline at end of file diff --git a/app/views/admin/product_options/edit_option_selection.rjs b/app/views/admin/product_options/edit_option_selection.rjs index aeb6854..e90c8b7 100644 --- a/app/views/admin/product_options/edit_option_selection.rjs +++ b/app/views/admin/product_options/edit_option_selection.rjs @@ -2,5 +2,4 @@ page[:selection_form].replace_html :partial => '/admin/product_options/option_se :locals => { :product_option_selection => @option_selection, :product => @product, :product_option => @product_option } - - \ No newline at end of file + diff --git a/app/views/admin/product_options/remove_option_selection.rjs b/app/views/admin/product_options/remove_option_selection.rjs index 442a78c..eb34c30 100644 --- a/app/views/admin/product_options/remove_option_selection.rjs +++ b/app/views/admin/product_options/remove_option_selection.rjs @@ -1,12 +1,12 @@ -page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', +page[:selection_list].replace_html :partial => '/admin/product_options/option_selection_list', :locals => { :product_option => @product_option, :product => @product } -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, :product => @product, :product_option_selection => @selection } -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } - +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } + diff --git a/app/views/admin/product_options/update.rjs b/app/views/admin/product_options/update.rjs index def969b..06e5c96 100644 --- a/app/views/admin/product_options/update.rjs +++ b/app/views/admin/product_options/update.rjs @@ -1,9 +1,9 @@ -page[:option_list].replace_html :partial => '/admin/product_options/option_list', - :locals => { :product => @product } +page[:option_list].replace_html :partial => '/admin/product_options/option_list', + :locals => { :product => @product } page[:product_option_selections].show - -page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', + +page[:selection_form].replace_html render :partial => '/admin/product_options/option_selection_form', :locals => { :product_option => @product_option, :product => @product, :product_option_selection => ProductOptionSelection.new } diff --git a/app/views/admin/products/_categories.html.erb b/app/views/admin/products/_categories.html.erb index 1a4a0f4..3a45eb8 100644 --- a/app/views/admin/products/_categories.html.erb +++ b/app/views/admin/products/_categories.html.erb @@ -1,9 +1,9 @@

Category:

- <%= select_tag 'category_ids[]', - options_for_select(nested_set_options(Category.root.children) do - |i| raw("#{'  ' * (i.level - 1)} #{i.name}") - end, + <%= select_tag 'category_ids[]', + options_for_select(nested_set_options(Category.root.children) do + |i| raw("#{'  ' * (i.level - 1)} #{i.name}") + end, :disabled => @product.category_ids), :id => 'category_select' %> <%= link_to "Add Category", admin_product_path(@product), :id => 'add_category' %> diff --git a/app/views/admin/products/_details.html.erb b/app/views/admin/products/_details.html.erb index c189878..aa00deb 100644 --- a/app/views/admin/products/_details.html.erb +++ b/app/views/admin/products/_details.html.erb @@ -6,16 +6,16 @@ <%= form.text_field :name, :size => 20 %>
<%= form.text_field :subname, :size => 10 %>
-
+
<%= form.check_box :available %> Available
<%= form.check_box :is_featured %> Featured Product
- <%= form.select :shipping_type || 1, ShippingType::PRODUCT_SHIPPING_TYPES.invert %>
+ <%= form.select :shipping_type || 1, ShippingType::PRODUCT_SHIPPING_TYPES.invert %>
<%= form.text_field :flat_rate_shipping, :size => 10 %>

- <%= form.text_field :sku, :size => 10 %>
+ <%= form.text_field :sku, :size => 10 %>
<%= form.text_field :price, :size => 10 %> @@ -26,7 +26,7 @@ <%= form.text_field :width, :size => 10, :class => 'gt-form-text' %> <%= form.text_field :height, :size => 10, :class => 'gt-form-text' %> -
+
<%= form.collection_select :vendor_id, @vendors, :id, :name %>

@@ -35,9 +35,9 @@
<%= form.text_area :admin_notes, :rows => 10 %>
- +
- +


<%= submit_tag "Create" %> diff --git a/app/views/admin/products/_optimizations.html.erb b/app/views/admin/products/_optimizations.html.erb index 026be9c..2a17831 100644 --- a/app/views/admin/products/_optimizations.html.erb +++ b/app/views/admin/products/_optimizations.html.erb @@ -1,23 +1,23 @@ <% form_for :product, @product, :url => admin_product_url(@product.id), :html => { :class => 'gt-form', :method => :put } do |form| %> -

These fields help with Search Engine Optimization. - +

These fields help with Search Engine Optimization. +


- + <%= form.text_field :title, :class => 'gt-form-text' %>
- <%= form.text_area :keywords, :rows => 3, + <%= form.text_area :keywords, :rows => 3, :cols => 90, :class => 'gt-form-textarea' %>
- <%= form.text_area :description, :rows => 6, + <%= form.text_area :description, :rows => 6, :cols => 90, :class => 'gt-form-textarea' %>

- <%= image_submit_tag 'gt/btn-save.jpg', :class => 'gt-submit-btn' %> + <%= image_submit_tag 'gt/btn-save.jpg', :class => 'gt-submit-btn' %>

- +

- - + + <% end %> \ No newline at end of file diff --git a/app/views/admin/products/_variant_image.html.erb b/app/views/admin/products/_variant_image.html.erb index 8720746..6a8fa4b 100644 --- a/app/views/admin/products/_variant_image.html.erb +++ b/app/views/admin/products/_variant_image.html.erb @@ -1,5 +1,5 @@ <% if variant_image.new_record? %> - <% form_for [:admin, variant_image], + <% form_for [:admin, variant_image], :html => { :multipart => true, :id => 'variant_image_add' } do |form|%>

@@ -14,7 +14,7 @@

Regular Size:


<%= image_tag variant_image.filename.url %> - <%= link_to 'Remove Variant Image', admin_variant_image_path(variant_image), + <%= link_to 'Remove Variant Image', admin_variant_image_path(variant_image), :class => "destroy-variant-image" %>
diff --git a/app/views/admin/products/_variant_large_image.html.erb b/app/views/admin/products/_variant_large_image.html.erb index 65c4a40..fe30d05 100644 --- a/app/views/admin/products/_variant_large_image.html.erb +++ b/app/views/admin/products/_variant_large_image.html.erb @@ -1,5 +1,5 @@ <% if large_image.new_record? %> - <% form_for [:admin, variant_image, large_image], + <% form_for [:admin, variant_image, large_image], :html => { :multipart => true, :id => 'variant_image_large_add' } do |form| %>

@@ -13,7 +13,7 @@

Large Image:


<%= image_tag large_image.filename.url %> - <%= link_to 'Remove Large Image', admin_variant_image_variant_large_image_path(variant_image, large_image), + <%= link_to 'Remove Large Image', admin_variant_image_variant_large_image_path(variant_image, large_image), :class => "destroy-variant-large-image" %>
<% end %> \ No newline at end of file diff --git a/app/views/admin/products/_variant_thumbnail.html.erb b/app/views/admin/products/_variant_thumbnail.html.erb index 58e6171..d88e6f5 100644 --- a/app/views/admin/products/_variant_thumbnail.html.erb +++ b/app/views/admin/products/_variant_thumbnail.html.erb @@ -1,5 +1,5 @@ <% if thumbnail.new_record? %> - <% form_for [:admin, variant_image, thumbnail], + <% form_for [:admin, variant_image, thumbnail], :html => { :multipart => true, :id => 'variant_thumbnail_add' } do |form| %>

@@ -13,7 +13,7 @@

Thumbnail:


<%= image_tag thumbnail.filename.url %> - <%= link_to 'Remove Thumbnail Image', admin_variant_image_variant_image_thumbnail_path(variant_image, thumbnail), + <%= link_to 'Remove Thumbnail Image', admin_variant_image_variant_image_thumbnail_path(variant_image, thumbnail), :class => "destroy-variant-thumbnail" %>
<% end %> \ No newline at end of file diff --git a/app/views/admin/products/_variants.html.erb b/app/views/admin/products/_variants.html.erb index 02d7b92..ca8b625 100644 --- a/app/views/admin/products/_variants.html.erb +++ b/app/views/admin/products/_variants.html.erb @@ -27,7 +27,7 @@ <% variant.product_option_selections.each do |selection| %> <%= selection.name %> <% end %> - + <% if inventory_managed? %> <%= variant_form.text_field :inventory, :size => 5 %> @@ -42,10 +42,10 @@ <%= check_box_tag "variant_checkbox", variant.id, false, :class => "variant_image_upload" %> <% if variant.variant_image %> <%= link_to image_tag(variant.variant_image.filename.url, :height => 30), - admin_variant_image_path(variant.variant_image), + admin_variant_image_path(variant.variant_image), :class => 'show-variant-image' %> - <%= link_to 'Remove', admin_variant_path(variant), - :class => "remove-variant-image" %> + <%= link_to 'Remove', admin_variant_path(variant), + :class => "remove-variant-image" %> <% end %> @@ -56,8 +56,8 @@ <% end %> - -
+ +
<%= render "admin/products/variant_image", :variant_image => variant_image %>
\ No newline at end of file diff --git a/app/views/admin/products/add_to_category.rjs b/app/views/admin/products/add_to_category.rjs index 51e5625..e83b664 100644 --- a/app/views/admin/products/add_to_category.rjs +++ b/app/views/admin/products/add_to_category.rjs @@ -1,5 +1,5 @@ -page[:category_list].replace_html :partial => "category_list", +page[:category_list].replace_html :partial => "category_list", :locals => { :product_id => @product.id, :categories => @product.categories } diff --git a/app/views/admin/products/faux_products/_faux_products.html.erb b/app/views/admin/products/faux_products/_faux_products.html.erb index c2b8af1..f00f374 100644 --- a/app/views/admin/products/faux_products/_faux_products.html.erb +++ b/app/views/admin/products/faux_products/_faux_products.html.erb @@ -28,8 +28,8 @@ - <%= link_to 'Destroy', admin_product_faux_product_path(@product), - :confirm => "Are you sure you want to delete #{ faux_product.name } ?", + <%= link_to 'Destroy', admin_product_faux_product_path(@product), + :confirm => "Are you sure you want to delete #{ faux_product.name } ?", :method => :delete %>
@@ -43,7 +43,7 @@

Faux Description:

<% form_for :product, @product, :url => admin_product_url(@product), :html => { :class => 'gt-form', :method => :put } do |form| %> - <%= form.text_area :faux_description, :rows => 30, + <%= form.text_area :faux_description, :rows => 30, :cols => 70, :class => 'gt-form-textarea' %>

<%= image_submit_tag 'gt/btn-save.jpg', :class => 'gt-submit-btn' %> or <%= link_to "Cancel", admin_product_path %> <% end %> diff --git a/app/views/admin/products/images/_image_large_form.html.erb b/app/views/admin/products/images/_image_large_form.html.erb index f663a4c..67a4bbc 100644 --- a/app/views/admin/products/images/_image_large_form.html.erb +++ b/app/views/admin/products/images/_image_large_form.html.erb @@ -1,5 +1,5 @@
- <% form_for [:admin, image, large_image], + <% form_for [:admin, image, large_image], :html => { :multipart => true, :class => 'image_large_add' } do |form| %>

@@ -10,4 +10,4 @@ <%= image_submit_tag 'gt/btn-upload.jpg', :class => 'gt-submit-btn' %>

<% end %> -
+
diff --git a/app/views/admin/products/images/_image_large_list.html.erb b/app/views/admin/products/images/_image_large_list.html.erb index 017c865..c1a0469 100644 --- a/app/views/admin/products/images/_image_large_list.html.erb +++ b/app/views/admin/products/images/_image_large_list.html.erb @@ -2,6 +2,6 @@
<%= image_tag large_image.filename.url %> - <%= link_to 'Remove Large Image', admin_product_image_product_large_image_path(image, large_image), + <%= link_to 'Remove Large Image', admin_product_image_product_large_image_path(image, large_image), :class => "destroy-product-large-image" %>
diff --git a/app/views/admin/products/images/_image_thumbnail_form.html.erb b/app/views/admin/products/images/_image_thumbnail_form.html.erb index c0e5c09..7419004 100644 --- a/app/views/admin/products/images/_image_thumbnail_form.html.erb +++ b/app/views/admin/products/images/_image_thumbnail_form.html.erb @@ -1,5 +1,5 @@
- <% form_for [:admin, image, thumbnail], + <% form_for [:admin, image, thumbnail], :html => { :multipart => true, :class => 'image_thumbnail_add' } do |form| %>

@@ -10,4 +10,4 @@ <%= image_submit_tag 'gt/btn-upload.jpg', :class => 'gt-submit-btn' %>

<% end %> -
+
diff --git a/app/views/admin/products/images/_image_thumbnail_list.html.erb b/app/views/admin/products/images/_image_thumbnail_list.html.erb index 7448d41..fa450c7 100644 --- a/app/views/admin/products/images/_image_thumbnail_list.html.erb +++ b/app/views/admin/products/images/_image_thumbnail_list.html.erb @@ -2,6 +2,6 @@
<%= image_tag thumbnail.filename.url %> - <%= link_to 'Remove Thumbnail', admin_product_image_product_image_thumbnail_path(image, thumbnail), + <%= link_to 'Remove Thumbnail', admin_product_image_product_image_thumbnail_path(image, thumbnail), :class => "destroy-product-image-thumbnail" %>
diff --git a/app/views/admin/products/images/_images.html.erb b/app/views/admin/products/images/_images.html.erb index d344763..76a3302 100644 --- a/app/views/admin/products/images/_images.html.erb +++ b/app/views/admin/products/images/_images.html.erb @@ -7,4 +7,4 @@ <% end %>
-<%= render :partial => '/admin/products/images/image_form', :locals => { :product => product } %> +<%= render :partial => '/admin/products/images/image_form', :locals => { :product => product } %> diff --git a/app/views/admin/products/index.html.erb b/app/views/admin/products/index.html.erb index a69de1e..69f325b 100644 --- a/app/views/admin/products/index.html.erb +++ b/app/views/admin/products/index.html.erb @@ -26,8 +26,8 @@ <%= product.id %> <%= link_to 'Edit', edit_admin_product_path(product.id) %> - <%= link_to 'Delete', admin_product_path(product.id), - :confirm => 'Are you sure?', + <%= link_to 'Delete', admin_product_path(product.id), + :confirm => 'Are you sure?', :method => :delete %> diff --git a/app/views/admin/products/new.html.erb b/app/views/admin/products/new.html.erb index b91ab80..29fd213 100644 --- a/app/views/admin/products/new.html.erb +++ b/app/views/admin/products/new.html.erb @@ -14,7 +14,7 @@
<%= render :partial => "new" %> -
+
diff --git a/app/views/carts/_cart_item.html.erb b/app/views/carts/_cart_item.html.erb index 7c51c04..999673e 100644 --- a/app/views/carts/_cart_item.html.erb +++ b/app/views/carts/_cart_item.html.erb @@ -4,8 +4,8 @@ <% cart_item.price %> - <%= link_to cart_item.product.name, - category_product_path(cart_item.product.category, + <%= link_to cart_item.product.name, + category_product_path(cart_item.product.category, cart_item.product) %> <% if cart_item.option_selections.size > 0 %> (<%= render :partial => '/carts/cart_item_selections', @@ -22,9 +22,9 @@ <%= h(number_to_currency(cart_item.price * cart_item.quantity)) %> - <%= link_to 'Remove', cart_cart_item_path(cart, cart_item), + <%= link_to 'Remove', cart_cart_item_path(cart, cart_item), :confirm => "Are you sure you want to remove - #{cart_item.product.name}?", + #{cart_item.product.name}?", :method => :delete %> diff --git a/app/views/carts/_promo_code.html.erb b/app/views/carts/_promo_code.html.erb index 33bdef8..b589f24 100644 --- a/app/views/carts/_promo_code.html.erb +++ b/app/views/carts/_promo_code.html.erb @@ -5,7 +5,7 @@   Promo Code <%= cart.promo_code %> - + <% if cart.promo_discount > 0 %>

@@ -15,5 +15,5 @@ <%= cart.promo_discount %> <% end %> - + <% end %> \ No newline at end of file diff --git a/app/views/carts/_shipping_methods.html.erb b/app/views/carts/_shipping_methods.html.erb index 76812ce..1bc7ce7 100644 --- a/app/views/carts/_shipping_methods.html.erb +++ b/app/views/carts/_shipping_methods.html.erb @@ -1,2 +1,2 @@ <%= select_tag :methods, options_from_collection_for_select(shipping_methods, :id, :name, - @default_method.id) %>
+ @default_method.id) %>
diff --git a/app/views/carts/refresh_shipping_methods.rjs b/app/views/carts/refresh_shipping_methods.rjs index bba8aad..af63493 100644 --- a/app/views/carts/refresh_shipping_methods.rjs +++ b/app/views/carts/refresh_shipping_methods.rjs @@ -1,12 +1,12 @@ -page[:shipping_methods].replace_html :partial => "/carts/shipping_methods", +page[:shipping_methods].replace_html :partial => "/carts/shipping_methods", :locals => { :shipping_methods => @shipping_methods } -page[:shipping_totals].replace_html :partial => "/carts/shipping_totals", +page[:shipping_totals].replace_html :partial => "/carts/shipping_totals", :locals => { :shipping_total => @shipping_total } #page[:shipping_label].visual_effect :highlight, :duration => 3 #page[:shipping_total].visual_effect :highlight, :duration => 3 -page[:cart_totals].replace_html :partial => "/carts/cart_totals", +page[:cart_totals].replace_html :partial => "/carts/cart_totals", :locals => { :grand_total => @grand_total } page[:cart_total].visual_effect :highlight, :duration => 3 page[:cart_total_label].visual_effect :highlight, :duration => 3 \ No newline at end of file diff --git a/app/views/carts/refresh_totals.rjs b/app/views/carts/refresh_totals.rjs index 9d2b9e7..8099438 100644 --- a/app/views/carts/refresh_totals.rjs +++ b/app/views/carts/refresh_totals.rjs @@ -1,10 +1,10 @@ -page[:shipping_totals].replace_html :partial => "/carts/shipping_totals", +page[:shipping_totals].replace_html :partial => "/carts/shipping_totals", :locals => { :shipping_total => @shipping_total } #page[:shipping_label].visual_effect :highlight, :duration => 3 #page[:shipping_total].visual_effect :highlight, :duration => 3 -page[:cart_totals].replace_html :partial => "/carts/cart_totals", +page[:cart_totals].replace_html :partial => "/carts/cart_totals", :locals => { :grand_total => @grand_total } page[:cart_total].visual_effect :highlight, :duration => 3 -page[:cart_total_label].visual_effect :highlight, :duration => 3, +page[:cart_total_label].visual_effect :highlight, :duration => 3, :endcolor => '#f3f5da' \ No newline at end of file diff --git a/app/views/categories/_categories.html.erb b/app/views/categories/_categories.html.erb index dee7fe7..25d873c 100644 --- a/app/views/categories/_categories.html.erb +++ b/app/views/categories/_categories.html.erb @@ -2,15 +2,15 @@ <% categories.each do |category| %>
- <%= link_to image_tag(category.category_image), + <%= link_to image_tag(category.category_image), category_path(category) unless category.category_image.blank? %>
-

<%= link_to category.name, +

<%= link_to category.name, category_path(category) %>



- <%= link_to 'view shirts >>', + <%= link_to 'view shirts >>', category_path(category) %>

diff --git a/app/views/categories/_sidenav.html.erb b/app/views/categories/_sidenav.html.erb index 5ba031b..a827be3 100644 --- a/app/views/categories/_sidenav.html.erb +++ b/app/views/categories/_sidenav.html.erb @@ -7,7 +7,7 @@
    <% Category.tree('Womens').each do |category| %> <%= category.name %> - <% end %> + <% end %>
  • All
diff --git a/app/views/index/about.html.erb b/app/views/index/about.html.erb index d6a6d68..1b8f0c2 100644 --- a/app/views/index/about.html.erb +++ b/app/views/index/about.html.erb @@ -11,7 +11,7 @@

The Green Label philosophy

is one of respect; respect for our environment, respect for working people everywhere, and respect for ourselves through the choices we make.

We are pleased to offer you this colorful collection of 100% certified organic ring spun cotton T-shirts and tops. Our super-soft, low impact garment dyed organic T-shirts are made in the USA. Each piece is artfully designed to deliver fun and positive messages about the environment, fair trade, sustainability, and issues that are important to us all.

- We urge you always to….
+ We urge you always to….

Respect Labor* Respect the Planet* Respect Yourself



Namaste,
diff --git a/app/views/index/index.html.erb b/app/views/index/index.html.erb index 998006b..9da850c 100644 --- a/app/views/index/index.html.erb +++ b/app/views/index/index.html.erb @@ -1,4 +1,4 @@ -<% title("Pebbles") -%> +<% title("Pebbles") -%>
@@ -6,7 +6,7 @@

At Green Label Organic we strive to produce the most socially responsible and environmentally sustainable clothing available. We offer you easy to wear, fun clothing, with a point of view.

- +
@@ -17,7 +17,7 @@
Certified 100% Organic - + The Highest Quality

Experience our super-soft organic shirts made with organic ring spun cotton.

Made in the USA.

diff --git a/app/views/index/privacy_policy.html.erb b/app/views/index/privacy_policy.html.erb index 9b8c278..1462e42 100644 --- a/app/views/index/privacy_policy.html.erb +++ b/app/views/index/privacy_policy.html.erb @@ -12,7 +12,7 @@

This notice applies to all information collected or submitted on the Green Label Organic website. On some pages, you can order products and make requests. The types of personal information collected at these pages are:

Name
-Billing Address
+Billing Address
Shipping Address
Email address
Phone number
diff --git a/app/views/index/support_local.html.erb b/app/views/index/support_local.html.erb index 5c9354e..d48a3ba 100644 --- a/app/views/index/support_local.html.erb +++ b/app/views/index/support_local.html.erb @@ -1,5 +1,5 @@
- +

Support Local

>> Click for Support Local T-Shirts for your Organization diff --git a/app/views/order_notifier/order_confirmation.html.erb b/app/views/order_notifier/order_confirmation.html.erb index 3ecd8b7..d296c44 100644 --- a/app/views/order_notifier/order_confirmation.html.erb +++ b/app/views/order_notifier/order_confirmation.html.erb @@ -18,7 +18,7 @@ Order Details:


<% @order.order_items.each do |order_item| %> - <%= order_item.quantity %> - <%= order_item.product_name %> Organic T-Shirt - + <%= order_item.quantity %> - <%= order_item.product_name %> Organic T-Shirt - <%= number_to_currency(order_item.quantity * order_item.price) %>
<% end %> @@ -33,16 +33,16 @@ Shipping: <%= number_to_currency(@order.shipping_cost) %>

Shipping Address

<%= @order.shipping_address.address_1 %>
<%= @order.shipping_address.address_2 -%>
-<%= @order.shipping_address.city %>, <%= @order.shipping_address.state %> +<%= @order.shipping_address.city %>, <%= @order.shipping_address.state %> <%= @order.shipping_address.postal_code %>
<%= @order.shipping_address.country %>



- + <%= @order.shipping_method %>

Contact us:

-Please contact us at +Please contact us at customerservice@greenlabel.com for any questions.
diff --git a/app/views/order_notifier/supplier_confirmation.html.erb b/app/views/order_notifier/supplier_confirmation.html.erb index 82cf21b..6118ae5 100644 --- a/app/views/order_notifier/supplier_confirmation.html.erb +++ b/app/views/order_notifier/supplier_confirmation.html.erb @@ -32,12 +32,12 @@ Shipping: <%= number_to_currency(@order.shipping_cost) %>

Shipping Address

<%= @order.shipping_address.address_1 %>
<%= @order.shipping_address.address_2 -%>
-<%= @order.shipping_address.city %>, <%= @order.shipping_address.state %> +<%= @order.shipping_address.city %>, <%= @order.shipping_address.state %> <%= @order.shipping_address.postal_code %>
<%= @order.shipping_address.country %>


Contact us:

-Please contact us at +Please contact us at customerservice@greenlabel.com for any questions.
diff --git a/app/views/orders/_billing_address.html.erb b/app/views/orders/_billing_address.html.erb index 533f9be..8236633 100644 --- a/app/views/orders/_billing_address.html.erb +++ b/app/views/orders/_billing_address.html.erb @@ -1,5 +1,5 @@  -
+
<% fields_for :billing_address, billing_address do |address| %>

Billing Address

<%= error_messages_for :billing_address %> @@ -7,17 +7,17 @@   <%= address.text_field :address_1, :size => 20 %>
  - <%= address.text_field :address_2, :size => 20 %>
+ <%= address.text_field :address_2, :size => 20 %>
  - <%= address.text_field :city, :size => 20 %>
+ <%= address.text_field :city, :size => 20 %>
  - <%= state(address, 'billing_address') %>
+ <%= state(address, 'billing_address') %>
  - <%= address.text_field :postal_code, :size => 15 %>
+ <%= address.text_field :postal_code, :size => 15 %>
  <%= country(address, 'billing_address') %>
- + <% end %>
diff --git a/app/views/orders/_billing_shipping_info.html.erb b/app/views/orders/_billing_shipping_info.html.erb index c81c7fb..a6b9d43 100644 --- a/app/views/orders/_billing_shipping_info.html.erb +++ b/app/views/orders/_billing_shipping_info.html.erb @@ -4,24 +4,24 @@
  - <%= form.text_field :full_name, :size => 20 %>
+ <%= form.text_field :full_name, :size => 20 %>
  - <%= form.text_field :email, :size => 20 %>
+ <%= form.text_field :email, :size => 20 %>
  - <%= form.text_field :phone_number, :size => 20 %>
+ <%= form.text_field :phone_number, :size => 20 %>
  - <%= form.text_field :business, :size => 20 %>
+ <%= form.text_field :business, :size => 20 %>
- - + + -
+
- <%= render :partial => 'billing_address', - :locals => { :address_type => 'billing', - :billing_address => billing_address } %> - <%= render :partial => 'shipping_address', - :locals => { :address_type => 'shipping', + <%= render :partial => 'billing_address', + :locals => { :address_type => 'billing', + :billing_address => billing_address } %> + <%= render :partial => 'shipping_address', + :locals => { :address_type => 'shipping', :shipping_address => shipping_address } %>
diff --git a/app/views/orders/_payment_method.html.erb b/app/views/orders/_payment_method.html.erb index cc68423..53b096e 100644 --- a/app/views/orders/_payment_method.html.erb +++ b/app/views/orders/_payment_method.html.erb @@ -16,41 +16,41 @@ <%#= radio_button_tag 'payment_method', 'pay_pay', false, :onclick => "payment_credit_card_details_hide()" %> -
- +
+
Credit Card
- +
<% fields_for :credit_card, credit_card do |credit_card| %> - <%= credit_card.text_field :first_name, :size => 29 %>
- <%= credit_card.text_field :last_name, :size => 29 %>
+ <%= credit_card.text_field :first_name, :size => 29 %>
+ <%= credit_card.text_field :last_name, :size => 29 %>
<%= credit_card.text_field :number, :size => 29 %>
- <%= options_for_select([["Visa", "visa" ], ["Master Card", "master"], ["Discover", "discover"], ["American Express", "american_express"]], credit_card.type) %> -
- <%= select_month(credit_card.month, :prefix => "credit_card[month]", - :discard_type => true, :add_month_numbers => true ) %> +
+ <%= select_month(credit_card.month, :prefix => "credit_card[month]", + :discard_type => true, :add_month_numbers => true ) %>  /  - <%= select_year(credit_card.year, :prefix => "credit_card[year]", - :discard_type => true, - :start_year => 2008, :end_year => 2015 ) %> -

- <%= credit_card.text_field :verification_value, :size => 4 %> - What is this?
- <% end %> + <%= select_year(credit_card.year, :prefix => "credit_card[year]", + :discard_type => true, + :start_year => 2008, :end_year => 2015 ) %> +

+ <%= credit_card.text_field :verification_value, :size => 4 %> + What is this?
+ <% end %>
- - + +

diff --git a/app/views/orders/_paypal_form.html.erb b/app/views/orders/_paypal_form.html.erb index 7eefd0d..e97fa42 100644 --- a/app/views/orders/_paypal_form.html.erb +++ b/app/views/orders/_paypal_form.html.erb @@ -1,4 +1,4 @@ -<%= link_to image_tag('paypal_button.gif'), +<%= link_to image_tag('paypal_button.gif'), paypal_checkout_orders_path %> diff --git a/app/views/orders/_promo_code.html.erb b/app/views/orders/_promo_code.html.erb index dbb8286..5584147 100644 --- a/app/views/orders/_promo_code.html.erb +++ b/app/views/orders/_promo_code.html.erb @@ -1,9 +1,9 @@
<%= hidden_field_tag 'subtotal', @sub_total %> <%= text_field_tag 'order[promo_code]', "", - :size => 15, + :size => 15, :id => 'promo_text_field' %> - <%= link_to_remote " Apply Promo Code", + <%= link_to_remote " Apply Promo Code", { :submit => 'apply_promo_code', :url => promo_codes_path, :method => :post } diff --git a/app/views/orders/_review.html.erb b/app/views/orders/_review.html.erb index c61b53d..b6452bd 100644 --- a/app/views/orders/_review.html.erb +++ b/app/views/orders/_review.html.erb @@ -13,10 +13,10 @@     Subtotal - <%= number_to_currency(@subtotal) %> - + <%= number_to_currency(@subtotal) %> + - Shipping Region: <%= shipping_region(active_shipping_region_id) %>
+ Shipping Region: <%= shipping_region(active_shipping_region_id) %>
Shipping Method: <%= shipping_method(active_shipping_method_id) %> diff --git a/app/views/orders/_shipping_address.html.erb b/app/views/orders/_shipping_address.html.erb index c482aa0..f306b40 100644 --- a/app/views/orders/_shipping_address.html.erb +++ b/app/views/orders/_shipping_address.html.erb @@ -4,26 +4,26 @@ <%= check_box_tag 'address_choice', 'same_as_billing', true, :onclick => "Element.toggle('shipping_address_fields'); return true;" %> - Ship to billing address + Ship to billing address <% fields_for :shipping_address, shipping_address do |address| %> - diff --git a/app/views/orders/create.html.erb b/app/views/orders/create.html.erb index c2d43a2..b1c680e 100644 --- a/app/views/orders/create.html.erb +++ b/app/views/orders/create.html.erb @@ -1,4 +1,4 @@ -<%= render :partial => 'receipt', +<%= render :partial => 'receipt', :locals => { :order => @order } %> \ No newline at end of file diff --git a/app/views/orders/new.html.erb b/app/views/orders/new.html.erb index e883e96..ddcd3f9 100644 --- a/app/views/orders/new.html.erb +++ b/app/views/orders/new.html.erb @@ -8,27 +8,27 @@ <% end %>

1 Review Your Order

- <%= render :partial => '/carts/cart', + <%= render :partial => '/carts/cart', :locals => { :order_review => true } %>

2 Promo Code

- <% form_for :order, :url => orders_url, + <% form_for :order, :url => orders_url, :html => { :method => :post } do |form| %> - + <%= render :partial => 'promo_code' %> - + <% if @cart.sub_total > 0 %>

3 Payment

<%= render :partial => 'payment_method', :credit_card => @order.credit_card %>

4 Information

- <%= render :partial => 'billing_shipping_info', + <%= render :partial => 'billing_shipping_info', :locals => { :billing_address => @order.billing_address, :shipping_address => @order.shipping_address, :form => form } %> -
+


@@ -43,14 +43,14 @@
- + <% else %>
Please add additional items to checkout.
<% end %> - + =======
<% if @processing_error_message %> @@ -58,27 +58,27 @@ <% end %>

1 Review Your Order

- <%= render :partial => '/carts/cart', + <%= render :partial => '/carts/cart', :locals => { :order_review => true } %>

2 Promo Code

- <% form_for :order, :url => orders_url, + <% form_for :order, :url => orders_url, :html => { :method => :post } do |form| %> - + <%= render :partial => 'promo_code' %> - + <% if @cart.sub_total > 0 %>

3 Payment

<%= render :partial => 'payment_method', :credit_card => @order.credit_card %>

4 Information

- <%= render :partial => 'billing_shipping_info', + <%= render :partial => 'billing_shipping_info', :locals => { :billing_address => @order.billing_address, :shipping_address => @order.shipping_address, :form => form } %> -
+


@@ -93,14 +93,14 @@
- + <% else %>
Please add additional items to checkout.
<% end %> - + >>>>>>> abf4830788514b0161ca65127932212b3c312e3a <% end %>
diff --git a/app/views/orders/status.html.erb b/app/views/orders/status.html.erb index 4b9394e..0a29c94 100644 --- a/app/views/orders/status.html.erb +++ b/app/views/orders/status.html.erb @@ -2,9 +2,9 @@

<%= @status_error %>

<% else %> Confirmation #: <%= @status.confirmation %>
- Status: + Status: <%= @status.state %>
- Tracking Number: + Tracking Number: <%= @status.tracking_number %> <%# if @order %> diff --git a/app/views/products/_accessory_options.html.erb b/app/views/products/_accessory_options.html.erb index 0ef12ca..9ded303 100644 --- a/app/views/products/_accessory_options.html.erb +++ b/app/views/products/_accessory_options.html.erb @@ -4,13 +4,13 @@ <% if product_option.selection_type == ProductOption::DROP_DOWN_LIST %> - + - + diff --git a/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb b/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb index 68a285d..054386d 100644 --- a/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb +++ b/vendor/plugins/responds_to_parent/lib/responds_to_parent.rb @@ -1,23 +1,23 @@ # Module containing the methods useful for child IFRAME to parent window communication module RespondsToParent - + # Executes the response body as JavaScript in the context of the parent window. # Use this method of you are posting a form to a hidden IFRAME or if you would like # to use IFRAME base RPC. def responds_to_parent(&block) yield - + if performed? # We're returning HTML instead of JS or XML now response.headers['Content-Type'] = 'text/html; charset=UTF-8' - + # Either pull out a redirect or the request body script = if location = erase_redirect_results "document.location.href = #{location.to_s.inspect}" else response.body end - + # Escape quotes, linebreaks and slashes, maintaining previously escaped slashes # Suggestions for improvement? script = (script || ''). @@ -28,8 +28,8 @@ def responds_to_parent(&block) # Clear out the previous render to prevent double render erase_results - - # Eval in parent scope and replace document location of this frame + + # Eval in parent scope and replace document location of this frame # so back button doesn't replay action on targeted forms # loc = document.location to be set after parent is updated for IE # with(window.parent) - pull in variables from parent window @@ -37,7 +37,7 @@ def responds_to_parent(&block) # window.eval - legal eval for Opera render :text => "" end end diff --git a/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb b/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb index 0b45b64..ca33c8b 100644 --- a/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb +++ b/vendor/plugins/responds_to_parent/test/responds_to_parent_test.rb @@ -4,46 +4,46 @@ class IFrameController < ActionController::Base def normal - render :update do |page| + render :update do |page| page.alert "foo" end end - + def aliased respond_to_parent do render :text => 'woot' end end - + def redirect responds_to_parent do redirect_to '/another/place' end end - + def no_block responds_to_parent end - + def empty_render responds_to_parent do end - + render :text => '' end - + def quotes responds_to_parent do render :text => %(single' double" qs\\' qd\\" escaped\\\' doubleescaped\\\\') end end - + def newlines responds_to_parent do render :text => "line1\nline2\\nline2" end end - + def update responds_to_parent do render :update do |page| @@ -52,7 +52,7 @@ def update end end end - + def rescue_action(e) raise e end @@ -64,48 +64,48 @@ def setup @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end - + def test_normal get :normal assert_match /alert\("foo"\)/, @response.body assert_no_match /window\.parent/, @response.body end - + def test_quotes_should_be_escaped render :quotes assert_match %r{eval\('single\\' double\\" qs\\\\\\' qd\\\\\\" escaped\\\\\\' doubleescaped\\\\\\\\\\'}, @response.body end - + def test_newlines_should_be_escaped render :newlines assert_match %r{eval\('line1\\nline2\\\\nline2'\)}, @response.body end - + def test_no_block_should_raise assert_raises LocalJumpError do get :no_block end end - + def test_empty_render_should_not_expand_javascript get :empty_render assert_equal '', @response.body end - + def test_update_should_perform_combined_rjs render :update assert_match /alert\(\\"foo\\"\);\\nalert\(\\"bar\\"\)/, @response.body end - + def test_aliased_method_should_not_raise assert_nothing_raised do render :aliased assert_match /eval\('woot'\)/, @response.body end end - + protected - + def render(action) get action assert_match /