Skip to content

Commit

Permalink
add method to Product to fetch leadtime. show leadtime under price us…
Browse files Browse the repository at this point in the history
…ing hook
  • Loading branch information
David North committed Dec 21, 2009
1 parent 92489ba commit 0566652
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 40 deletions.
6 changes: 6 additions & 0 deletions shipping_centers_extension.rb
Expand Up @@ -14,6 +14,12 @@ class ShippingCentersExtension < Spree::Extension

def activate

Product.class_eval do
def leadtime
ShippingCenter.leadtime_for_product(self)
end
end

ProductGroup.class_eval do

# Is a producted in the group (does it match the group's criteria?)
Expand Down
50 changes: 10 additions & 40 deletions shipping_centers_hooks.rb
@@ -1,43 +1,13 @@
class ShippingCentersHooks < Spree::ThemeSupport::HookListener

#
# In this file you can modify the content of the hooks available in the default templates
# and avoid overriding a template in many situations. Multiple extensions can modify the
# same hook, the changes being applied cumulatively based on extension load order
#
# Most hooks are defined with blocks so they span a region of the template, allowing content
# to be replaced or removed as well as added to.
#
# Usage
#
# The following methods are available
#
# * insert_before
# * insert_after
# * replace
# * remove
#
# All accept a block name symbol followed either by arguments that would be valid for 'render'
# or a block which returns the string to be inserted. The block will have access to any methods
# or instance variables accessible in your views
#
# Examples
#
# insert_before :homepage_products, :text => "<h1>Welcome!</h1>"
# insert_after :homepage_products, 'shared/offers' # renders a partial
# replace :taxon_sidebar_navigation, 'shared/my_sidebar
#
# adding a link below product details:
#
# insert_after :product_description do
# '<p>' + link_to('Back to products', products_path) + '</p>'
# end
#
# adding a new tab to the admin navigation
#
# insert_after :admin_tabs do
# tab(:taxonomies)
# end
#

insert_after :product_price do
%(
<p><% if leadtime = @product.leadtime %>
Ships in <%= @product.leadtime %>
<% else %>
Shipping time unknown
<% end %></p>
)
end

end

0 comments on commit 0566652

Please sign in to comment.