camaleon_ecommerce 0.0.4 → 1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/plugins/ecommerce/admin.js +0 -33
  3. data/app/assets/javascripts/plugins/ecommerce/cart.js +83 -200
  4. data/app/assets/javascripts/plugins/ecommerce/fix_form.js +1 -4
  5. data/app/assets/stylesheets/plugins/ecommerce/checkout.css.scss +46 -0
  6. data/app/assets/stylesheets/plugins/ecommerce/front.scss +2 -30
  7. data/app/controllers/plugins/ecommerce/admin/coupons_controller.rb +2 -2
  8. data/app/controllers/plugins/ecommerce/admin/orders_controller.rb +45 -34
  9. data/app/controllers/plugins/ecommerce/admin/payment_methods_controller.rb +4 -3
  10. data/app/controllers/plugins/ecommerce/admin/prices_controller.rb +5 -5
  11. data/app/controllers/plugins/ecommerce/admin/settings_controller.rb +0 -2
  12. data/app/controllers/plugins/ecommerce/admin/shipping_methods_controller.rb +3 -3
  13. data/app/controllers/plugins/ecommerce/admin/tax_rates_controller.rb +2 -2
  14. data/app/controllers/plugins/ecommerce/admin_controller.rb +1 -1
  15. data/app/controllers/plugins/ecommerce/front/checkout_controller.rb +162 -110
  16. data/app/controllers/plugins/ecommerce/front/orders_controller.rb +7 -234
  17. data/app/controllers/plugins/ecommerce/front_controller.rb +42 -3
  18. data/app/decorators/plugins/ecommerce/cart_decorator.rb +27 -0
  19. data/app/{models → decorators}/plugins/ecommerce/coupon_decorator.rb +1 -1
  20. data/app/decorators/plugins/ecommerce/order_decorator.rb +22 -0
  21. data/app/decorators/plugins/ecommerce/product_decorator.rb +88 -0
  22. data/app/decorators/plugins/ecommerce/product_item_decorator.rb +18 -0
  23. data/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb +91 -28
  24. data/app/helpers/plugins/ecommerce/ecommerce_helper.rb +30 -136
  25. data/app/helpers/plugins/ecommerce/ecommerce_payment_helper.rb +14 -20
  26. data/app/models/plugins/ecommerce/cart.rb +139 -15
  27. data/app/models/plugins/ecommerce/coupon.rb +33 -7
  28. data/app/models/plugins/ecommerce/order.rb +47 -31
  29. data/app/models/plugins/ecommerce/{product.rb → product_item.rb} +11 -5
  30. data/app/views/camaleon_cms/html_mailer/order_canceled.html.erb +2 -0
  31. data/app/views/camaleon_cms/html_mailer/order_confirmed.html.erb +2 -0
  32. data/app/views/camaleon_cms/html_mailer/order_received_admin.html.erb +1 -1
  33. data/app/views/camaleon_cms/html_mailer/order_shipped.html.erb +2 -0
  34. data/app/views/plugins/ecommerce/admin/coupons/form.html.erb +10 -10
  35. data/app/views/plugins/ecommerce/admin/coupons/index.html.erb +1 -1
  36. data/app/views/plugins/ecommerce/admin/orders/form.html.erb +5 -49
  37. data/app/views/plugins/ecommerce/admin/orders/index.html.erb +140 -80
  38. data/app/views/plugins/ecommerce/admin/orders/show.html.erb +7 -169
  39. data/app/views/plugins/ecommerce/admin/payment_methods/form.html.erb +30 -3
  40. data/app/views/plugins/ecommerce/admin/payment_methods/index.html.erb +1 -3
  41. data/app/views/plugins/ecommerce/admin/prices/index.html.erb +0 -2
  42. data/app/views/plugins/ecommerce/admin/prices/show.html.erb +0 -2
  43. data/app/views/plugins/ecommerce/admin/products/index.html.erb +1 -1
  44. data/app/views/plugins/ecommerce/admin/settings/index.html.erb +0 -1
  45. data/app/views/plugins/ecommerce/admin/tax_rates/form.html.erb +1 -1
  46. data/app/views/plugins/ecommerce/front/checkout/cart_index.html.erb +46 -57
  47. data/app/views/plugins/ecommerce/front/checkout/index.html.erb +34 -158
  48. data/app/views/plugins/ecommerce/front/login.html.erb +67 -0
  49. data/app/views/plugins/ecommerce/front/orders/index.html.erb +36 -44
  50. data/app/views/plugins/ecommerce/front/orders/show.html.erb +121 -67
  51. data/app/views/plugins/ecommerce/partials/_cart_widget.html.erb +38 -0
  52. data/app/views/plugins/ecommerce/partials/checkout/_details.html.erb +35 -0
  53. data/app/views/plugins/ecommerce/partials/checkout/_payments.html.erb +123 -0
  54. data/app/views/plugins/ecommerce/partials/checkout/_products_detail.html.erb +49 -0
  55. data/app/views/plugins/ecommerce/partials/checkout/_user_info.html.erb +93 -0
  56. data/app/views/post_types/commerce.html.erb +22 -0
  57. data/app/views/post_types/commerce/_product_widget.html.erb +13 -0
  58. data/app/views/post_types/commerce/category.html.erb +23 -0
  59. data/app/views/post_types/commerce/single.html.erb +91 -0
  60. data/config/custom_models.rb +24 -57
  61. data/config/locales/en.yml +192 -0
  62. data/config/locales/es.yml +405 -0
  63. data/config/routes.rb +26 -16
  64. data/db/migrate/20160502221327_add_cama_ecommerce_structure_plugin.rb +12 -0
  65. data/db/migrate/20160504162311_move_featured_attribute_of_products.rb +15 -0
  66. data/db/migrate/20160527184747_add_new_cart_structure.rb +21 -0
  67. data/lib/ecommerce/version.rb +1 -1
  68. metadata +42 -19
  69. data/app/models/plugins/ecommerce/order_decorator.rb +0 -54
  70. data/app/views/layouts/plugins/ecommerce/mailer.html.erb +0 -22
  71. data/app/views/plugins/ecommerce/admin/index.html.erb +0 -2
  72. data/app/views/plugins/ecommerce/front/_post_list_item.html.erb +0 -18
  73. data/app/views/plugins/ecommerce/front/index.html.erb +0 -2
  74. data/app/views/plugins/ecommerce/front/list_products.html.erb +0 -34
  75. data/app/views/plugins/ecommerce/front/orders/pay_by_bank_transfer.html.erb +0 -67
  76. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card.html.erb +0 -131
  77. data/app/views/plugins/ecommerce/front/orders/pay_by_credit_card_authorize_net.erb +0 -150
  78. data/app/views/plugins/ecommerce/front/orders/select_payment.html.erb +0 -70
  79. data/app/views/plugins/ecommerce/front/product.html.erb +0 -105
  80. data/app/views/plugins/ecommerce/layouts/_ecommerce.html.erb +0 -41
  81. data/app/views/plugins/ecommerce/partials/_form_address.html.erb +0 -84
  82. data/app/views/plugins/ecommerce/partials/_table_order_products.html.erb +0 -85
  83. data/config/locales/translation.yml +0 -371
