camaleon_ecommerce 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/plugins/ecommerce/admin.js +33 -0
  6. data/app/assets/javascripts/plugins/ecommerce/cart.js +207 -0
  7. data/app/assets/javascripts/plugins/ecommerce/fix_form.js +10 -0
  8. data/app/assets/javascripts/plugins/ecommerce/jquery.creditCardValidator.js +208 -0
  9. data/app/assets/stylesheets/plugins/ecommerce/admin.scss +122 -0
  10. data/app/assets/stylesheets/plugins/ecommerce/front.scss +36 -0
  11. data/app/controllers/plugins/ecommerce/admin/coupons_controller.rb +61 -0
  12. data/app/controllers/plugins/ecommerce/admin/orders_controller.rb +96 -0
  13. data/app/controllers/plugins/ecommerce/admin/payment_methods_controller.rb +90 -0
  14. data/app/controllers/plugins/ecommerce/admin/prices_controller.rb +70 -0
  15. data/app/controllers/plugins/ecommerce/admin/settings_controller.rb +22 -0
  16. data/app/controllers/plugins/ecommerce/admin/shipping_methods_controller.rb +62 -0
  17. data/app/controllers/plugins/ecommerce/admin/tax_rates_controller.rb +61 -0
  18. data/app/controllers/plugins/ecommerce/admin_controller.rb +20 -0
  19. data/app/controllers/plugins/ecommerce/front/checkout_controller.rb +166 -0
  20. data/app/controllers/plugins/ecommerce/front/orders_controller.rb +255 -0
  21. data/app/controllers/plugins/ecommerce/front_controller.rb +18 -0
  22. data/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb +46 -0
  23. data/app/helpers/plugins/ecommerce/ecommerce_functions_helper.rb +49 -0
  24. data/app/helpers/plugins/ecommerce/ecommerce_helper.rb +240 -0
  25. data/app/helpers/plugins/ecommerce/ecommerce_payment_helper.rb +67 -0
  26. data/app/models/plugins/ecommerce/cart.rb +40 -0
  27. data/app/models/plugins/ecommerce/coupon.rb +25 -0
  28. data/app/models/plugins/ecommerce/coupon_decorator.rb +60 -0
  29. data/app/models/plugins/ecommerce/order.rb +65 -0
  30. data/app/models/plugins/ecommerce/order_decorator.rb +54 -0
  31. data/app/models/plugins/ecommerce/order_detail.rb +13 -0
  32. data/app/models/plugins/ecommerce/payment_method.rb +29 -0
  33. data/app/models/plugins/ecommerce/product.rb +14 -0
  34. data/app/models/plugins/ecommerce/shipping_method.rb +26 -0
  35. data/app/models/plugins/ecommerce/tax_rate.rb +18 -0
  36. data/app/views/camaleon_cms/html_mailer/order_received.html.erb +3 -0
  37. data/app/views/camaleon_cms/html_mailer/order_received_admin.html.erb +3 -0
  38. data/app/views/camaleon_cms/html_mailer/recovery_cart.html.erb +4 -0
  39. data/app/views/layouts/plugins/ecommerce/mailer.html.erb +22 -0
  40. data/app/views/plugins/ecommerce/admin/coupons/form.html.erb +73 -0
  41. data/app/views/plugins/ecommerce/admin/coupons/index.html.erb +50 -0
  42. data/app/views/plugins/ecommerce/admin/index.html.erb +2 -0
  43. data/app/views/plugins/ecommerce/admin/orders/form.html.erb +64 -0
  44. data/app/views/plugins/ecommerce/admin/orders/index.html.erb +90 -0
  45. data/app/views/plugins/ecommerce/admin/orders/show.html.erb +173 -0
  46. data/app/views/plugins/ecommerce/admin/payment_methods/form.html.erb +115 -0
  47. data/app/views/plugins/ecommerce/admin/payment_methods/index.html.erb +43 -0
  48. data/app/views/plugins/ecommerce/admin/payment_methods/show.html.erb +70 -0
  49. data/app/views/plugins/ecommerce/admin/prices/form.html.erb +49 -0
  50. data/app/views/plugins/ecommerce/admin/prices/index.html.erb +39 -0
  51. data/app/views/plugins/ecommerce/admin/prices/show.html.erb +19 -0
  52. data/app/views/plugins/ecommerce/admin/products/index.html.erb +114 -0
  53. data/app/views/plugins/ecommerce/admin/settings/index.html.erb +25 -0
  54. data/app/views/plugins/ecommerce/admin/shipping_methods/form.html.erb +39 -0
  55. data/app/views/plugins/ecommerce/admin/shipping_methods/index.html.erb +41 -0
  56. data/app/views/plugins/ecommerce/admin/shipping_methods/show.html.erb +22 -0
  57. data/app/views/plugins/ecommerce/admin/tax_rates/form.html.erb +36 -0
  58. data/app/views/plugins/ecommerce/admin/tax_rates/index.html.erb +41 -0
  59. data/app/views/plugins/ecommerce/front/_post_list_item.html.erb +18 -0
  60. data/app/views/plugins/ecommerce/front/checkout/cart_index.html.erb +59 -0
  61. data/app/views/plugins/ecommerce/front/checkout/index.html.erb +166 -0
  62. data/app/views/plugins/ecommerce/front/index.html.erb +2 -0
  63. data/app/views/plugins/ecommerce/front/list_products.html.erb +34 -0
  64. data/app/views/plugins/ecommerce/front/orders/index.html.erb +46 -0
  65. data/app/views/plugins/ecommerce/front/orders/pay_by_bank_transfer.html.erb +67 -0
  66. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card.html.erb +131 -0
  67. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card_authorize_net.erb +150 -0
  68. data/app/views/plugins/ecommerce/front/orders/select_payment.html.erb +70 -0
  69. data/app/views/plugins/ecommerce/front/orders/show.html.erb +76 -0
  70. data/app/views/plugins/ecommerce/front/product.html.erb +105 -0
  71. data/app/views/plugins/ecommerce/layouts/_ecommerce.html.erb +41 -0
  72. data/app/views/plugins/ecommerce/partials/_form_address.html.erb +84 -0
  73. data/app/views/plugins/ecommerce/partials/_table_order_products.html.erb +85 -0
  74. data/config/camaleon_plugin.json +48 -0
  75. data/config/currency.json +154 -0
  76. data/config/currency_en.json +154 -0
  77. data/config/currency_es.json +154 -0
  78. data/config/custom_models.rb +64 -0
  79. data/config/locales/readme.txt +1 -0
  80. data/config/locales/translation.yml +371 -0
  81. data/config/routes.rb +57 -0
  82. data/lib/camaleon_ecommerce.rb +4 -0
  83. data/lib/ecommerce.rb +4 -0
  84. data/lib/ecommerce/engine.rb +6 -0
  85. data/lib/ecommerce/version.rb +3 -0
  86. data/lib/tasks/ecommerce_tasks.rake +4 -0
  87. metadata +185 -0
