camaleon_ecommerce 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/plugins/ecommerce/admin_product.js.coffee +17 -1
  3. data/app/controllers/plugins/ecommerce/admin/coupons_controller.rb +1 -1
  4. data/app/controllers/plugins/ecommerce/admin/orders_controller.rb +24 -21
  5. data/app/controllers/plugins/ecommerce/admin/payment_methods_controller.rb +2 -34
  6. data/app/controllers/plugins/ecommerce/admin/prices_controller.rb +3 -6
  7. data/app/controllers/plugins/ecommerce/admin/settings_controller.rb +2 -1
  8. data/app/controllers/plugins/ecommerce/admin/shipping_methods_controller.rb +2 -2
  9. data/app/controllers/plugins/ecommerce/admin/tax_rates_controller.rb +1 -1
  10. data/app/controllers/plugins/ecommerce/admin_controller.rb +2 -2
  11. data/app/controllers/plugins/ecommerce/front/checkout_controller.rb +34 -18
  12. data/app/controllers/plugins/ecommerce/front/orders_controller.rb +3 -4
  13. data/app/controllers/plugins/ecommerce/front_controller.rb +26 -11
  14. data/app/decorators/plugins/ecommerce/cart_decorator.rb +5 -5
  15. data/app/decorators/plugins/ecommerce/coupon_decorator.rb +8 -27
  16. data/app/decorators/plugins/ecommerce/order_decorator.rb +1 -1
  17. data/app/decorators/plugins/ecommerce/product_decorator.rb +33 -20
  18. data/app/decorators/plugins/ecommerce/product_item_decorator.rb +8 -2
  19. data/app/decorators/plugins/ecommerce/product_variation_decorator.rb +1 -1
  20. data/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb +7 -6
  21. data/app/helpers/plugins/ecommerce/ecommerce_functions_helper.rb +276 -33
  22. data/app/helpers/plugins/ecommerce/ecommerce_helper.rb +59 -56
  23. data/app/models/plugins/ecommerce/attribute.rb +3 -0
  24. data/app/models/plugins/ecommerce/cart.rb +31 -7
  25. data/app/models/plugins/ecommerce/legacy_order.rb +1 -30
  26. data/app/models/plugins/ecommerce/order.rb +11 -5
  27. data/app/models/plugins/ecommerce/order_detail.rb +1 -0
  28. data/app/models/plugins/ecommerce/payment_method.rb +9 -5
  29. data/app/models/plugins/ecommerce/product_variation.rb +6 -0
  30. data/app/services/plugins/ecommerce/cart_service.rb +4 -17
  31. data/app/views/camaleon_cms/html_mailer/order_canceled.html.erb +2 -2
  32. data/app/views/camaleon_cms/html_mailer/order_confirmed.html.erb +2 -2
  33. data/app/views/camaleon_cms/html_mailer/order_received.html.erb +5 -3
  34. data/app/views/camaleon_cms/html_mailer/order_received_admin.html.erb +3 -3
  35. data/app/views/camaleon_cms/html_mailer/order_shipped.html.erb +2 -2
  36. data/app/views/camaleon_cms/html_mailer/recovery_cart.html.erb +3 -3
  37. data/app/views/plugins/ecommerce/admin/coupons/form.html.erb +11 -11
  38. data/app/views/plugins/ecommerce/admin/coupons/index.html.erb +11 -11
  39. data/app/views/plugins/ecommerce/admin/orders/form.html.erb +2 -2
  40. data/app/views/plugins/ecommerce/admin/orders/index.html.erb +53 -63
  41. data/app/views/plugins/ecommerce/admin/payment_methods/form.html.erb +30 -24
  42. data/app/views/plugins/ecommerce/admin/payment_methods/index.html.erb +8 -8
  43. data/app/views/plugins/ecommerce/admin/payment_methods/show.html.erb +22 -22
  44. data/app/views/plugins/ecommerce/admin/prices/form.html.erb +6 -6
  45. data/app/views/plugins/ecommerce/admin/prices/index.html.erb +8 -8
  46. data/app/views/plugins/ecommerce/admin/product_attributes.html.erb +1 -1
  47. data/app/views/plugins/ecommerce/admin/products/_variations.html.erb +4 -4
  48. data/app/views/plugins/ecommerce/admin/products/index.html.erb +5 -5
  49. data/app/views/plugins/ecommerce/admin/settings/index.html.erb +20 -8
  50. data/app/views/plugins/ecommerce/admin/shipping_methods/form.html.erb +5 -5
  51. data/app/views/plugins/ecommerce/admin/shipping_methods/index.html.erb +8 -9
  52. data/app/views/plugins/ecommerce/admin/shipping_methods/show.html.erb +4 -4
  53. data/app/views/plugins/ecommerce/admin/tax_rates/form.html.erb +3 -3
  54. data/app/views/plugins/ecommerce/admin/tax_rates/index.html.erb +7 -7
  55. data/app/views/plugins/ecommerce/front/checkout/index.html.erb +4 -4
  56. data/app/views/plugins/ecommerce/front/login.html.erb +3 -6
  57. data/app/views/plugins/ecommerce/front/orders/show.html.erb +7 -1
  58. data/app/views/plugins/ecommerce/partials/_cart_widget.html.erb +14 -29
  59. data/app/views/plugins/ecommerce/partials/checkout/_details.html.erb +1 -1
  60. data/app/views/plugins/ecommerce/partials/checkout/_payments.html.erb +100 -99
  61. data/app/views/plugins/ecommerce/partials/checkout/_user_info.html.erb +2 -2
  62. data/app/views/post_types/commerce/{_product_widget.html.erb → _post_list_item.html.erb} +0 -0
  63. data/app/views/post_types/commerce/_product_info.html.erb +45 -0
  64. data/app/views/post_types/commerce/single.html.erb +63 -85
  65. data/config/camaleon_plugin.json +3 -8
  66. data/config/custom_models.rb +28 -4
  67. data/config/locales/en.yml +27 -12
  68. data/config/locales/es.yml +70 -57
  69. data/config/routes.rb +1 -0
  70. data/db/migrate/20161202182552_add_cookie_key_to_cart.rb +5 -0
  71. data/lib/ecommerce/version.rb +1 -1
  72. metadata +7 -14
  73. data/app/helpers/plugins/ecommerce/ecommerce_payment_helper.rb +0 -6
  74. data/app/models/plugins/ecommerce/legacy_cart.rb +0 -50
  75. data/app/services/plugins/ecommerce/product_item_service.rb +0 -29
  76. data/app/services/plugins/ecommerce/product_service.rb +0 -17
  77. data/app/services/plugins/ecommerce/site_service.rb +0 -21
  78. data/app/services/plugins/ecommerce/user_cart_service.rb +0 -12
  79. data/app/services/plugins/ecommerce/user_product_service.rb +0 -29
  80. data/app/views/post_types/commerce.html.erb +0 -22
  81. data/app/views/post_types/commerce/category.html.erb +0 -23
@@ -2,17 +2,16 @@ class Plugins::Ecommerce::Front::OrdersController < Plugins::Ecommerce::FrontCon
2
2
  before_action :commerce_authenticate
3
3
  before_action :set_bread
4
4
  def index
5
- @orders = current_site.orders.set_user(current_user).decorate
5
+ @orders = current_site.orders.set_user(cama_current_user).decorate
6
6
  render "index"
7
7
  end
8
8
 
9
9
  def show
10
- @order = current_site.orders.find_by_slug(params[:order]).decorate
10
+ @order = current_site.orders.set_user(cama_current_user).find_by_slug(params[:order]).try(:decorate)
11
+ return redirect_to(url_for(action: :index), error: t('plugins.ecommerce.messages.order_not_found', default: "Order not found", order: params[:order])) unless @order.present?
11
12
  @ecommerce_breadcrumb << [t('plugins.ecommerce.messages.detail_order', default: "Detail order: #%{order}", order: params[:order])]