@@ -6,28 +6,125 @@
6
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
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- class Plugins::Ecommerce::Cart < CamaleonCms::TermTaxonomy
10
- default_scope { where(taxonomy: :ecommerce_cart) }
11
- has_many :products, foreign_key: :objectid, through: :term_relationships, :source => :objects
12
- belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
9
+ class Plugins::Ecommerce::Cart < ActiveRecord::Base
10
+ self.table_name = 'plugins_ecommerce_orders'
11
+ default_scope { where(kind: 'cart') }
12
+ include CamaleonCms::Metas
13
13
 
14
- def add_product(object)
15
- post_id = defined?(object.id) ? object.id : object.to_i
16
- term_relationships.where(objectid: post_id).first_or_create if post_id > 0
14
+ has_many :product_items, foreign_key: :order_id, class_name: 'Plugins::Ecommerce::ProductItem', dependent: :destroy
15
+ has_many :products, foreign_key: :order_id, through: :product_items
16
+
17
+ belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :site_id
18
+ belongs_to :user, :class_name => "CamaleonCms::User", foreign_key: :user_id
19
+ after_create :generate_slug
20
+
21
+ def add_product(product, qty = 1)
22
+ pi = product_items.where(product_id: product.id).first
23
+ if pi.present?
24
+ pi.update_column(:qty, qty)
25
+ else
26
+ pi = product_items.create(product_id: product.id, qty: qty)
27
+ end
28
+ pi
29
+ end
30
+
31
+ def remove_product(product_id)
32
+ product_items.where(product_id: product_id).destroy_all
33
+ end
34
+
35
+ # return the product titles in array format
36
+ def products_title
37
+ products.decorate.each{|p| p.the_title }.join(', ')
38
+ end
39
+
40
+ def items_total
41
+ product_items.map{|item| item.qty }.inject{|sum,x| sum + x } || 0
42
+ end
43
+
44
+ # price of all products (no include taxes)
45
+ def sub_total
46
+ # product_items.map{|item| product = item.product.decorate; (product.price + product.tax) * item.qty }.inject{|sum,x| sum + x } || 0
47
+ product_items.map{|item| product = item.product.decorate; (product.price) * item.qty }.inject{|sum,x| sum + x } || 0
48
+ end
49
+
50
+ def tax_total
51
+ product_items.map{|item| product = item.product.decorate; (product.tax) * item.qty }.inject{|sum,x| sum + x } || 0
52
+ end
53
+
54
+ def weight_total
55
+ product_items.map{|item| product = item.product.decorate; (product.weight) * item.qty }.inject{|sum,x| sum + x } || 0
17
56
  end
