From 356ae40c7bf6af03b629498042405e307095dc57 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 13 Sep 2012 13:05:12 +1000 Subject: [PATCH] Display product descriptions as HTML in checkout --- Gemfile | 1 + Gemfile.lock | 2 ++ app/overrides/cart_item_description.rb | 4 ++++ app/views/spree/orders/_cart_item_description.html.haml | 8 ++++++++ 4 files changed, 15 insertions(+) create mode 100644 app/overrides/cart_item_description.rb create mode 100644 app/views/spree/orders/_cart_item_description.html.haml diff --git a/Gemfile b/Gemfile index ef246d273d..5a2e8e439d 100644 --- a/Gemfile +++ b/Gemfile @@ -20,6 +20,7 @@ gem 'spree_heroku', :git => 'git://github.com/joneslee85/spree-heroku.git' gem 'haml' gem 'aws-s3' gem 'andand' +gem 'truncate_html' # Gems used only for assets and not required # in production environments by default. diff --git a/Gemfile.lock b/Gemfile.lock index c35a8ae80e..6cdd8bf80d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -304,6 +304,7 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) + truncate_html (0.5.5) turn (0.8.3) ansi tzinfo (0.3.33) @@ -350,6 +351,7 @@ DEPENDENCIES spree_last_address! spree_paypal_express! therubyracer + truncate_html turn (~> 0.8.3) uglifier (>= 1.0.3) unicorn diff --git a/app/overrides/cart_item_description.rb b/app/overrides/cart_item_description.rb new file mode 100644 index 0000000000..9fd253c040 --- /dev/null +++ b/app/overrides/cart_item_description.rb @@ -0,0 +1,4 @@ +Deface::Override.new(:virtual_path => "spree/orders/_line_item", + :replace => "[data-hook='cart_item_description']", + :partial => "spree/orders/cart_item_description", + :name => "cart_item_description") diff --git a/app/views/spree/orders/_cart_item_description.html.haml b/app/views/spree/orders/_cart_item_description.html.haml new file mode 100644 index 0000000000..ff04782b44 --- /dev/null +++ b/app/views/spree/orders/_cart_item_description.html.haml @@ -0,0 +1,8 @@ +%td{'data-hook' => "cart_item_description"} + %h4= link_to variant.product.name, product_path(variant.product) + = variant.options_text + - if @order.insufficient_stock_lines.include? line_item + %span.out-of-stock + = variant.in_stock? ? t(:insufficient_stock, :on_hand => variant.on_hand) : t(:out_of_stock) + %br/ + = truncate_html(variant.product.description, :length => 100, :omission => "...")