diff --git a/plugins/shopping_cart/controllers/shopping_cart_plugin_profile_controller.rb b/plugins/shopping_cart/controllers/shopping_cart_plugin_profile_controller.rb index bf623d1..e948347 100644 --- a/plugins/shopping_cart/controllers/shopping_cart_plugin_profile_controller.rb +++ b/plugins/shopping_cart/controllers/shopping_cart_plugin_profile_controller.rb @@ -16,7 +16,7 @@ class ShoppingCartPluginProfileController < ProfileController :products => [{ :id => product.id, :name => product.name, - :price => get_price(product), + :price => get_price(product, profile.environment), :description => product.description, :picture => product.default_image(:minor), :quantity => session[:cart][:items][product.id] @@ -44,7 +44,7 @@ class ShoppingCartPluginProfileController < ProfileController product = Product.find(id) { :id => product.id, :name => product.name, - :price => get_price(product), + :price => get_price(product, profile.environment), :description => product.description, :picture => product.default_image(:minor), :quantity => quantity @@ -83,6 +83,7 @@ class ShoppingCartPluginProfileController < ProfileController end def buy + @environment = profile.environment render :layout => false end diff --git a/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb b/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb index 2f759be..2ece9c7 100644 --- a/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb +++ b/plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb @@ -7,15 +7,15 @@ module ShoppingCartPlugin::CartHelper product.discount ? product.price_with_discount : product.price end - def get_price(product) - float_to_currency(sell_price(product)) + def get_price(product, environment) + float_to_currency_cart(sell_price(product), environment) end - def get_total(items) - float_to_currency(items.map { |id, quantity| sell_price(Product.find(id)) * quantity}.sum) + def get_total(items, environment) + float_to_currency_cart(items.map { |id, quantity| sell_price(Product.find(id)) * quantity}.sum, environment) end - def items_table(items, by_mail = false) + def items_table(items, environment, by_mail = false) '' + @@ -33,12 +33,18 @@ module ShoppingCartPlugin::CartHelper content_tag('tr', content_tag('td', product.name) + content_tag('td', quantity, quantity_opts ) + - content_tag('td', get_price(product), price_opts ) + content_tag('td', get_price(product, environment), price_opts ) ) end.join("\n") + content_tag('th', _('Total:'), :colspan => 2, :class => 'cart-table-total-label') + - content_tag('th', get_total(items), :class => 'cart-table-total-value') + + content_tag('th', get_total(items, environment), :class => 'cart-table-total-value') + '
' end + private + + def float_to_currency_cart(value, environment) + number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :format => "%u %n") + end + end diff --git a/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb b/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb index 52d6e50..0c8ee0b 100644 --- a/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb +++ b/plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb @@ -1,5 +1,3 @@ -include ApplicationHelper - class ShoppingCartPlugin::Mailer < Noosfero::Plugin::MailerBase prepend_view_path(ShoppingCartPlugin.root_path+'/views') diff --git a/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb index 48dbc8a..1fd7e9b 100644 --- a/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb +++ b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb @@ -4,7 +4,6 @@ - <% environment = @environment %>

<%= _('Hi %s!') % @customer[:name] %>

@@ -22,13 +21,13 @@

<%=_('Here are the products you bought:')%>

- <%= items_table(@items, true) %> + <%= items_table(@items, @environment, true) %>

--
<%=_('Thanks for buying with us!')%>
<%= link_to @supplier.name, @supplier.url %>

- <%= _('A service of %s.') % environment.name %> + <%= _('A service of %s.') % @environment.name %> diff --git a/plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb index 8e01145..13cb3f8 100644 --- a/plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb +++ b/plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb @@ -4,7 +4,6 @@ - <% environment = @environment %>

<%= _('Hi %s!') % @supplier.name %>

@@ -22,12 +21,12 @@

<%=_('And here are the items bought by this customer:')%>

- <%= items_table(@items, true) %> + <%= items_table(@items, @environment, true) %>

--
- <%=_('If there are any problems with this email contact the admin of %s.') % environment.name %> + <%=_('If there are any problems with this email contact the admin of %s.') % @environment.name %>

- <%= _('A service of %s.') % environment.name %> + <%= _('A service of %s.') % @environment.name %> diff --git a/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb index 4248d05..3519a02 100644 --- a/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb +++ b/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb @@ -18,7 +18,7 @@ <%= submit_button(:send, _('Send buy request')) %> <% end %> - <%= items_table(session[:cart][:items]) %> + <%= items_table(session[:cart][:items], @environment) %>