18
- def remove_product(object)
19
- post_id = defined?(object.id) ? object.id : object.to_i
20
- term_relationships.where(objectid: post_id).destroy_all if post_id > 0
57
+
58
+ # verify an return {error: (error code), discount: amount of discount} coupon for current cart
59
+ # price: the total price including shipping price (used for free discount type)
60
+ def discount_for(coupon_code, price = nil)
61
+ coupon = site.coupons.find_by_slug(coupon_code)
62
+ res = {error: '', discount: 0, coupon: coupon}
63
+ if coupon.present?
64
+ opts = coupon.options
65
+ if coupon.expired?
66
+ res[:error] = 'coupon_expired'
67
+ elsif !coupon.active?
68
+ res[:error] = 'inactive_coupon'
69
+ elsif coupon.used_times_exceeded?
70
+ res[:error] = 'times_exceeded'
71
+ elsif !coupon.valid_min_price?(sub_total)
72
+ res[:error] = 'required_minimum_price'
73
+ else
74
+ case opts[:discount_type]
75
+ when 'free_ship'
76
+ res[:discount] = price || sub_total
77
+ when 'percent'
78
+ res[:discount] = sub_total * opts[:amount].to_f / 100
79
+ when 'money'
80
+ res[:discount] = opts[:amount].to_f
81
+ end
82
+ end
83
+ else
84
+ res[:error] = 'coupon_not_found'
85
+ end
86
+ res
87
+ end
88
+
89
+ # convert into order current cart
90
+ def make_order!
91
+ self.update_columns(kind: 'order', created_at: Time.current)
92
+ site.orders.find(self.id)
93
+ end
94
+
95
+ def shipping_method
96
+ Plugins::Ecommerce::ShippingMethod.find_by_id(self.shipping_method_id)
97
+ end
98
+
99
+ # return the total price without coupon price
100
+ def total_to_pay_without_discounts
101
+ sub_total + tax_total + total_shipping
21
102
  end
103
+ alias_method :partial_total, :total_to_pay_without_discounts
22
104
 
23
- def the_items_count
24
- options.map{|k, p| p[:qty].to_i}.inject{|sum,x| sum + x } || 0
105
+ # include all costs and discounts
106
+ def total_amount
107
+ payment_amount = partial_total
108
+ if self.coupon.present?
109
+ res_coupon = self.discount_for(self.coupon, payment_amount)
110
+ payment_amount = payment_amount - res_coupon[:discount] unless res_coupon[:error].present?
111
+ end
112
+ payment_amount < 0 ? 0 : payment_amount
25
113
  end
26
114
 