12
13
  end
13
14
 
14
-
15
-
16
15
  private
17
16
  def set_bread
18
17
  @ecommerce_breadcrumb << [t('plugins.ecommerce.messages.my_orders', default: 'My Orders'), url_for(action: :index)]
@@ -1,5 +1,5 @@
1
1
  class Plugins::Ecommerce::FrontController < CamaleonCms::Apps::PluginsFrontController
2
- include Plugins::Ecommerce::EcommercePaymentHelper
2
+ prepend_before_action :init_flash
3
3
  before_action :ecommerce_add_assets_in_front
4
4
  before_action :save_cache_redirect, only: [:login, :register]
5
5
  def login
@@ -8,11 +8,12 @@ class Plugins::Ecommerce::FrontController < CamaleonCms::Apps::PluginsFrontContr
8
8
  end
9
9
 
10
10
  def do_login
11
- if login_user_with_password(params[:username], params[:password])
12
- login_user(@user, false, (cookies[:return_to] || plugins_ecommerce_orders_path))
13
- return cookies.delete(:return_to)
11
+ if login_user_with_password(params[:email], params[:password])
12
+ callback_login(@user)
13
+ login_user(@user, false, (cookies[:e_return_to] || plugins_ecommerce_orders_path))
14
+ return cookies.delete(:e_return_to)
14
15
  else
15
- flash[:error] = t('plugins.ecommerce.messages.invalid_access', default: 'Invalid access')
16
+ flash[:cama_ecommerce][:error] = t('plugins.ecommerce.messages.invalid_access', default: 'Invalid access')
16
17
  return login
17
18
  end
18
19
  end
@@ -24,11 +25,13 @@ class Plugins::Ecommerce::FrontController < CamaleonCms::Apps::PluginsFrontContr
24
25
  end
25
26
 
26
27
  def do_register
28
+ params[:camaleon_cms_user][:username] = params[:camaleon_cms_user][:email] if params[:camaleon_cms_user].present?
27
29
  @user = current_site.users.new(params.require(:camaleon_cms_user).permit(:first_name, :last_name, :username, :email, :password, :password_confirmation))
28
30
  if @user.save
29
- flash[:notice] = t('plugins.ecommerce.messages.created_account', default: "Account created successfully")
30
- login_user(@user, false, (cookies[:return_to] || plugins_ecommerce_orders_path))
31
- return cookies.delete(:return_to)
31
+ flash[:cama_ecommerce][:notice] = t('plugins.ecommerce.messages.created_account', default: "Account created successfully")
32
+ callback_login(@user)
33
+ login_user(@user, false, (cookies[:e_return_to] || plugins_ecommerce_orders_path))
34
+ return cookies.delete(:e_return_to)
32
35
  else
33
36
  return register
34
37
  end
@@ -36,14 +39,26 @@ class Plugins::Ecommerce::FrontController < CamaleonCms::Apps::PluginsFrontContr
36
39
 
37
40
  private
38
41
  def save_cache_redirect
39
- cookies[:return_to] = params[:return_to] if params[:return_to].present?
42
+ cookies[:e_return_to] = params[:return_to] if params[:return_to].present?
40
43
  end
41
44
 
42
45
  def commerce_authenticate
43
46
  unless cama_sign_in?
44
- flash[:error] = t('camaleon_cms.admin.login.please_login')
45
- cookies[:return_to] = request.referer
47
+ flash[:cama_ecommerce][:error] = t('camaleon_cms.admin.login.please_login')
48
+ cookies[:e_return_to] = request.referer
46
49
  redirect_to plugins_ecommerce_login_path
47
50
  end
48
51
  end
52
+
53
+ def init_flash
54
+ flash[:cama_ecommerce] = {} unless flash[:cama_ecommerce].present?
55
+ end
56
+
57
+ # callback after log in
58
+ def callback_login(user)
59
+ if cookies[:e_cart_id].present?
60
+ e_current_cart(ecommerce_get_visitor_key).change_user(user)
61
+ cookies.delete(:e_cart_id)
62
+ end
63
+ end
49
64
  end
@@ -1,20 +1,20 @@
1
1
  class Plugins::Ecommerce::CartDecorator < Draper::Decorator
2
2
  delegate_all
3
3
  def the_sub_total
4
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.sub_total)}"
4
+ h.e_parse_price(object.sub_total)
5
5
  end
6
6
 
7
7
  def the_total_discounts
8
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.total_discounts)}"
8
+ h.e_parse_price(object.total_discounts)
9
9
  end
10
10
 
11
11
  def the_total_amount
12
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.total_amount)}"
12
+ h.e_parse_price(object.total_amount)
13
13
  end
14
14
  alias_method :the_price, :the_total_amount
15
15
 
16
16
  def the_tax_total
17
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.tax_total)}"
17
+ h.e_parse_price(object.tax_total)
18
18
  end
19
19
 
20
20
  def the_weight_total
@@ -22,6 +22,6 @@ class Plugins::Ecommerce::CartDecorator < Draper::Decorator
22
22
  end
23
23
 
24
24
  def the_total_shipping
25
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.total_shipping)}"
25
+ h.e_parse_price(object.total_shipping)
26
26
  end
27
27
  end
@@ -1,52 +1,33 @@
1
1
  class Plugins::Ecommerce::CouponDecorator < CamaleonCms::TermTaxonomyDecorator
2
2
  delegate_all
3
3
 
4
- # Define presentation-specific methods here. Helpers are accessed through
5
- # `helpers` (aka `h`). You can override attributes, for example:
6
- #
7
- # def created_at
8
- # helpers.content_tag :span, class: 'time' do
9
- # object.created_at.strftime("%a %m/%d/%y")
10
- # end
11
- # end
12
-
4
+ # return the code of the coupon
13
5
  def the_code
14
6
  object.slug.to_s.upcase
15
7
  end
16
8
 
9
+ # return humanized the amount/value of the coupon
17
10
  def the_amount
18
11
  opts = object.options
19
12
  case opts[:discount_type]
20
13
  when 'percent'
21
14
  "#{opts[:amount].to_f}%"
22
15
  when 'money'
23
- "#{h.current_site.current_unit}#{opts[:amount].to_f}"
24
- else
25
- "Free"
26
- end
27
- end
28
-
29
- def the_symbol
30
- opts = object.options
31
- case opts[:discount_type]
32
- when 'percent'
33
- "%"
34
- when 'money'
35
- h.current_site.current_unit
16
+ h.e_parse_price(opts[:amount].to_f)
36
17
  else
37
- ""
18
+ I18n.t('plugins.ecommerce.table.free_shipping', default: 'Free Shipping')
38
19
  end
39
20
  end
40
21
 
22
+ # return the html text status of the coupon
41
23
  def the_status
42
24
  opts = object.options
43
25
  if "#{opts[:expirate_date]} 23:59:59".to_datetime.to_i < Time.now.to_i
44
- "<span class='label label-danger'>#{I18n.t('plugin.ecommerce.table.expired')} </span>"
26
+ "<span class='label label-danger'>#{I18n.t('plugins.ecommerce.table.expired')} </span>"
45
27
  elsif object.status.to_s.to_bool
46
- "<span class='label label-success'>#{I18n.t('plugin.ecommerce.active')} </span>"
28
+ "<span class='label label-success'>#{I18n.t('plugins.ecommerce.active')} </span>"
47
29
  else
