Commit 773fab23137594a571ab78b2f49fa09aba3132de
1 parent
82653b80
Exists in
master
and in
29 other branches
Stop using application helper
(ActionItem1970)
Showing
6 changed files
with
22 additions
and
19 deletions
Show diff stats
plugins/shopping_cart/controllers/shopping_cart_plugin_profile_controller.rb
@@ -16,7 +16,7 @@ class ShoppingCartPluginProfileController < ProfileController | @@ -16,7 +16,7 @@ class ShoppingCartPluginProfileController < ProfileController | ||
16 | :products => [{ | 16 | :products => [{ |
17 | :id => product.id, | 17 | :id => product.id, |
18 | :name => product.name, | 18 | :name => product.name, |
19 | - :price => get_price(product), | 19 | + :price => get_price(product, profile.environment), |
20 | :description => product.description, | 20 | :description => product.description, |
21 | :picture => product.default_image(:minor), | 21 | :picture => product.default_image(:minor), |
22 | :quantity => session[:cart][:items][product.id] | 22 | :quantity => session[:cart][:items][product.id] |
@@ -44,7 +44,7 @@ class ShoppingCartPluginProfileController < ProfileController | @@ -44,7 +44,7 @@ class ShoppingCartPluginProfileController < ProfileController | ||
44 | product = Product.find(id) | 44 | product = Product.find(id) |
45 | { :id => product.id, | 45 | { :id => product.id, |
46 | :name => product.name, | 46 | :name => product.name, |
47 | - :price => get_price(product), | 47 | + :price => get_price(product, profile.environment), |
48 | :description => product.description, | 48 | :description => product.description, |
49 | :picture => product.default_image(:minor), | 49 | :picture => product.default_image(:minor), |
50 | :quantity => quantity | 50 | :quantity => quantity |
@@ -83,6 +83,7 @@ class ShoppingCartPluginProfileController < ProfileController | @@ -83,6 +83,7 @@ class ShoppingCartPluginProfileController < ProfileController | ||
83 | end | 83 | end |
84 | 84 | ||
85 | def buy | 85 | def buy |
86 | + @environment = profile.environment | ||
86 | render :layout => false | 87 | render :layout => false |
87 | end | 88 | end |
88 | 89 |
plugins/shopping_cart/lib/shopping_cart_plugin/cart_helper.rb
@@ -7,15 +7,15 @@ module ShoppingCartPlugin::CartHelper | @@ -7,15 +7,15 @@ module ShoppingCartPlugin::CartHelper | ||
7 | product.discount ? product.price_with_discount : product.price | 7 | product.discount ? product.price_with_discount : product.price |
8 | end | 8 | end |
9 | 9 | ||
10 | - def get_price(product) | ||
11 | - float_to_currency(sell_price(product)) | 10 | + def get_price(product, environment) |
11 | + float_to_currency_cart(sell_price(product), environment) | ||
12 | end | 12 | end |
13 | 13 | ||
14 | - def get_total(items) | ||
15 | - float_to_currency(items.map { |id, quantity| sell_price(Product.find(id)) * quantity}.sum) | 14 | + def get_total(items, environment) |
15 | + float_to_currency_cart(items.map { |id, quantity| sell_price(Product.find(id)) * quantity}.sum, environment) | ||
16 | end | 16 | end |
17 | 17 | ||
18 | - def items_table(items, by_mail = false) | 18 | + def items_table(items, environment, by_mail = false) |
19 | '<table id="cart-items-table" cellpadding="2" cellspacing="0" | 19 | '<table id="cart-items-table" cellpadding="2" cellspacing="0" |
20 | border="'+(by_mail ? '1' : '0')+'" | 20 | border="'+(by_mail ? '1' : '0')+'" |
21 | style="'+(by_mail ? 'border-collapse:collapse' : '')+'">' + | 21 | style="'+(by_mail ? 'border-collapse:collapse' : '')+'">' + |
@@ -33,12 +33,18 @@ module ShoppingCartPlugin::CartHelper | @@ -33,12 +33,18 @@ module ShoppingCartPlugin::CartHelper | ||
33 | content_tag('tr', | 33 | content_tag('tr', |
34 | content_tag('td', product.name) + | 34 | content_tag('td', product.name) + |
35 | content_tag('td', quantity, quantity_opts ) + | 35 | content_tag('td', quantity, quantity_opts ) + |
36 | - content_tag('td', get_price(product), price_opts ) | 36 | + content_tag('td', get_price(product, environment), price_opts ) |
37 | ) | 37 | ) |
38 | end.join("\n") + | 38 | end.join("\n") + |
39 | content_tag('th', _('Total:'), :colspan => 2, :class => 'cart-table-total-label') + | 39 | content_tag('th', _('Total:'), :colspan => 2, :class => 'cart-table-total-label') + |
40 | - content_tag('th', get_total(items), :class => 'cart-table-total-value') + | 40 | + content_tag('th', get_total(items, environment), :class => 'cart-table-total-value') + |
41 | '</table>' | 41 | '</table>' |
42 | end | 42 | end |
43 | 43 | ||
44 | + private | ||
45 | + | ||
46 | + def float_to_currency_cart(value, environment) | ||
47 | + number_to_currency(value, :unit => environment.currency_unit, :separator => environment.currency_separator, :delimiter => environment.currency_delimiter, :format => "%u %n") | ||
48 | + end | ||
49 | + | ||
44 | end | 50 | end |
plugins/shopping_cart/lib/shopping_cart_plugin/mailer.rb
plugins/shopping_cart/views/shopping_cart_plugin/mailer/customer_notification.html.erb
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
5 | </head> | 5 | </head> |
6 | <body> | 6 | <body> |
7 | - <% environment = @environment %> | ||
8 | <h4><%= _('Hi %s!') % @customer[:name] %></h4> | 7 | <h4><%= _('Hi %s!') % @customer[:name] %></h4> |
9 | 8 | ||
10 | <p> | 9 | <p> |
@@ -22,13 +21,13 @@ | @@ -22,13 +21,13 @@ | ||
22 | </ul> | 21 | </ul> |
23 | 22 | ||
24 | <p><%=_('Here are the products you bought:')%></p> | 23 | <p><%=_('Here are the products you bought:')%></p> |
25 | - <%= items_table(@items, true) %> | 24 | + <%= items_table(@items, @environment, true) %> |
26 | 25 | ||
27 | <p> | 26 | <p> |
28 | --<br/> | 27 | --<br/> |
29 | <%=_('Thanks for buying with us!')%><br/> | 28 | <%=_('Thanks for buying with us!')%><br/> |
30 | <%= link_to @supplier.name, @supplier.url %> | 29 | <%= link_to @supplier.name, @supplier.url %> |
31 | </p> | 30 | </p> |
32 | - <small style="color: #888"><%= _('A service of %s.') % environment.name %></small> | 31 | + <small style="color: #888"><%= _('A service of %s.') % @environment.name %></small> |
33 | </body> | 32 | </body> |
34 | </html> | 33 | </html> |
plugins/shopping_cart/views/shopping_cart_plugin/mailer/supplier_notification.html.erb
@@ -4,7 +4,6 @@ | @@ -4,7 +4,6 @@ | ||
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
5 | </head> | 5 | </head> |
6 | <body> | 6 | <body> |
7 | - <% environment = @environment %> | ||
8 | <h4><%= _('Hi %s!') % @supplier.name %></h4> | 7 | <h4><%= _('Hi %s!') % @supplier.name %></h4> |
9 | 8 | ||
10 | <p> | 9 | <p> |
@@ -22,12 +21,12 @@ | @@ -22,12 +21,12 @@ | ||
22 | </ul> | 21 | </ul> |
23 | 22 | ||
24 | <p><%=_('And here are the items bought by this customer:')%></p> | 23 | <p><%=_('And here are the items bought by this customer:')%></p> |
25 | - <%= items_table(@items, true) %> | 24 | + <%= items_table(@items, @environment, true) %> |
26 | 25 | ||
27 | <p> | 26 | <p> |
28 | --<br/> | 27 | --<br/> |
29 | - <%=_('If there are any problems with this email contact the admin of %s.') % environment.name %> | 28 | + <%=_('If there are any problems with this email contact the admin of %s.') % @environment.name %> |
30 | </p> | 29 | </p> |
31 | - <small style="color: #888"><%= _('A service of %s.') % environment.name %></small> | 30 | + <small style="color: #888"><%= _('A service of %s.') % @environment.name %></small> |
32 | </body> | 31 | </body> |
33 | </html> | 32 | </html> |
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | <%= submit_button(:send, _('Send buy request')) %> | 18 | <%= submit_button(:send, _('Send buy request')) %> |
19 | </div> | 19 | </div> |
20 | <% end %> | 20 | <% end %> |
21 | - <%= items_table(session[:cart][:items]) %> | 21 | + <%= items_table(session[:cart][:items], @environment) %> |
22 | </div> | 22 | </div> |
23 | 23 | ||
24 | <script type="text/javascript"> | 24 | <script type="text/javascript"> |