27
- def the_amount_total
28
- options.map{|k, p| (p[:price].to_f + p[:tax])* p[:qty].to_f}.inject{|sum,x| sum + x } || 0
115
+ # return total of discounts
116
+ def total_discounts
117
+ if self.coupon.present?
118
+ self.discount_for(self.coupon, partial_total)[:discount] || 0
119
+ else
120
+ 0
121
+ end
29
122
  end
30
123
 
124
+ # return the total price of shipping
125
+ def total_shipping
126
+ shipping_method.present? ? shipping_method.get_price_from_weight(weight_total) : 0
127
+ end
31
128
 
32
129
  # set user in filter
33
130
  def self.set_user(user)
@@ -35,6 +132,33 @@ class Plugins::Ecommerce::Cart < CamaleonCms::TermTaxonomy
35
132
  self.where(user_id: user_id)
36
133
  end
37
134
 
135
+ # check if the price of the cart is 0, including prices for products, discounts, shipping
136
+ def free_cart?
137
+ total_amount <= 0
138
+ end
139
+
140
+ # return order object
141
+ def make_paid!(status = 'paid')
142
+ product_items.decorate.each do |item|
143
+ p = item.product.decorate
144
+ item.update_columns(cache_the_price: item.the_price, cache_the_title: p.the_title, cache_the_tax: p.the_tax, cache_the_sub_total: item.the_sub_total)
145
+ end
38
146
 
147
+ if self.coupon.present?
148
+ res_coupon = self.discount_for(self.coupon, total_to_pay_without_discounts)
149
+ unless res_coupon[:error].present?
150
+ update_columns(the_coupon_amount: res_coupon[:coupon].decorate.the_amount, coupon_amount: res_coupon[:discount])
151
+ res_coupon[:coupon].mark_as_used(user)
152
+ end
153
+ end
154
+ c = self.decorate
155
+ self.update_columns(status: status, paid_at: Time.current, amount: total_amount, cache_the_total: c.the_price, cache_the_sub_total: c.the_sub_total, cache_the_tax: c.the_tax_total, cache_the_weight: c.the_weight_total, cache_the_discounts: c.the_total_discounts, cache_the_shipping: c.the_total_shipping)
156
+ make_order!
157
+ end
158
+
159
+
160
+ private
161
+ def generate_slug
162
+ self.update_column(:slug, "#{Time.current.to_i}-#{self.id}")
163
+ end
39
164
  end
40
- #Cart = Plugins::Ecommerce::Cart
@@ -11,15 +11,41 @@ class Plugins::Ecommerce::Coupon < CamaleonCms::TermTaxonomy
11
11
  belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
12
12
  scope :actives, -> {where(status: '1')}
13
13
 
14
- def self.find_valid_by_code(code)
15
- coupon = self.find_by_slug(code.to_s.parameterize)
16
- if coupon.nil?
17
- nil
18
- elsif "#{coupon.options[:expirate_date]} 23:59:59".to_datetime.to_i < Time.now.to_i || coupon.status != '1'
19
- nil
14
+ def used_times_exceeded?
15
+ (used_applications + 1) > allowed_applications
16
+ end
17
+
18
+ def mark_as_used(user = nil)
19
+ set_option('used_applications', used_applications + 1)
20
+ end
21
+
22
+ def used_applications
23
+ get_option('used_applications', 0).to_i
24
+ end
25
+
26
+ def allowed_applications
27
+ get_option('allowed_applications', 0).to_i
28
+ end
29
+
30
+ def expired?
31
+ d = get_option('expirate_date', '')
32
+ if d.present?
33
+ "#{d} 23:59:59".to_datetime.to_i < Time.current.to_i
20
34
  else
21
- coupon
35
+ false
22
36
  end
23
37
  end
24
38
 
39
+ def min_cart_total
40
+ get_option('min_cart_total', '')
41
+ end
42
+
43
+ def valid_min_price?(price)
44
+ !min_cart_total.present? || min_cart_total.to_i <= price
45
+ end
46
+
47
+ def active?
48
+ status.to_s == '1'
49
+ end
50
+
25
51
  end