48
- "<span class='label label-default'>#{I18n.t('plugin.ecommerce.not_active')} </span>"
30
+ "<span class='label label-default'>#{I18n.t('plugins.ecommerce.not_active')} </span>"
49
31
  end
50
-
51
32
  end
52
33
  end
@@ -2,7 +2,7 @@ class Plugins::Ecommerce::OrderDecorator < Draper::Decorator
2
2
  delegate_all
3
3
 
4
4
  def the_status(include_date_action = false)
5
- res = if object.bank_pending?
5
+ res = if object.bank_pending? || object.on_delivery_pending?
6
6
  "<span class='label label-warning'>#{h.t("plugins.ecommerce.messages.order_status.#{object.status}", default: object.status.titleize)}</span>"
7
7
  elsif object.canceled?
8
8
  "<span class='label label-danger'>#{h.t("plugins.ecommerce.messages.order_status.#{object.status}", default: object.status.titleize)}</span>"
@@ -8,12 +8,12 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
8
8
  if variation_id.present?
9
9
  get_variation(variation_id).sku
10
10
  else
11
- object.get_field_value('ecommerce_sku').to_s
11
+ is_variation_product? ? get_default_variation.sku : object.get_field_value('ecommerce_sku').to_s
12
12
  end
13
13
  end
14
14
 
15
15
  def the_price(variation_id = nil)
16
- "#{h.current_site.current_unit}#{sprintf('%.2f', price(variation_id))}"
16
+ h.e_parse_price(price(variation_id))
17
17
  end
18
18
 
19
19
  def the_weight(variation_id = nil)
@@ -24,7 +24,7 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
24
24
  if variation_id.present?
25
25
  get_variation(variation_id).weight || 0
26
26
  else
27
- object.get_field_value('ecommerce_weight').to_f || 0
27
+ is_variation_product? ? (get_default_variation.weight || 0) : object.get_field_value('ecommerce_weight').to_f || 0
28
28
  end
29
29
  end
30
30
 
@@ -32,10 +32,19 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
32
32
  if variation_id.present?
33
33
  get_variation(variation_id).qty || 0
34
34
  else
35
- object.get_field_value('ecommerce_qty') || 0
35
+ is_variation_product? ? (get_default_variation.qty || 0) : object.get_field_value('ecommerce_qty').to_i || 0
36
36
  end
37
37
  end
38
38
 
39
+ # return the total (Integer) of products available to sell (doesn't include the qty of the current cart)
40
+ def the_qty_real(variation_id = nil)
41
+ return the_qty_real(get_default_variation.id) if !variation_id.present? && is_variation_product?
42
+ carts = h.current_site.carts.active_cart.joins(:product_items)
43
+ _q = variation_id.present? ? {variation_id: variation_id} : {product_id: object.id}
44
+ _qty_in_carts = carts.where.not(id: h.e_current_cart.id).where("#{Plugins::Ecommerce::ProductItem.table_name}" => _q).sum("#{Plugins::Ecommerce::ProductItem.table_name}.qty")
45
+ the_qty - _qty_in_carts
46
+ end
47
+
39
48
  def the_photos
40
49
  object.get_field_values('ecommerce_photos') || []
41
50
  end
@@ -52,7 +61,7 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
52
61
  if variation_id.present?
53
62
  get_variation(variation_id).amount || 0
54
63
  else
55
- object.get_field_value(:ecommerce_price).to_f || 0
64
+ is_variation_product? ? (get_default_variation.amount || 0) : object.get_field_value(:ecommerce_price).to_f || 0
56
65
  end
57
66
  end
58
67
 
@@ -69,7 +78,7 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
69
78
  end
70
79
 
71
80
  def the_tax(variation_id = nil)
72
- tax(variation_id)
81
+ h.e_parse_price(tax(variation_id))
73
82
  end
74
83
 
75
84
  def tax(variation_id = nil)
@@ -84,9 +93,9 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
84
93
 
85
94
  def the_stock_status(variation_id = nil)
86
95
  if in_stock?(variation_id) && the_qty_real.to_i > 0
87
- "<span class='label label-success'>#{I18n.t('plugin.ecommerce.product.in_stock')}</span>"
96
+ "<span class='label label-success'>#{I18n.t('plugins.ecommerce.product.in_stock')}</span>"
88
97
  else
89
- "<span class='label label-danger'>#{I18n.t('plugin.ecommerce.product.not_in_tock')}</span>"
98
+ "<span class='label label-danger'>#{I18n.t('plugins.ecommerce.product.not_in_tock')}</span>"
90
99
  end
91
100
  end
92
101
 
@@ -96,23 +105,12 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
96
105
 
97
106
  def the_featured_status
98
107
  if eco_featured?
99
- "<span class='label label-primary'>#{I18n.t('plugin.ecommerce.product.featured')}</span>"
108
+ "<span class='label label-primary'>#{I18n.t('plugins.ecommerce.product.featured')}</span>"
100
109
  else
101
110
  ""
102
111
  end
103
112
  end
104
113
 
105
- # return the total of products available to sell
106
- def the_qty_real(variation_id = nil)
107
- if h.current_user
108
- Plugins::Ecommerce::UserProductService.new(
109
- h.current_site, h.current_user, object, variation_id).available_qty
110
- else
111
- Plugins::Ecommerce::ProductService.new(
112
- h.current_site, object, variation_id).available_qty
113
- end
114
- end
115
-
116
114
  # check if there are enough products to be purchased
117
115
  def can_added?(qty, variation_id = nil)
118
116
  (the_qty_real(variation_id) - qty).to_i >= 0
@@ -136,4 +134,19 @@ class Plugins::Ecommerce::ProductDecorator < CamaleonCms::PostDecorator
136
134
  def is_variation_product?
137
135
  @_cache_is_variation_product ||= self.product_variations.any?
138
136
  end
137
+
138
+ # return (Hash) all variations qty for each variation, sample: {1: 10, 5: 2, 3: 0}
139
+ def map_variations_the_qty_real
140
+ res = {}
141
+ return res unless is_variation_product?
142
+ object.product_variations.eager_load(:product).each do |var|
143
+ res[var.id] = var.product.decorate.the_qty_real
144
+ end
145
+ res
146
+ end
147
+
148
+ # return the first variation of a product
149
+ def get_default_variation
150
+ @_cama_cache_get_default_variation ||= object.product_variations.first
151
+ end
139
152
  end
@@ -5,7 +5,7 @@ class Plugins::Ecommerce::ProductItemDecorator < Draper::Decorator
5
5
  end
6
6
 
7
7
  def the_sub_total
8
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.sub_total)}"
8
+ h.e_parse_price(object.sub_total)
9
9
  end
10
10
 
11
11
  def the_price
@@ -31,7 +31,13 @@ class Plugins::Ecommerce::ProductItemDecorator < Draper::Decorator
31
31
 
32
32
  # update quantity of product or product variation used in current cart item
33
33
  def decrement_qty!
34
- Plugins::Ecommerce::ProductItemService.new(object.cart.site, object).decrement_qty!
34
+ val = get_product.the_qty(object.variation_id) - object.qty
35
+ if object.variation_id.present?
36
+ product_variation.update_column(:qty, val)
37
+ else
38
+ product.update_field_value('ecommerce_qty', val)
39
+ end
40
+ val
35
41
  end
36
42
 
37
43
  # verify if the quantity of the cart item is avilable
@@ -1,7 +1,7 @@
1
1
  class Plugins::Ecommerce::ProductVariationDecorator < Draper::Decorator
2
2
  delegate_all
3
3
  def the_price
4
- "#{h.current_site.current_unit}#{sprintf('%.2f', object.amount)}"
4
+ h.e_parse_price(object.amount)
5
5
  end
6
6
 
7
7
  def the_title