@@ -0,0 +1,122 @@
1
+ .ec-list-orders-address{
2
+ padding: 0;
3
+ list-style: none;
4
+ li{
5
+ overflow: hidden;
6
+ margin-bottom: 4px;
7
+ strong{
8
+ width: 80px;
9
+ float: left;
10
+ }
11
+ span{
12
+ display: block;
13
+ float: left;
14
+ }
15
+ }
16
+ }
17
+
18
+ #shipping_address #copy{
19
+ display: none;
20
+ }
21
+
22
+ #order_view {
23
+ .status-bar {
24
+ background-size: 8px;
25
+ margin: 45px 0;
26
+ overflow: hidden;
27
+ position: relative;
28
+ .bg-bar{
29
+ background: #ddd none repeat scroll 0 0;
30
+ height: 6px;
31
+ left: 0;
32
+ position: absolute;
33
+ top: 15px;
34
+ width: 100%;
35
+ z-index: 0;
36
+ }
37
+ ul{
38
+ padding: 0;
39
+ list-style: none;
40
+ position: relative;
41
+ z-index: 9;
42
+ li{
43
+ width: 33%;
44
+ float: left;
45
+ text-align: center;
46
+ background-size: 36px;
47
+ padding-top: 0;
48
+ z-index: 10;
49
+ .icon{
50
+ padding-bottom: 10px;
51
+ i{
52
+ border-radius: 50%;
53
+ background: #aaa;
54
+ color: #fff;
55
+ display: inline-block;
56
+ font-size: 16px;
57
+ height: 34px;
58
+ padding: 8px;
59
+ width: 34px;
60
+ };
61
+ }
62
+ }
63
+ .received{
64
+ .icon i{
65
+
66
+ }
67
+ }
68
+ .accepted{
69
+ .icon i{
70
+ background-color: #89BD2F;
71
+ }
72
+ }
73
+ .shipped{
74
+ .icon i{
75
+ background-color: #E32479;
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
81
+ .box-adv-search{
82
+ .dropdown.dropdown-lg .dropdown-menu {
83
+ margin-top: -1px;
84
+ padding: 6px 20px;
85
+ }
86
+ .input-group-btn .btn-group {
87
+ display: flex !important;
88
+ }
89
+ .btn-group .btn {
90
+ border-radius: 0;
91
+ margin-left: -1px;
92
+ }
93
+ .btn-group .btn:last-child {
94
+ border-top-right-radius: 4px;
95
+ border-bottom-right-radius: 4px;
96
+ }
97
+ .btn-group .form-horizontal .btn[type="submit"] {
98
+ border-top-left-radius: 4px;
99
+ border-bottom-left-radius: 4px;
100
+ }
101
+ .form-horizontal .form-group {
102
+ margin-left: 0;
103
+ margin-right: 0;
104
+ }
105
+ .form-group .form-control:last-child {
106
+ border-top-left-radius: 4px;
107
+ border-bottom-left-radius: 4px;
108
+ }
109
+
110
+ @media screen and (min-width: 768px) {
111
+ #adv-search {
112
+ width: 360px;
113
+ margin: 0 auto;
114
+ }
115
+ .dropdown.dropdown-lg {
116
+ position: static !important;
117
+ }
118
+ .dropdown.dropdown-lg .dropdown-menu {
119
+ min-width: 400px;
120
+ }
121
+ }
122
+ }
@@ -0,0 +1,36 @@
1
+ .ec-list-orders-address{
2
+ padding: 0;
3
+ list-style: none;
4
+ li{
5
+ overflow: hidden;
6
+ margin-bottom: 2px;
7
+ list-style: none !important;
8
+ strong{
9
+ width: 80px;
10
+ float: left;
11
+ }
12
+ span{
13
+ display: block;
14
+ float: left;
15
+ }
16
+ }
17
+ }
18
+
19
+ .shopping_cart_box{
20
+ h5{
21
+ margin-top: 0;
22
+ margin-bottom: 4px;
23
+ }
24
+ p{
25
+ margin-bottom: 4px;
26
+ }
27
+ }
28
+ .form-validate-ec label.error{
29
+ color: #ff4d00;
30
+ font-size: 12px;
31
+ font-weight: normal;
32
+ }
33
+
34
+ .form-validate-ec .form-control.error{
35
+ border-color: #ff4d00;
36
+ }
@@ -0,0 +1,61 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Admin::CouponsController < Plugins::Ecommerce::AdminController
10
+ before_action :set_order, only: ['show','edit','update','destroy']
11
+
12
+ def index
13
+ @coupons = current_site.coupons.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
14
+ end
15
+
16
+ def new
17
+ @coupon = current_site.coupons.new
18
+ admin_breadcrumb_add("#{t('plugin.ecommerce.new')}")
19
+ render 'form'
20
+ end
21
+
22
+ def show
23
+ end
24
+
25
+ def edit
26
+ admin_breadcrumb_add("#{t('camaleon_cms.admin.button.edit')}")
27
+ render 'form'
28
+ end
29
+
30
+ def create
31
+ data = params[:plugins_ecommerce_coupon]
32
+ @coupon = current_site.coupons.new(data)
33
+ if @coupon.save
34
+ @coupon.set_meta('_default', params[:options])
35
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.created')
36
+ redirect_to action: :index
37
+ else
38
+ render 'form'
39
+ end
40
+ end
41
+
42
+ def update
43
+ data = params[:plugins_ecommerce_coupon]
44
+ if @coupon.update(data)
45
+ @coupon.set_meta('_default', params[:options])
46
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.updated')
47
+ redirect_to action: :index
48
+ else
49
+ render 'form'
50
+ end
51
+ end
52
+
53
+
54
+
55
+
56
+ private
57
+ def set_order
58
+ @coupon = current_site.coupons.find(params[:id])
59
+ end
60
+
61
+ end
@@ -0,0 +1,96 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Admin::OrdersController < Plugins::Ecommerce::AdminController
10
+ before_action :set_order, only: ['show', 'edit', 'update', 'destroy']
11
+
12
+ def index
13
+ orders = current_site.orders
14
+ if params[:q].present?
15
+ #orders = orders.where(params[:q].strip_stopwords2(I18n.locale).split(" ").map{|text| "posts.title LIKE '%#{text}%'" }.join(" OR "))
16
+ orders = orders.where(slug: params[:q])
17
+ end
18
+ if params[:c].present?
19
+ #orders = orders.where(user_id: User.joins(:metas).where(usermeta: {key: ['first_name','last_name']}).where("usermeta.value LIKE ?","%#{params[:c]}%").pluck(:id))
20
+ orders = orders.joins(:details).where("plugins_order_details.customer LIKE ?", "%#{params[:c]}%")
21
+ end
22
+ if params[:e].present?
23
+ orders = orders.joins(:details).where("plugins_order_details.email LIKE ?", "%#{params[:e]}%")
24
+ end
25
+ if params[:p].present?
26
+ orders = orders.joins(:details).where("plugins_order_details.phone LIKE ?", "%#{params[:p]}%")
27
+ end
28
+ if params[:s].present?
29
+ orders = orders.where(status: params[:s])
30
+ end
31
+
32
+ orders = orders.order('updated_at DESC')
33
+ @orders = orders.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
34
+ end
35
+
36
+ def show
37
+ admin_breadcrumb_add("#{t('plugin.ecommerce.table.details')}")
38
+ @order = @order.decorate
39
+ end
40
+
41
+ def new
42
+ @order = current_site.orders.new
43
+ render 'form'
44
+ end
45
+
46
+ def edit
47
+ admin_breadcrumb_add("#{t('camaleon_cms.admin.button.edit')}")
48
+ render 'form'
49
+ end
50
+
51
+ def update
52
+ @order.details.update(@order.details.attributes.merge(params[:order][:details]))
53
+ @order.set_meta("billing_address", @order.get_meta("billing_address", {}).merge(params[:order][:billing_address]))
54
+ @order.set_meta("shipping_address", @order.get_meta("shipping_address", {}).merge(params[:order][:shipping_address]))
55
+ flash[:notice] = "#{t('plugin.ecommerce.message.order', status: "#{t('plugin.ecommerce.message.updated')}")}"
56
+ redirect_to action: :show, id: params[:id]
57
+ end
58
+
59
+ # accepted order
60
+ def accepted
61
+ @order = current_site.orders.find_by_slug(params[:order_id])
62
+ r = {order: @order}; hooks_run('plugin_ecommerce_before_accepted_order', r)
63
+ @order.update({status: 'accepted'})
64
+ @order.details.update({accepted_at: Time.now})
65
+ message = "#{t('plugin.ecommerce.message.order', status: "#{t('plugin.ecommerce.message.accepted')}")}"
66
+ r = {order: @order, message: message}; hooks_run('plugin_ecommerce_after_accepted_order', r)
67
+ flash[:info] = r[:message]
68
+ redirect_to action: :show, id: params[:order_id]
69
+ end
70
+
71
+ # shipped order
72
+ def shipped
73
+ @order = current_site.orders.find_by_slug(params[:order_id])
74
+ @order.update({status: 'shipped'})
75
+ @order.details.update({shipped_at: Time.now})
76
+ code = params[:payment][:consignment_number]
77
+ @order.set_meta("payment", @order.get_meta("payment", {}).merge({consignment_number: code}))
78
+ flash[:info] = "#{t('plugin.ecommerce.message.order', status: "#{t('plugin.ecommerce.message.shipped')}")}"
79
+ redirect_to action: :show, id: params[:order_id]
80
+ end
81
+
82
+ # closed order
83
+ def closed
84
+ @order = current_site.orders.find_by_slug(params[:order_id])
85
+ @order.update({status: 'closed'})
86
+ @order.details.update({closed_at: Time.now})
87
+ flash[:info] = "#{t('plugin.ecommerce.message.order', status: "#{t('plugin.ecommerce.message.closed')}")}"
88
+ redirect_to action: :show, id: params[:order_id]
89
+ end
90
+
91
+ private
92
+ def set_order
93
+ @order = current_site.orders.find_by_slug(params[:id])
94
+ end
95
+
96
+ end
@@ -0,0 +1,90 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Admin::PaymentMethodsController < Plugins::Ecommerce::AdminController
10
+ before_action :set_order, only: ['show','edit','update','destroy']
11
+
12
+ def index
13
+ @payment_methods = current_site.payment_methods.paginate(:page => params[:page], :per_page => current_site.admin_per_page)
14
+ end
15
+
16
+ def new
17
+ @payment_method = current_site.payment_methods.new
18
+ admin_breadcrumb_add("#{t('plugin.ecommerce.new')}")
19
+ render 'form'
20
+ end
21
+
22
+ def show
23
+ admin_breadcrumb_add("#{t('plugin.ecommerce.table.details')}")
24
+ @payment_method = @payment_method.decorate
25
+ end
26
+
27
+ def edit
28
+ admin_breadcrumb_add("#{t('camaleon_cms.admin.button.edit')}")
29
+ render 'form'
30
+ end
31
+
32
+ def create
33
+ data = params[:plugins_ecommerce_payment_method]
34
+ @payment_method = current_site.payment_methods.new(data)
35
+ if @payment_method.save
36
+ @payment_method.set_meta('_default',params[:options])
37
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.created')
38
+ redirect_to action: :index
39
+ else
40
+ render 'form'
41
+ end
42
+ end
43
+
44
+ def update
45
+ data = params[:plugins_ecommerce_payment_method]
46
+
47
+ if defined?(params[:options][:type]) && params[:options][:type] == 'paypal'
48
+ unless valid_paypal_data(params[:options])
49
+ flash.now[:error] = "#{t('plugin.ecommerce.message.error_paypal_values')}"
50
+ render 'form'
51
+ return
52
+ end
53
+ end
54
+
55
+ #FIXME create valid_authorize_net_data function
56
+
57
+ if @payment_method.update(data)
58
+ @payment_method.set_meta('_default',params[:options])
59
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.updated')
60
+ redirect_to action: :index
61
+ else
62
+ render 'form'
63
+ end
64
+ end
65
+
66
+
67
+
68
+
69
+ private
70
+ def set_order
71
+ @payment_method = current_site.payment_methods.find(params[:id])#.decorate
72
+ end
73
+
74
+ def valid_paypal_data(data)
75
+ ActiveMerchant::Billing::Base.mode = data[:paypal_sandbox].to_s.to_bool ? :test : :production
76
+ paypal_options = {
77
+ :login => data[:paypal_login],
78
+ :password => data[:paypal_password],
79
+ :signature => data[:paypal_signature]
80
+ }
81
+ opts = {
82
+ :ip => request.remote_ip,
83
+ :return_url => plugins_ecommerce_order_success_url(order: 'test'),
84
+ :cancel_return_url => plugins_ecommerce_order_cancel_url(order: 'test')
85
+ }
86
+ @gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(paypal_options)
87
+ response = @gateway.setup_authorization(500, opts)
88
+ response.success?
89
+ end
90
+ end
@@ -0,0 +1,70 @@
1
+ =begin
2
+ Camaleon CMS is a content management system
3
+ Copyright (C) 2015 by Owen Peredo Diaz
4
+ Email: owenperedo@gmail.com
5
+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
6
+ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7
+ See the GNU Affero General Public License (GPLv3) for more details.
8
+ =end
9
+ class Plugins::Ecommerce::Admin::PricesController < Plugins::Ecommerce::AdminController
10
+ before_action :set_shipping_method
11
+
12
+ def index
13
+ admin_breadcrumb_add("#{t('plugin.ecommerce.product.price')}")
14
+ end
15
+
16
+ def new
17
+ @price = {}
18
+ admin_breadcrumb_add("#{t('plugin.ecommerce.product.price')}", admin_plugins_ecommerce_shipping_method_prices_path( params[:shipping_method_id] ))
19
+ admin_breadcrumb_add("#{t('plugin.ecommerce.new')}")
20
+ render 'form'
21
+ end
22
+
23
+ def show
24
+ end
25
+
26
+ def edit
27
+ @price = @prices[params[:id].to_sym] || {}
28
+ admin_breadcrumb_add("#{t('plugin.ecommerce.product.price')}", admin_plugins_ecommerce_shipping_method_prices_path( params[:shipping_method_id] ))
29
+ admin_breadcrumb_add("#{t('camaleon_cms.admin.button.edit')}")
30
+ render 'form'
31
+ end
32
+
33
+ def create
34
+ _id = Time.now.to_i.to_s
35
+ data = params[:price]
36
+ data[:id] = _id
37
+ @prices[_id] = data
38
+ @shipping_method.set_meta('prices', @prices)
39
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.created')
40
+ redirect_to action: :index
41
+ end
42
+
43
+ def update
44
+ _id = params[:id]
45
+ @price = @prices[params[:id].to_sym] || {}
46
+ @prices[_id] = @price.merge(params[:price])
47
+ @shipping_method.set_meta('prices', @prices)
48
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.updated')
49
+ redirect_to action: :index
50
+ end
51
+
52
+ def destroy
53
+ @prices.delete(params[:id].to_sym)
54
+ @shipping_method.set_meta('prices', @prices)
55
+ flash[:notice] = t('camaleon_cms.admin.post_type.message.deleted')
56
+ redirect_to action: :index
57
+ end
58
+
59
+
60
+
61
+ private
62
+ def set_shipping_method
63
+ @shipping_method = current_site.shipping_methods.find(params[:shipping_method_id])
64
+ add_breadcrumb(t("plugin.ecommerce.shipping_methods"))
65
+ add_breadcrumb(@shipping_method.name)
66
+ add_breadcrumb(t("plugin.ecommerce.shipping_prices"))
67
+ @prices = @shipping_method.get_meta("prices", {})
68
+ end
69
+
70
+ end