@@ -6,60 +6,76 @@
6
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
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- class Plugins::Ecommerce::Order < CamaleonCms::TermTaxonomy
10
- default_scope { where(taxonomy: :ecommerce_order) }
11
- has_one :details, class_name: "Plugins::Ecommerce::OrderDetail", foreign_key: :order_id, dependent: :destroy
12
- has_many :products, foreign_key: :objectid, through: :term_relationships, :source => :objects
13
- belongs_to :customer, class_name: "CamaleonCms::User", foreign_key: :user_id
9
+ class Plugins::Ecommerce::Order < Plugins::Ecommerce::Cart
10
+ self.table_name = 'plugins_ecommerce_orders'
11
+ has_many :metas, ->{ where(object_class: 'Plugins::Ecommerce::Cart')}, :class_name => "CamaleonCms::Meta", foreign_key: :objectid, dependent: :delete_all
12
+ default_scope { where(kind: 'order') }
13
+ # status: bank_pending => pending of verification for bank transfer orders
14
+ # paid => paid by some method
15
+ # canceled => canceled order
16
+ # shipped => shipped status
17
+ # accepted => received status
14
18
 
15
- scope :not_closed, -> { where('status != ?', :closed) }
19
+ def payment_method
20
+ Plugins::Ecommerce::PaymentMethod.find_by_id(get_meta('payment_method_id', self.payment_method_id))
21
+ end
16
22
 
17
- def add_product(object)
18
- post_id = defined?(object.id) ? object.id : object.to_i
19
- term_relationships.where(objectid: post_id).first_or_create if post_id > 0
23
+ def paid?
24
+ status == 'paid'
20
25
  end
21
26
 
22
- def remove_product(object)
23
- post_id = defined?(object.id) ? object.id : object.to_i
24
- term_relationships.where(objectid: post_id).destroy_all if post_id > 0
27
+ def accepted?
28
+ status == 'accepted'
25
29
  end
26
30
 
27
- def payment_method
28
- Plugins::Ecommerce::PaymentMethod.find_by_id get_meta("payment")[:payment_id]
31
+ def accepted!
32
+ update_columns({status: 'accepted', accepted_at: Time.current})
29
33
  end
30
34
 
31
- def payment
32
- payment = get_meta("payment")
33
- get_meta("pay_#{payment[:type]}".to_sym)
35
+ def shipped?
36
+ status == 'shipped'
34
37
  end
35
38
 
36
- def shipping_method
37
- Plugins::Ecommerce::ShippingMethod.find_by_id get_meta("payment", {})[:shipping_method]
39
+ def shipped!(code)
40
+ update_columns({status: 'shipped', shipped_at: Time.current})
41
+ set_meta('consignment_number', code)
38
42
  end
39
43
 
40
44
  def canceled?
41
45
  status == 'canceled'
42
46
  end
43
47
 
44
- def unpaid?
45
- status == 'unpaid'
48
+ def canceled!
49
+ update_columns({status: 'canceled', shipped_at: Time.current})
46
50
  end
47
51
 
48
- def closed?
49
- status == 'closed'
52
+ def received?
53
+ status == 'received'
50
54
  end
51
55
 
52
- def paid?
53
- payment.present?
56
+ def bank_pending?
57
+ status == 'bank_pending'
54
58
  end
55
59
 
56
-
57
- # set user in filter
58
- def self.set_user(user)
59
- user_id = defined?(user.id) ? user.id : user.to_i
60
- self.where(user_id: user_id)
60
+ def bank_confirmed!
61
+ update_columns({status: 'paid', updated_at: Time.current})
61
62
  end
62
63
 
64
+ def payment_data
65
+ get_meta('payment_data', {})
66
+ end
63
67
 
68
+ # return the date of the current status
69
+ def action_date
70
+ case object.status
71
+ when 'paid'
72
+ object.created_at
73
+ when 'canceled'
74
+ object.closed_at
75
+ when 'shipped'
76
+ object.shipped_at
77
+ when 'accepted'
78
+ object.accepted_at
79
+ end
80
+ end
64
81
  end
65
- #Cart = Plugins::Ecommerce::Cart
@@ -6,9 +6,15 @@
6
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
7
  See the GNU Affero General Public License (GPLv3) for more details.
8
8
  =end