@@ -13,17 +13,17 @@ module Plugins::Ecommerce::EcommerceEmailHelper
13
13
 
14
14
  flash[:notice] = t('plugins.ecommerce.messages.payment_completed', default: "Payment completed successfully")
15
15
  args = {order: order}; hooks_run("commerce_after_payment_completed", args)
16
-
16
+
17
17
  order
18
18
  end
19
19
 
20
20
  def commerce_send_order_received_email(order, is_after_bank_confirmation = false)
21
21
  data = _commerce_prepare_send_order_email_data(order)
22
22
  if is_after_bank_confirmation
23
- cama_send_email(order.user.email, t('plugin.ecommerce.mail.order_confirmed.subject'), {template_name: 'order_confirmed', extra_data: data[:extra_data], attachs: data[:files]})
23
+ cama_send_email(order.user.email, t('plugins.ecommerce.mail.order_confirmed.subject'), {template_name: 'order_confirmed', extra_data: data[:extra_data], attachs: data[:files]})
24
24
  else
25
25
  data.delete(:files) unless order.paid?
26
- cama_send_email(order.user.email, t('plugin.ecommerce.email.order_received.subject'), {template_name: 'order_received', extra_data: data[:extra_data], attachs: data[:files]})
26
+ cama_send_email(order.user.email, t('plugins.ecommerce.email.order_received.subject'), {template_name: 'order_received', extra_data: data[:extra_data], attachs: data[:files]})
27
27
  end
28
28
  end
29
29
 
@@ -31,7 +31,7 @@ module Plugins::Ecommerce::EcommerceEmailHelper
31
31
  data = _commerce_prepare_send_order_email_data(order)
32
32
  data[:owners].each do |user|
33
33
  data[:extra_data][:admin] = user
34
- cama_send_email(user.email, t('plugin.ecommerce.email.order_received_admin.subject'), {template_name: 'order_received_admin', extra_data: data[:extra_data], attachs: data[:files]})
34
+ cama_send_email(user.email, t('plugins.ecommerce.email.order_received_admin.subject'), {template_name: 'order_received_admin', extra_data: data[:extra_data], attachs: data[:files]})
35
35
  end
36
36
  end
37
37
 
@@ -40,7 +40,7 @@ module Plugins::Ecommerce::EcommerceEmailHelper
40
40
  :fullname => order.user.fullname,
41
41
  :order => order
42
42
  }
43
- send_email(order.user.email, t('plugin.ecommerce.email.recovery_cart.subject'), '', nil, [], 'recovery_cart', nil, extra_data)
43
+ send_email(order.user.email, t('plugins.ecommerce.email.recovery_cart.subject'), '', nil, [], 'recovery_cart', nil, extra_data)
44
44
  Rails.logger.info "Send recovery to #{order.user.email} with order #{order.slug}"
45
45
  end
46
46
 
@@ -96,7 +96,8 @@ module Plugins::Ecommerce::EcommerceEmailHelper
96
96
  :shipping_address => order.get_meta('shipping_address'),
97
97
  :subtotal => order.cache_the_sub_total,
98
98
  :total_cost => order.cache_the_total,
99
- :order => order
99
+ :order => order,
100
+ :order_details_html => render_to_string(file: 'plugins/ecommerce/front/orders/show', layout: false, locals: {as_partial: true, order: order.decorated? ? order : order.decorate})
100
101
  }
101
102
  order_service = Plugins::Ecommerce::OrderService.new(current_site, order)
102
103
  data[:owners] = order_service.product_owners
@@ -1,47 +1,291 @@
1
1
  #encoding: utf-8
2
2
  module Plugins::Ecommerce::EcommerceFunctionsHelper
3
- def self.included(klass)
4
- klass.helper_method [:e_get_currency_units, :e_get_currency_weight, :e_symbol_by_code, :ecommerce_custom_payment_methods] rescue ""
5
- end
6
- def e_get_currency_weight
7
- r = {}
8
- JSON.parse('[{"code":"kg","name":'+"#{t('plugin.ecommerce.select.kilogram').to_json}"'},{"code":"lb","name":'+"#{t('plugin.ecommerce.select.pound').to_json}"'},{"code":"dr","name":'+"#{t('plugin.ecommerce.select.dram').to_json}"'},{"code":"gr","name":'+"#{t('plugin.ecommerce.select.grain').to_json}"'},{"code":"g","name":'+"#{t('plugin.ecommerce.select.gram').to_json}"'},{"code":"UK","name":'+"#{t('plugin.ecommerce.select.hundredweight').to_json}"'},{"code":"mg","name":'+"#{t('plugin.ecommerce.select.milligram').to_json}"'},{"code":"oz","name":'+"#{t('plugin.ecommerce.select.ounce').to_json}"'},{"code":"t","name":'+"#{t('plugin.ecommerce.select.tonne').to_json}"'}]').collect do |item|
9
- item['name'] = item['name'].to_s.titleize
10
- r[item['code']] = item
3
+ # return the settings for ecommerce (Hash)
4
+ def ecommerce_get_settings
5
+ current_site.get_meta("_setting_ecommerce", {})
6
+ end
7
+
8
+ # return the visitor key which is used to relate the cart until login/register
9
+ def ecommerce_get_visitor_key
10
+ cookies[:e_cart_id] ||= cama_get_session_id unless cama_current_user.present?
11
+ end
12
+
13
+ # return the current cart for current user
14
+ def e_current_cart(custom_visitor_key = nil)
15
+ @_cache_e_current_cart ||= current_site.carts.set_user(custom_visitor_key || cama_current_user || ecommerce_get_visitor_key).active_cart.first_or_create(name: "Cart by #{Time.current.to_s}").decorate
16
+ end
17
+
18
+ # return all shipping country codes supported for shipping
19
+ def e_shipping_countries
20
+ ecommerce_get_settings[:shipping_countries] || ISO3166::Country.codes
21
+ end
22
+
23
+ # return (Array) all the currencies for visitors
24
+ def e_visitor_unit_currencies
25
+ ecommerce_get_settings[:visitor_unit_currencies] || ['USD']
26
+ end
27
+
28
+ # draw a select dropdown with all frontend currencies and actions to change current currency
29
+ # long_mode: (Boolean, default false)
30
+ # attrs = (Hash) attributes of the select drodown, sample: {class: 'form-control'}
31
+ def e_draw_ecommerce_currencies(long_mode = false, attrs = {})
32
+ return '' if e_visitor_unit_currencies.count <= 1
33
+ res = '<select '+attrs.collect{|k, v| "#{k}='#{v}'" }.join(" ")+' onchange="window.location.href=window.location.href.split(\'cama_change_currency\')[0]+(window.location.href.search(\'\\\?\') > 1 ? \'&\' : \'?\')+\'cama_change_currency=\'+this.value">'
34
+ e_visitor_unit_currencies.each do |unit|
35
+ cur = e_get_currency_by_code(unit)
36
+ res << "<option value='#{unit}' #{'selected' if e_current_visitor_currency == unit}>#{long_mode ? "#{cur[:label]} (#{cur[:symbol]})": cur[:symbol]}</option>"
11
37
  end
12
- @e_get_currency_weight ||= r
38
+ res << '</select>'
13
39
  end
14
40
 