9
- class Plugins::Ecommerce::Product < CamaleonCms::Post
10
- # attrs:
11
- # slug => plugin key
12
- #default_scope { where(taxonomy: :e_commerce_product) }
9
+ class Plugins::Ecommerce::ProductItem < ActiveRecord::Base
10
+ include CamaleonCms::Metas
11
+ self.table_name = 'plugins_ecommerce_products'
12
+ belongs_to :cart, class_name: 'Plugins::Ecommerce::Cart', foreign_key: :order_id
13
+ belongs_to :order, class_name: 'Plugins::Ecommerce::Order'
14
+ belongs_to :product, foreign_key: :product_id, class_name: 'CamaleonCms::Post'
15
+
16
+ def sub_total
17
+ p = self.product.decorate
18
+ (p.price + p.tax) * self.qty
19
+ end
13
20
  end
14
- Product = Plugins::Ecommerce::Product
@@ -0,0 +1,2 @@
1
+ <p><%= t('plugin.ecommerce.mail.dear', default: 'Dear %{name}: ', name: @extra_data[:order].user.fullname) %></p>
2
+ <p><%= t('plugin.ecommerce.mail.order_canceled.message', default: 'Your order %{order} has been canceled: %{message}', order: @extra_data[:order].slug, message: @extra_data[:message]) %></p>
@@ -0,0 +1,2 @@
1
+ <p><%= t('plugin.ecommerce.mail.dear', default: 'Dear %{name}: ', name: @extra_data[:fullname]) %></p>
2
+ <p><%= t('plugin.ecommerce.mail.order_confirmed.message', default: 'We have confirmed your payment by bank transfer for the order #%{order}.\n\n Thanks for your preference.', order: @extra_data[:order_slug]).gsub(/\n/, '<br>').gsub('\n', '<br>') %></p>
@@ -1,3 +1,3 @@
1
1
  <p><%= t('plugin.ecommerce.mail.order_received.welcome') %><%= @extra_data[:admin][:fullname] %></p>
2
- <p><%= @extra_data[:fullname] %> has bought!</p>
2
+ <p><%= t('plugin.ecommerce.mail.order_received.boght_by', user: @extra_data[:fullname], default: '%{user} has bought') %></p>
3
3
  <p><%= t('plugin.ecommerce.mail.order_received.reference') %> <a href="<%= @extra_data[:order_url] %>"><%= @extra_data[:order_slug] %></a>
@@ -0,0 +1,2 @@
1
+ <p><%= t('plugin.ecommerce.mail.dear', default: 'Dear %{name}: ', name: @extra_data[:order].user.fullname) %></p>
2
+ <p><%= t('plugin.ecommerce.mail.order_shipped.message', default: 'Your order %{order} has been sent.', order: @extra_data[:order].slug) %></p>
@@ -4,7 +4,6 @@
4
4
 
5
5
  <!-- PAGE CONTENT WRAPPER -->
6
6
  <div class="page-content-wrap">
7
-
8
7
  <div class="row">
9
8
  <div class="col-md-8 col-md-offset-2">
10
9
  <div class="panel panel-default">
@@ -39,8 +38,11 @@
39
38
  </div>
40
39
 
41
40
  <div class="form-group">
42
- <label for=""><%= t('plugin.ecommerce.table.expiration_date') %></label><br>
43
- <%= text_field_tag "options[expirate_date]",options[:expirate_date] || '', :class => "form-control required" %>
41
+ <label for=""><%= t('plugin.ecommerce.table.expiration_date') %></label><br>
42
+ <div class="input-group date date-input-box">
43
+ <%= text_field_tag "options[expirate_date]",options[:expirate_date] || '', :class => "form-control required", "data-locale" => current_locale %>
44
+ <span class="add-on input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span>
45
+ </div>
44
46
  </div>
45
47
 
46
48
  <div class="form-group">
@@ -59,15 +61,13 @@
59
61
  </div>
60
62
  <% end %>
61
63
  </div>
62
-
63
-
64
64
  </div>
65
65
  </div>
66
66
  </div>
67
-
68
- <% add_asset_library('datepicker') %>
69
67
  <script>