15
- def e_get_currency_units
16
- @e_get_currency_units ||= lambda{
17
- file = File.read("#{File.dirname(__FILE__)}/../../../../config/currency.json")
18
- args = {currencies: JSON.parse(file)}; hooks_run("ecommerce_currencies", args)
19
- args[:currencies]
41
+ # set a new currency if new_currency is present
42
+ # return current currency defined by the current visitor
43
+ def e_current_visitor_currency(new_currency = nil)
44
+ session[:e_current_visitor_currency] = new_currency if new_currency.present?
45
+ session[:e_current_visitor_currency] || 'USD'
46
+ end
47
+
48
+ # return all currency weights supported by the plugin
49
+ def e_get_currency_weights
50
+ @_cache_e_get_currency_weights ||= lambda{
51
+ weights = {kg: t('plugins.ecommerce.select.kilogram'), lb: t('plugins.ecommerce.select.pound'), dr: t('plugins.ecommerce.select.dram'), gr: t('plugins.ecommerce.select.grain'), g: t('plugins.ecommerce.select.gram'), mg: t('plugins.ecommerce.select.milligram'), oz: t('plugins.ecommerce.select.ounce'), t: t('plugins.ecommerce.select.tonne'), UK: t('plugins.ecommerce.select.hundredweight')}
52
+ hooks_run('ecommerce_weights', weights)
53
+ weights
20
54
  }.call
21
55
  end
22
56
 
23
- def e_symbol_by_code(unit)
24
- e_get_currency_units[unit]['symbol'] rescue '$xx'
57
+ # return the currency details with code = code
58
+ def e_get_currency_by_code(code)
59
+ e_get_all_currencies[code.to_s.upcase] || {}
60
+ end
61
+
62
+ # return the currency defined for admin panel
63
+ def e_system_currency
64
+ ecommerce_get_settings[:current_unit] || 'USD'
25
65
  end
26
66
 
27
- # use in add cart
28
- def e_add_data_product(data, product_id)
29
- post = CamaleonCms::Post.find(product_id).decorate
30
- attributes = post.attributes
31
- attributes[:content] = ''
32
- data[:product_title] = post.the_title
33
- data[:price] = post.get_field_value(:ecommerce_price)
34
- data[:weight] = post.get_field_value(:ecommerce_weight)
35
- data[:tax_rate_id] = post.get_field_value(:ecommerce_tax)
36
- tax_product = current_site.tax_rates.find(data[:tax_rate_id]).options[:rate].to_f rescue 0
37
- data[:tax_percent] = tax_product
38
- data[:tax] = data[:price].to_f * data[:tax_percent] / 100 rescue 0
39
- data[:currency_code] = current_site.currency_code
40
- metas = {}
41
- post.metas.map{|m| metas[m.key] = m.value }
42
- data.merge(post: attributes, fields: post.get_field_values_hash, meta: metas)
67
+ # render price formatted of a product with current currency
68
+ def e_parse_price(price)
69
+ currency = cama_is_admin_request? ? e_system_currency : e_current_visitor_currency
70
+ args = {currency: currency, price: price, data: "#{currency} #{sprintf('%.2f', e_parse_to_current_currency(price))}"}; hooks_run('ecommerce_parse_price', args) # permit to customize price format
71
+ args[:data]
43
72
  end
44
73
 
74
+ # convert the amount of system currency into visitor current currency
75
+ # amount: (Number) which will be exchanged into current visitor's currency
76
+ # return the modified amount (Integer)
77
+ def e_parse_to_current_currency(amount)
78
+ amount = amount.to_f
79
+ args = {amount: amount, from: e_system_currency, to: e_current_visitor_currency, exchange: nil}
80
+ return amount if cama_is_admin_request? || args[:from] == args[:to] || amount.to_f.round(2) == 0.00
81
+
82
+ currency = cama_ecommerce_post_type.get_option(e_current_visitor_currency, {}, 'currencies')
83
+ return (currency[:exchange] * amount).round(2) if currency[:date] == Date.today.to_s && currency[:base] == e_system_currency
84
+
85
+ hooks_run('ecommerce_calculate_exchange', args) # permit to use custom exchange app by setting the value in :exchange attribute
86
+ return (args[:exchange] * amount).round(2) if args[:exchange].present?
87
+
88
+ # request to google's finance converter site
89
+ res = open("https://www.google.com/finance/converter?a=1&from=#{args[:from]}&to=#{args[:to]}").read
90
+ res = res.scan(/\<span class=bld\>(.+?)\<\/span\>/).first.first.split(' ') # => ["69.3000", "BOB"]
91
+ exchange = res.first.to_f.round(4)
92
+ cama_ecommerce_post_type.set_option(e_current_visitor_currency, {date: Date.today.to_s, exchange: exchange, base: e_system_currency}, 'currencies')
93
+ (exchange * amount).round(2)
94
+ end
95
+
96
+ # return all currencies to use as a base currency
97
+ def e_get_all_currencies
98
+ @_cache_e_get_all_currencies ||= lambda{
99
+ currencies = {
100
+ 'AED' => {symbol: 'AED', label: t('plugins.ecommerce.currencies.aed', default: 'United Arab Emirates Dirham')},
101
+ 'AFN' => {symbol: 'AFN', label: t('plugins.ecommerce.currencies.afn', default: 'Afghan Afghani')},
102
+ 'ALL' => {symbol: 'ALL', label: t('plugins.ecommerce.currencies.all', default: 'Albanian Lek')},
103
+ 'AMD' => {symbol: 'AMD', label: t('plugins.ecommerce.currencies.amd', default: 'Armenian Dram')},
104
+ 'ANG' => {symbol: 'ANG', label: t('plugins.ecommerce.currencies.ang', default: 'Netherlands Antillean Guilder')},
105
+ 'AOA' => {symbol: 'AOA', label: t('plugins.ecommerce.currencies.aoa', default: 'Angolan Kwanza')},
106
+ 'ARS' => {symbol: 'ARS', label: t('plugins.ecommerce.currencies.ars', default: 'Argentine Peso')},
107
+ 'AUD' => {symbol: 'A$', label: t('plugins.ecommerce.currencies.aud', default: 'Australian Dollar')},
108
+ 'AWG' => {symbol: 'AWG', label: t('plugins.ecommerce.currencies.awg', default: 'Aruban Florin')},
109
+ 'AZN' => {symbol: 'AZN', label: t('plugins.ecommerce.currencies.azn', default: 'Azerbaijani Manat')},
110
+ 'BAM' => {symbol: 'BAM', label: t('plugins.ecommerce.currencies.bam', default: 'Bosnia-Herzegovina Convertible Mark')},
111
+ 'BBD' => {symbol: 'BBD', label: t('plugins.ecommerce.currencies.bbd', default: 'Barbadian Dollar')},
112
+ 'BDT' => {symbol: 'BDT', label: t('plugins.ecommerce.currencies.bdt', default: 'Bangladeshi Taka')},
113
+ 'BGN' => {symbol: 'BGN', label: t('plugins.ecommerce.currencies.bgn', default: 'Bulgarian Lev')},
114
+ 'BHD' => {symbol: 'BHD', label: t('plugins.ecommerce.currencies.bhd', default: 'Bahraini Dinar')},
115
+ 'BIF' => {symbol: 'BIF', label: t('plugins.ecommerce.currencies.bif', default: 'Burundian Franc')},
116
+ 'BMD' => {symbol: 'BMD', label: t('plugins.ecommerce.currencies.bmd', default: 'Bermudan Dollar')},
117
+ 'BND' => {symbol: 'BND', label: t('plugins.ecommerce.currencies.bnd', default: 'Brunei Dollar')},
118
+ 'BOB' => {symbol: 'BOB', label: t('plugins.ecommerce.currencies.bob', default: 'Bolivian Boliviano')},
119
+ 'BRL' => {symbol: 'R$', label: t('plugins.ecommerce.currencies.brl', default: 'Brazilian Real')},
120
+ 'BSD' => {symbol: 'BSD', label: t('plugins.ecommerce.currencies.bsd', default: 'Bahamian Dollar')},
121
+ 'BTC' => {symbol: '฿', label: t('plugins.ecommerce.currencies.btc', default: 'Bitcoin')},
122
+ 'BTN' => {symbol: 'BTN', label: t('plugins.ecommerce.currencies.btn', default: 'Bhutanese Ngultrum')},
123
+ 'BWP' => {symbol: 'BWP', label: t('plugins.ecommerce.currencies.bwp', default: 'Botswanan Pula')},
124
+ 'BYN' => {symbol: 'BYN', label: t('plugins.ecommerce.currencies.byn', default: 'Belarusian Ruble')},
125
+ 'BYR' => {symbol: '2000-2016 ', label: t('plugins.ecommerce.currencies.byr', default: 'Belarusian Ruble')},
126
+ 'BZD' => {symbol: 'BZD', label: t('plugins.ecommerce.currencies.bzd', default: 'Belize Dollar')},
127
+ 'CAD' => {symbol: 'CA$', label: t('plugins.ecommerce.currencies.cad', default: 'Canadian Dollar')},
128
+ 'CDF' => {symbol: 'CDF', label: t('plugins.ecommerce.currencies.cdf', default: 'Congolese Franc')},
129
+ 'CHF' => {symbol: 'CHF', label: t('plugins.ecommerce.currencies.chf', default: 'Swiss Franc')},
130
+ 'CLF' => {symbol: 'UF ', label: t('plugins.ecommerce.currencies.clf', default: 'Chilean Unit of Account')},
131
+ 'CLP' => {symbol: 'CLP', label: t('plugins.ecommerce.currencies.clp', default: 'Chilean Peso')},
132
+ 'CNH' => {symbol: 'CNH', label: t('plugins.ecommerce.currencies.cnh', default: 'CNH')},
133
+ 'CNY' => {symbol: 'CN¥', label: t('plugins.ecommerce.currencies.cny', default: 'Chinese Yuan')},
134
+ 'COP' => {symbol: 'COP', label: t('plugins.ecommerce.currencies.cop', default: 'Colombian Peso')},
135
+ 'CRC' => {symbol: 'CRC', label: t('plugins.ecommerce.currencies.crc', default: 'Costa Rican Colón')},
136
+ 'CUP' => {symbol: 'CUP', label: t('plugins.ecommerce.currencies.cup', default: 'Cuban Peso')},
137
+ 'CVE' => {symbol: 'CVE', label: t('plugins.ecommerce.currencies.cve', default: 'Cape Verdean Escudo')},
138
+ 'CZK' => {symbol: 'CZK', label: t('plugins.ecommerce.currencies.czk', default: 'Czech Republic Koruna')},
139
+ 'DEM' => {symbol: 'DEM', label: t('plugins.ecommerce.currencies.dem', default: 'German Mark')},
140
+ 'DJF' => {symbol: 'DJF', label: t('plugins.ecommerce.currencies.djf', default: 'Djiboutian Franc')},
141
+ 'DKK' => {symbol: 'DKK', label: t('plugins.ecommerce.currencies.dkk', default: 'Danish Krone')},
142
+ 'DOP' => {symbol: 'DOP', label: t('plugins.ecommerce.currencies.dop', default: 'Dominican Peso')},
143
+ 'DZD' => {symbol: 'DZD', label: t('plugins.ecommerce.currencies.dzd', default: 'Algerian Dinar')},
144
+ 'EGP' => {symbol: 'EGP', label: t('plugins.ecommerce.currencies.egp', default: 'Egyptian Pound')},
145
+ 'ERN' => {symbol: 'ERN', label: t('plugins.ecommerce.currencies.ern', default: 'Eritrean Nakfa')},
146
+ 'ETB' => {symbol: 'ETB', label: t('plugins.ecommerce.currencies.etb', default: 'Ethiopian Birr')},
147
+ 'EUR' => {symbol: '€', label: t('plugins.ecommerce.currencies.eur', default: 'Euro')},
148
+ 'FIM' => {symbol: 'FIM', label: t('plugins.ecommerce.currencies.fim', default: 'Finnish Markka')},
149
+ 'FJD' => {symbol: 'FJD', label: t('plugins.ecommerce.currencies.fjd', default: 'Fijian Dollar')},
150
+ 'FKP' => {symbol: 'FKP', label: t('plugins.ecommerce.currencies.fkp', default: 'Falkland Islands Pound')},
151
+ 'FRF' => {symbol: 'FRF', label: t('plugins.ecommerce.currencies.frf', default: 'French Franc')},
152
+ 'GBP' => {symbol: '£', label: t('plugins.ecommerce.currencies.gbp', default: 'British Pound')},
153
+ 'GEL' => {symbol: 'GEL', label: t('plugins.ecommerce.currencies.gel', default: 'Georgian Lari')},
154
+ 'GHS' => {symbol: 'GHS', label: t('plugins.ecommerce.currencies.ghs', default: 'Ghanaian Cedi')},
155
+ 'GIP' => {symbol: 'GIP', label: t('plugins.ecommerce.currencies.gip', default: 'Gibraltar Pound')},
156
+ 'GMD' => {symbol: 'GMD', label: t('plugins.ecommerce.currencies.gmd', default: 'Gambian Dalasi')},
157
+ 'GNF' => {symbol: 'GNF', label: t('plugins.ecommerce.currencies.gnf', default: 'Guinean Franc')},
158
+ 'GTQ' => {symbol: 'GTQ', label: t('plugins.ecommerce.currencies.gtq', default: 'Guatemalan Quetzal')},
159
+ 'GYD' => {symbol: 'GYD', label: t('plugins.ecommerce.currencies.gyd', default: 'Guyanaese Dollar')},
160
+ 'HKD' => {symbol: 'HK$', label: t('plugins.ecommerce.currencies.hkd', default: 'Hong Kong Dollar')},
161
+ 'HNL' => {symbol: 'HNL', label: t('plugins.ecommerce.currencies.hnl', default: 'Honduran Lempira')},
162
+ 'HRK' => {symbol: 'HRK', label: t('plugins.ecommerce.currencies.hrk', default: 'Croatian Kuna')},
163
+ 'HTG' => {symbol: 'HTG', label: t('plugins.ecommerce.currencies.htg', default: 'Haitian Gourde')},
164
+ 'HUF' => {symbol: 'HUF', label: t('plugins.ecommerce.currencies.huf', default: 'Hungarian Forint')},
165
+ 'IDR' => {symbol: 'IDR', label: t('plugins.ecommerce.currencies.idr', default: 'Indonesian Rupiah')},
166
+ 'IEP' => {symbol: 'IEP', label: t('plugins.ecommerce.currencies.iep', default: 'Irish Pound')},
167
+ 'ILS' => {symbol: '₪', label: t('plugins.ecommerce.currencies.ils', default: 'Israeli New Sheqel')},
168
+ 'INR' => {symbol: '₹', label: t('plugins.ecommerce.currencies.inr', default: 'Indian Rupee')},
169
+ 'IQD' => {symbol: 'IQD', label: t('plugins.ecommerce.currencies.iqd', default: 'Iraqi Dinar')},
170
+ 'IRR' => {symbol: 'IRR', label: t('plugins.ecommerce.currencies.irr', default: 'Iranian Rial')},
171
+ 'ISK' => {symbol: 'ISK', label: t('plugins.ecommerce.currencies.isk', default: 'Icelandic Króna')},
172
+ 'ITL' => {symbol: 'ITL', label: t('plugins.ecommerce.currencies.itl', default: 'Italian Lira')},
173
+ 'JMD' => {symbol: 'JMD', label: t('plugins.ecommerce.currencies.jmd', default: 'Jamaican Dollar')},
174
+ 'JOD' => {symbol: 'JOD', label: t('plugins.ecommerce.currencies.jod', default: 'Jordanian Dinar')},
175
+ 'JPY' => {symbol: '¥', label: t('plugins.ecommerce.currencies.jpy', default: 'Japanese Yen')},
176
+ 'KES' => {symbol: 'KES', label: t('plugins.ecommerce.currencies.kes', default: 'Kenyan Shilling')},
177
+ 'KGS' => {symbol: 'KGS', label: t('plugins.ecommerce.currencies.kgs', default: 'Kyrgystani Som')},
178
+ 'KHR' => {symbol: 'KHR', label: t('plugins.ecommerce.currencies.khr', default: 'Cambodian Riel')},
179
+ 'KMF' => {symbol: 'KMF', label: t('plugins.ecommerce.currencies.kmf', default: 'Comorian Franc')},
180
+ 'KPW' => {symbol: 'KPW', label: t('plugins.ecommerce.currencies.kpw', default: 'North Korean Won')},
181
+ 'KRW' => {symbol: '₩', label: t('plugins.ecommerce.currencies.krw', default: 'South Korean Won')},
182
+ 'KWD' => {symbol: 'KWD', label: t('plugins.ecommerce.currencies.kwd', default: 'Kuwaiti Dinar')},
183
+ 'KYD' => {symbol: 'KYD', label: t('plugins.ecommerce.currencies.kyd', default: 'Cayman Islands Dollar')},
184
+ 'KZT' => {symbol: 'KZT', label: t('plugins.ecommerce.currencies.kzt', default: 'Kazakhstani Tenge')},
185
+ 'LAK' => {symbol: 'LAK', label: t('plugins.ecommerce.currencies.lak', default: 'Laotian Kip')},
186
+ 'LBP' => {symbol: 'LBP', label: t('plugins.ecommerce.currencies.lbp', default: 'Lebanese Pound')},
187
+ 'LKR' => {symbol: 'LKR', label: t('plugins.ecommerce.currencies.lkr', default: 'Sri Lankan Rupee')},
188
+ 'LRD' => {symbol: 'LRD', label: t('plugins.ecommerce.currencies.lrd', default: 'Liberian Dollar')},
189
+ 'LSL' => {symbol: 'LSL', label: t('plugins.ecommerce.currencies.lsl', default: 'Lesotho Loti')},
190
+ 'LTL' => {symbol: 'LTL', label: t('plugins.ecommerce.currencies.ltl', default: 'Lithuanian Litas')},
191
+ 'LVL' => {symbol: 'LVL', label: t('plugins.ecommerce.currencies.lvl', default: 'Latvian Lats')},
192
+ 'LYD' => {symbol: 'LYD', label: t('plugins.ecommerce.currencies.lyd', default: 'Libyan Dinar')},
193
+ 'MAD' => {symbol: 'MAD', label: t('plugins.ecommerce.currencies.mad', default: 'Moroccan Dirham')},
194
+ 'MDL' => {symbol: 'MDL', label: t('plugins.ecommerce.currencies.mdl', default: 'Moldovan Leu')},
195
+ 'MGA' => {symbol: 'MGA', label: t('plugins.ecommerce.currencies.mga', default: 'Malagasy Ariary')},
196
+ 'MKD' => {symbol: 'MKD', label: t('plugins.ecommerce.currencies.mkd', default: 'Macedonian Denar')},
197
+ 'MMK' => {symbol: 'MMK', label: t('plugins.ecommerce.currencies.mmk', default: 'Myanmar Kyat')},
198
+ 'MNT' => {symbol: 'MNT', label: t('plugins.ecommerce.currencies.mnt', default: 'Mongolian Tugrik')},
199
+ 'MOP' => {symbol: 'MOP', label: t('plugins.ecommerce.currencies.mop', default: 'Macanese Pataca')},
200
+ 'MRO' => {symbol: 'MRO', label: t('plugins.ecommerce.currencies.mro', default: 'Mauritanian Ouguiya')},
201
+ 'MUR' => {symbol: 'MUR', label: t('plugins.ecommerce.currencies.mur', default: 'Mauritian Rupee')},
202
+ 'MVR' => {symbol: 'MVR', label: t('plugins.ecommerce.currencies.mvr', default: 'Maldivian Rufiyaa')},
203
+ 'MWK' => {symbol: 'MWK', label: t('plugins.ecommerce.currencies.mwk', default: 'Malawian Kwacha')},
204
+ 'MXN' => {symbol: 'MX$', label: t('plugins.ecommerce.currencies.mxn', default: 'Mexican Peso')},
205
+ 'MYR' => {symbol: 'MYR', label: t('plugins.ecommerce.currencies.myr', default: 'Malaysian Ringgit')},
206
+ 'MZN' => {symbol: 'MZN', label: t('plugins.ecommerce.currencies.mzn', default: 'Mozambican Metical')},
207
+ 'NAD' => {symbol: 'NAD', label: t('plugins.ecommerce.currencies.nad', default: 'Namibian Dollar')},
208
+ 'NGN' => {symbol: 'NGN', label: t('plugins.ecommerce.currencies.ngn', default: 'Nigerian Naira')},
209
+ 'NIO' => {symbol: 'NIO', label: t('plugins.ecommerce.currencies.nio', default: 'Nicaraguan Córdoba')},
210
+ 'NOK' => {symbol: 'NOK', label: t('plugins.ecommerce.currencies.nok', default: 'Norwegian Krone')},
211
+ 'NPR' => {symbol: 'NPR', label: t('plugins.ecommerce.currencies.npr', default: 'Nepalese Rupee')},
212
+ 'NZD' => {symbol: 'NZ$', label: t('plugins.ecommerce.currencies.nzd', default: 'New Zealand Dollar')},
213
+ 'OMR' => {symbol: 'OMR', label: t('plugins.ecommerce.currencies.omr', default: 'Omani Rial')},
214
+ 'PAB' => {symbol: 'PAB', label: t('plugins.ecommerce.currencies.pab', default: 'Panamanian Balboa')},
215
+ 'PEN' => {symbol: 'PEN', label: t('plugins.ecommerce.currencies.pen', default: 'Peruvian Nuevo Sol')},
216
+ 'PGK' => {symbol: 'PGK', label: t('plugins.ecommerce.currencies.pgk', default: 'Papua New Guinean Kina')},
217
+ 'PHP' => {symbol: 'PHP', label: t('plugins.ecommerce.currencies.php', default: 'Philippine Peso')},
218
+ 'PKG' => {symbol: 'PKG', label: t('plugins.ecommerce.currencies.pkg', default: 'PKG')},
219
+ 'PKR' => {symbol: 'PKR', label: t('plugins.ecommerce.currencies.pkr', default: 'Pakistani Rupee')},
220
+ 'PLN' => {symbol: 'PLN', label: t('plugins.ecommerce.currencies.pln', default: 'Polish Zloty')},
221
+ 'PYG' => {symbol: 'PYG', label: t('plugins.ecommerce.currencies.pyg', default: 'Paraguayan Guarani')},
222
+ 'QAR' => {symbol: 'QAR', label: t('plugins.ecommerce.currencies.qar', default: 'Qatari Rial')},
223
+ 'RON' => {symbol: 'RON', label: t('plugins.ecommerce.currencies.ron', default: 'Romanian Leu')},
224
+ 'RSD' => {symbol: 'RSD', label: t('plugins.ecommerce.currencies.rsd', default: 'Serbian Dinar')},
225
+ 'RUB' => {symbol: 'RUB', label: t('plugins.ecommerce.currencies.rub', default: 'Russian Ruble')},
226
+ 'RWF' => {symbol: 'RWF', label: t('plugins.ecommerce.currencies.rwf', default: 'Rwandan Franc')},
227
+ 'SAR' => {symbol: 'SAR', label: t('plugins.ecommerce.currencies.sar', default: 'Saudi Riyal')},
228
+ 'SBD' => {symbol: 'SBD', label: t('plugins.ecommerce.currencies.sbd', default: 'Solomon Islands Dollar')},
229
+ 'SCR' => {symbol: 'SCR', label: t('plugins.ecommerce.currencies.scr', default: 'Seychellois Rupee')},
230
+ 'SDG' => {symbol: 'SDG', label: t('plugins.ecommerce.currencies.sdg', default: 'Sudanese Pound')},
231
+ 'SEK' => {symbol: 'SEK', label: t('plugins.ecommerce.currencies.sek', default: 'Swedish Krona')},
232
+ 'SGD' => {symbol: 'SGD', label: t('plugins.ecommerce.currencies.sgd', default: 'Singapore Dollar')},
233
+ 'SHP' => {symbol: 'SHP', label: t('plugins.ecommerce.currencies.shp', default: 'St. Helena Pound')},
234
+ 'SKK' => {symbol: 'SKK', label: t('plugins.ecommerce.currencies.skk', default: 'Slovak Koruna')},
235
+ 'SLL' => {symbol: 'SLL', label: t('plugins.ecommerce.currencies.sll', default: 'Sierra Leonean Leone')},
236
+ 'SOS' => {symbol: 'SOS', label: t('plugins.ecommerce.currencies.sos', default: 'Somali Shilling')},
237
+ 'SRD' => {symbol: 'SRD', label: t('plugins.ecommerce.currencies.srd', default: 'Surinamese Dollar')},
238
+ 'STD' => {symbol: 'STD', label: t('plugins.ecommerce.currencies.std', default: 'São Tomé & Príncipe Dobra')},
239
+ 'SVC' => {symbol: 'SVC', label: t('plugins.ecommerce.currencies.svc', default: 'Salvadoran Colón')},
240
+ 'SYP' => {symbol: 'SYP', label: t('plugins.ecommerce.currencies.syp', default: 'Syrian Pound')},
241
+ 'SZL' => {symbol: 'SZL', label: t('plugins.ecommerce.currencies.szl', default: 'Swazi Lilangeni')},
242
+ 'THB' => {symbol: 'THB', label: t('plugins.ecommerce.currencies.thb', default: 'Thai Baht')},
243
+ 'TJS' => {symbol: 'TJS', label: t('plugins.ecommerce.currencies.tjs', default: 'Tajikistani Somoni')},
244
+ 'TMT' => {symbol: 'TMT', label: t('plugins.ecommerce.currencies.tmt', default: 'Turkmenistani Manat')},
245
+ 'TND' => {symbol: 'TND', label: t('plugins.ecommerce.currencies.tnd', default: 'Tunisian Dinar')},
246
+ 'TOP' => {symbol: 'TOP', label: t('plugins.ecommerce.currencies.top', default: 'Tongan Paʻanga')},
247
+ 'TRY' => {symbol: 'TRY', label: t('plugins.ecommerce.currencies.try', default: 'Turkish Lira')},
248
+ 'TTD' => {symbol: 'TTD', label: t('plugins.ecommerce.currencies.ttd', default: 'Trinidad & Tobago Dollar')},
249
+ 'TWD' => {symbol: 'NT$', label: t('plugins.ecommerce.currencies.twd', default: 'New Taiwan Dollar')},
250
+ 'TZS' => {symbol: 'TZS', label: t('plugins.ecommerce.currencies.tzs', default: 'Tanzanian Shilling')},
251
+ 'UAH' => {symbol: 'UAH', label: t('plugins.ecommerce.currencies.uah', default: 'Ukrainian Hryvnia')},
252
+ 'UGX' => {symbol: 'UGX', label: t('plugins.ecommerce.currencies.ugx', default: 'Ugandan Shilling')},
253
+ 'USD' => {symbol: '$', label: t('plugins.ecommerce.currencies.usd', default: 'US Dollar')},
254
+ 'UYU' => {symbol: 'UYU', label: t('plugins.ecommerce.currencies.uyu', default: 'Uruguayan Peso')},
255
+ 'UZS' => {symbol: 'UZS', label: t('plugins.ecommerce.currencies.uzs', default: 'Uzbekistani Som')},
256
+ 'VEF' => {symbol: 'VEF', label: t('plugins.ecommerce.currencies.vef', default: 'Venezuelan Bolívar')},
257
+ 'VND' => {symbol: '₫', label: t('plugins.ecommerce.currencies.vnd', default: 'Vietnamese Dong')},
258
+ 'VUV' => {symbol: 'VUV', label: t('plugins.ecommerce.currencies.vuv', default: 'Vanuatu Vatu')},
259
+ 'WST' => {symbol: 'WST', label: t('plugins.ecommerce.currencies.wst', default: 'Samoan Tala')},
260
+ 'XAF' => {symbol: 'FCFA', label: t('plugins.ecommerce.currencies.xaf', default: 'Central African CFA Franc')},
261
+ 'XCD' => {symbol: 'EC$', label: t('plugins.ecommerce.currencies.xcd', default: 'East Caribbean Dollar')},
262
+ 'XDR' => {symbol: 'XDR', label: t('plugins.ecommerce.currencies.xdr', default: 'Special Drawing Rights')},
263
+ 'XOF' => {symbol: 'CFA', label: t('plugins.ecommerce.currencies.xof', default: 'West African CFA Franc')},
264
+ 'XPF' => {symbol: 'CFPF', label: t('plugins.ecommerce.currencies.xpf', default: 'CFP Franc')},
265
+ 'YER' => {symbol: 'YER', label: t('plugins.ecommerce.currencies.yer', default: 'Yemeni Rial')},
266
+ 'ZAR' => {symbol: 'ZAR', label: t('plugins.ecommerce.currencies.zar', default: 'South African Rand')},
267
+ 'ZMK' => {symbol: '1968–2012 ', label: t('plugins.ecommerce.currencies.zmk', default: 'Zambian Kwacha')},
268
+ 'ZMW' => {symbol: 'ZMW', label: t('plugins.ecommerce.currencies.zmw', default: 'Zambian Kwacha')},
269
+ 'ZWL' => {symbol: '2009 ', label: t('plugins.ecommerce.currencies.zwl', default: 'Zimbabwean Dollar')}
270
+ }
271
+ hooks_run('ecommerce_currencies', currencies)
272
+ currencies
273
+ }.call
274
+ end
275
+
276
+ def ecommerce_draw_breadcrumb
277
+ res = '<ol class="breadcrumb" style="margin: 0;">'
278
+ @ecommerce_breadcrumb.each_with_index do |m, index|
279
+ if m[1].present?
280
+ res << "<li class='#{"active" if @ecommerce_breadcrumb.size == index+1}'><a href='#{m[1]}'>#{m[0]}</a></li>"
281
+ else
282
+ res << "<li class='#{"active" if @ecommerce_breadcrumb.size == index+1}'><span>#{m[0]}</span></li>"
283
+ end
284
+ end
285
+ res << '</ol>'
286
+ end
287
+
288
+ # permit to add custom payment methods by hooks
45
289
  def ecommerce_custom_payment_methods
46
290
  @_ecommerce_custom_payment_methods ||= lambda{
47
291
  args = {custom_payment_methods: {}}; hooks_run("ecommerce_custom_payment_methods", args)
@@ -59,5 +303,4 @@ module Plugins::Ecommerce::EcommerceFunctionsHelper
59
303
  args[:custom_payment_methods]
60
304
  }.call
61
305
  end
62
-
63
306
  end