70
- run.push(function(){
71
- jQuery( '#form-coupon' ).on( "change", 'input[type="number"], #options_min_cart_total', function() {setTimeout(function(){jQuery(this).val(Math.abs(jQuery(this).val()) || 0);}.bind(this), 60)});
72
- })
68
+ jQuery(function(){
69
+ var form = jQuery( '#form-coupon');
70
+ form.on( "change", 'input[type="number"], #options_min_cart_total', function() {setTimeout(function(){jQuery(this).val(Math.abs(jQuery(this).val()) || 0);}.bind(this), 60)});
71
+ form.find('#options_expirate_date').parent().datepicker();
72
+ });
73
73
  </script>
@@ -34,7 +34,7 @@
34
34
  <td><%= options[:min_cart_total] %></td>
35
35
  <td><%= options[:expirate_date] %></td>
36
36
  <td><%= options[:allowed_applications] %></td>
37
- <td><%= options[:used_applications] || 0 %></td>
37
+ <td><%= row.used_applications %></td>
38
38
  <td>
39
39
  <%= link_to raw('<i class="fa fa-edit"></i>'), {action: :edit, id: row.id}, class: "btn btn-default btn-xs", title: "#{t('camaleon_cms.admin.button.edit')}" %>
40
40
  </td>
@@ -4,55 +4,11 @@
4
4
  </div>
5
5
  <%= form_for @order, url: {action: @order.new_record? ? :create : :update}, html: {class: 'form-order', id: 'form-order'} do |f| %>
6
6
  <div class="panel-body">
7
- <div class="row">
8
- <div class="col-md-12">
9
- <div id="user_details" class="row">
10
- <h3 class="col-md-12"><%= t('plugin.ecommerce.details_user') %></h3>
11
-
12
- <div class="form-group col-md-4">
13
- <label for=""><%= t('plugin.ecommerce.table.customer') %></label>
14
- <input class="form-control" type="text" name="order[details][customer]" value="<%= @order.details.customer rescue '' %>">
15
- </div>
16
- <div class="form-group col-md-4">
17
- <label for=""><%= t('plugin.ecommerce.table.email') %></label>
18
- <input class="form-control" type="text" name="order[details][email]" value="<%= @order.details.email rescue '' %>">
19
- </div>
20
- <div class="form-group col-md-4">
21
- <label for=""><%= t('plugin.ecommerce.table.phone') %></label>
22
- <input class="form-control" type="text" name="order[details][phone]" value="<%= @order.details.phone rescue '' %>">
23
- </div>
24
- </div>
25
- </div>
26
- <div class="col-md-12">
27
- <%= render partial: 'plugins/ecommerce/partials/form_address', locals: {billing_address: @order.get_meta("billing_address"), shipping_address: @order.get_meta("shipping_address")} %>
28
- </div>
29
- </div>
30
- <hr/>
31
- <div class="row">
32
- <div class="col-md-12">
33
- <h3 class=""> <%= t('plugin.ecommerce.products') %></h3>
34
- <table class="table">
35
- <thead>
36
- <tr>
37
- <td><%= t('plugin.ecommerce.products').singularize %></td>
38
- <td><%= t('plugin.ecommerce.product.qty') %></td>
39
- <td><%= t('plugin.ecommerce.product.price') %></td>
40
- <td><%= t('plugin.ecommerce.product.tax') %></td>
41
- </tr>
42
- </thead>
43
- <tbody>
44
- <% @order.get_meta("products", {}).each do |key, product| %>
45
- <tr>
46
- <td><%= product[:product_title] %></td>
47
- <td><%= product[:qty] %></td>
48
- <td><%= e_symbol_by_code(product[:currency_code]) %> <%= product[:price] %></td>
49
- <td><%= e_symbol_by_code(product[:currency_code]) %> <%= product[:tax] %></td>
50
- </tr>
51
- <% end %>
52
- </tbody>
53
- </table>
54
- <%#= debug @order.get_meta("products") %>
55
- </div>
7
+ <%= render plugin_view('partials/checkout/user_info'), cart: @order, as_partial: true %>
8
+ <hr>
9
+ <div class="form-group">
10
+ <%= f.label nil, t('plugin.ecommerce.show_order.consignment_number', default: 'Consignment Number') %>
11
+ <%= text_field_tag 'metas[consignment_number]', @order.get_meta('consignment_number'), class: 'form-control' %>
56
12
  </div>
57
13
  </div>
58
14