camaleon_ecommerce 1.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/plugins/ecommerce/admin_product.js.coffee +17 -1
- data/app/controllers/plugins/ecommerce/admin/coupons_controller.rb +1 -1
- data/app/controllers/plugins/ecommerce/admin/orders_controller.rb +24 -21
- data/app/controllers/plugins/ecommerce/admin/payment_methods_controller.rb +2 -34
- data/app/controllers/plugins/ecommerce/admin/prices_controller.rb +3 -6
- data/app/controllers/plugins/ecommerce/admin/settings_controller.rb +2 -1
- data/app/controllers/plugins/ecommerce/admin/shipping_methods_controller.rb +2 -2
- data/app/controllers/plugins/ecommerce/admin/tax_rates_controller.rb +1 -1
- data/app/controllers/plugins/ecommerce/admin_controller.rb +2 -2
- data/app/controllers/plugins/ecommerce/front/checkout_controller.rb +34 -18
- data/app/controllers/plugins/ecommerce/front/orders_controller.rb +3 -4
- data/app/controllers/plugins/ecommerce/front_controller.rb +26 -11
- data/app/decorators/plugins/ecommerce/cart_decorator.rb +5 -5
- data/app/decorators/plugins/ecommerce/coupon_decorator.rb +8 -27
- data/app/decorators/plugins/ecommerce/order_decorator.rb +1 -1
- data/app/decorators/plugins/ecommerce/product_decorator.rb +33 -20
- data/app/decorators/plugins/ecommerce/product_item_decorator.rb +8 -2
- data/app/decorators/plugins/ecommerce/product_variation_decorator.rb +1 -1
- data/app/helpers/plugins/ecommerce/ecommerce_email_helper.rb +7 -6
- data/app/helpers/plugins/ecommerce/ecommerce_functions_helper.rb +276 -33
- data/app/helpers/plugins/ecommerce/ecommerce_helper.rb +59 -56
- data/app/models/plugins/ecommerce/attribute.rb +3 -0
- data/app/models/plugins/ecommerce/cart.rb +31 -7
- data/app/models/plugins/ecommerce/legacy_order.rb +1 -30
- data/app/models/plugins/ecommerce/order.rb +11 -5
- data/app/models/plugins/ecommerce/order_detail.rb +1 -0
- data/app/models/plugins/ecommerce/payment_method.rb +9 -5
- data/app/models/plugins/ecommerce/product_variation.rb +6 -0
- data/app/services/plugins/ecommerce/cart_service.rb +4 -17
- data/app/views/camaleon_cms/html_mailer/order_canceled.html.erb +2 -2
- data/app/views/camaleon_cms/html_mailer/order_confirmed.html.erb +2 -2
- data/app/views/camaleon_cms/html_mailer/order_received.html.erb +5 -3
- data/app/views/camaleon_cms/html_mailer/order_received_admin.html.erb +3 -3
- data/app/views/camaleon_cms/html_mailer/order_shipped.html.erb +2 -2
- data/app/views/camaleon_cms/html_mailer/recovery_cart.html.erb +3 -3
- data/app/views/plugins/ecommerce/admin/coupons/form.html.erb +11 -11
- data/app/views/plugins/ecommerce/admin/coupons/index.html.erb +11 -11
- data/app/views/plugins/ecommerce/admin/orders/form.html.erb +2 -2
- data/app/views/plugins/ecommerce/admin/orders/index.html.erb +53 -63
- data/app/views/plugins/ecommerce/admin/payment_methods/form.html.erb +30 -24
- data/app/views/plugins/ecommerce/admin/payment_methods/index.html.erb +8 -8
- data/app/views/plugins/ecommerce/admin/payment_methods/show.html.erb +22 -22
- data/app/views/plugins/ecommerce/admin/prices/form.html.erb +6 -6
- data/app/views/plugins/ecommerce/admin/prices/index.html.erb +8 -8
- data/app/views/plugins/ecommerce/admin/product_attributes.html.erb +1 -1
- data/app/views/plugins/ecommerce/admin/products/_variations.html.erb +4 -4
- data/app/views/plugins/ecommerce/admin/products/index.html.erb +5 -5
- data/app/views/plugins/ecommerce/admin/settings/index.html.erb +20 -8
- data/app/views/plugins/ecommerce/admin/shipping_methods/form.html.erb +5 -5
- data/app/views/plugins/ecommerce/admin/shipping_methods/index.html.erb +8 -9
- data/app/views/plugins/ecommerce/admin/shipping_methods/show.html.erb +4 -4
- data/app/views/plugins/ecommerce/admin/tax_rates/form.html.erb +3 -3
- data/app/views/plugins/ecommerce/admin/tax_rates/index.html.erb +7 -7
- data/app/views/plugins/ecommerce/front/checkout/index.html.erb +4 -4
- data/app/views/plugins/ecommerce/front/login.html.erb +3 -6
- data/app/views/plugins/ecommerce/front/orders/show.html.erb +7 -1
- data/app/views/plugins/ecommerce/partials/_cart_widget.html.erb +14 -29
- data/app/views/plugins/ecommerce/partials/checkout/_details.html.erb +1 -1
- data/app/views/plugins/ecommerce/partials/checkout/_payments.html.erb +100 -99
- data/app/views/plugins/ecommerce/partials/checkout/_user_info.html.erb +2 -2
- data/app/views/post_types/commerce/{_product_widget.html.erb → _post_list_item.html.erb} +0 -0
- data/app/views/post_types/commerce/_product_info.html.erb +45 -0
- data/app/views/post_types/commerce/single.html.erb +63 -85
- data/config/camaleon_plugin.json +3 -8
- data/config/custom_models.rb +28 -4
- data/config/locales/en.yml +27 -12
- data/config/locales/es.yml +70 -57
- data/config/routes.rb +1 -0
- data/db/migrate/20161202182552_add_cookie_key_to_cart.rb +5 -0
- data/lib/ecommerce/version.rb +1 -1
- metadata +7 -14
- data/app/helpers/plugins/ecommerce/ecommerce_payment_helper.rb +0 -6
- data/app/models/plugins/ecommerce/legacy_cart.rb +0 -50
- data/app/services/plugins/ecommerce/product_item_service.rb +0 -29
- data/app/services/plugins/ecommerce/product_service.rb +0 -17
- data/app/services/plugins/ecommerce/site_service.rb +0 -21
- data/app/services/plugins/ecommerce/user_cart_service.rb +0 -12
- data/app/services/plugins/ecommerce/user_product_service.rb +0 -29
- data/app/views/post_types/commerce.html.erb +0 -22
- data/app/views/post_types/commerce/category.html.erb +0 -23
@@ -1,50 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::LegacyCart < CamaleonCms::TermTaxonomy
|
2
|
-
default_scope { where(taxonomy: :ecommerce_cart) }
|
3
|
-
has_many :products, foreign_key: :objectid, through: :term_relationships, :source => :objects
|
4
|
-
belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id
|
5
|
-
|
6
|
-
def add_product(object)
|
7
|
-
post_id = defined?(object.id) ? object.id : object.to_i
|
8
|
-
term_relationships.where(objectid: post_id).first_or_create if post_id > 0
|
9
|
-
end
|
10
|
-
|
11
|
-
# update or set product quantity
|
12
|
-
# return true if it is possible to add the quantity
|
13
|
-
# return false if quantity is not enough
|
14
|
-
def set_product_qty(product, qty)
|
15
|
-
_options = self.get_option("product_#{product.id}")
|
16
|
-
if qty.to_f <= product.the_qty_real.to_f
|
17
|
-
_options['qty'] = qty
|
18
|
-
self.set_option("product_#{product.id}", _options)
|
19
|
-
true
|
20
|
-
else
|
21
|
-
false
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def remove_product(object)
|
26
|
-
post_id = defined?(object.id) ? object.id : object.to_i
|
27
|
-
term_relationships.where(objectid: post_id).destroy_all if post_id > 0
|
28
|
-
end
|
29
|
-
|
30
|
-
def the_items_count
|
31
|
-
options.map{|k, p| p[:qty].to_i}.inject{|sum,x| sum + x } || 0 rescue 0
|
32
|
-
end
|
33
|
-
|
34
|
-
def the_amount_total
|
35
|
-
options.map{|k, p| (p[:price].to_f + p[:tax])* p[:qty].to_f}.inject{|sum,x| sum + x } || 0 rescue 0
|
36
|
-
end
|
37
|
-
|
38
|
-
# return the price of current cart ($10)
|
39
|
-
def the_price
|
40
|
-
"#{self.site.decorate.current_unit}#{sprintf('%.2f', the_amount_total)}"
|
41
|
-
end
|
42
|
-
|
43
|
-
# set user in filter
|
44
|
-
def self.set_user(user)
|
45
|
-
user_id = defined?(user.id) ? user.id : user.to_i
|
46
|
-
self.where(user_id: user_id)
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::ProductItemService
|
2
|
-
def initialize(site, product_item)
|
3
|
-
@site = site
|
4
|
-
@product_item = product_item
|
5
|
-
end
|
6
|
-
|
7
|
-
attr_reader :site, :product_item
|
8
|
-
|
9
|
-
def user
|
10
|
-
@user ||= product_item.cart.user
|
11
|
-
end
|
12
|
-
|
13
|
-
def product
|
14
|
-
@product ||= product_item.product
|
15
|
-
end
|
16
|
-
|
17
|
-
def decrement_qty!
|
18
|
-
available_qty = Plugins::Ecommerce::UserProductService.new(
|
19
|
-
site, user, product, product_item.variation_id).available_qty
|
20
|
-
val = (available_qty - product_item.qty).to_i
|
21
|
-
if val >= 0
|
22
|
-
if product_item.variation_id.present?
|
23
|
-
product_item.product_variation.update_column(:qty, val)
|
24
|
-
else
|
25
|
-
product.update_field_value('ecommerce_qty', val)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::ProductService
|
2
|
-
def initialize(site, product, variation_id = nil)
|
3
|
-
@site = site
|
4
|
-
@product = product
|
5
|
-
@variation_id = variation_id
|
6
|
-
end
|
7
|
-
|
8
|
-
attr_reader :site, :product, :variation_id
|
9
|
-
|
10
|
-
def available_qty
|
11
|
-
if variation_id.present?
|
12
|
-
product.decorate.get_variation(variation_id).qty || 0
|
13
|
-
else
|
14
|
-
product.get_field_value('ecommerce_qty').to_f || 0
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::SiteService
|
2
|
-
def initialize(site)
|
3
|
-
@site = site
|
4
|
-
end
|
5
|
-
|
6
|
-
attr_reader :site
|
7
|
-
|
8
|
-
def currency
|
9
|
-
site.get_meta("_setting_ecommerce", {})[:current_unit] || 'USD'
|
10
|
-
end
|
11
|
-
|
12
|
-
def payment_method(type)
|
13
|
-
payment_method = site.payment_methods.actives.detect do |payment_method|
|
14
|
-
payment_method.get_option('type') == type
|
15
|
-
end
|
16
|
-
if payment_method.nil?
|
17
|
-
raise ArgumentError, "Payment method #{type} is not found"
|
18
|
-
end
|
19
|
-
payment_method
|
20
|
-
end
|
21
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::UserCartService
|
2
|
-
def initialize(site, user)
|
3
|
-
@site = site
|
4
|
-
@user = user
|
5
|
-
end
|
6
|
-
|
7
|
-
attr_reader :site, :user
|
8
|
-
|
9
|
-
def get_cart
|
10
|
-
site.carts.set_user(user).active_cart.first_or_create(name: "Cart by #{user.id}").decorate
|
11
|
-
end
|
12
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class Plugins::Ecommerce::UserProductService
|
2
|
-
def initialize(site, user, product, variation_id = nil)
|
3
|
-
@site = site
|
4
|
-
@user = user
|
5
|
-
@product = product
|
6
|
-
@variation_id = variation_id
|
7
|
-
end
|
8
|
-
|
9
|
-
attr_reader :site, :user, :product, :variation_id
|
10
|
-
|
11
|
-
def available_qty
|
12
|
-
available_qty = Plugins::Ecommerce::ProductService.new(
|
13
|
-
site, product, variation_id).available_qty
|
14
|
-
available_qty -= qty_in_carts
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def qty_in_carts
|
20
|
-
carts = site.carts.where.not(user_id: user.id).active_cart.joins(:product_items)
|
21
|
-
if variation_id.present?
|
22
|
-
carts.where("#{Plugins::Ecommerce::ProductItemDecorator.table_name}" =>
|
23
|
-
{variation_id: variation_id}).sum("#{Plugins::Ecommerce::ProductItem.table_name}.qty")
|
24
|
-
else
|
25
|
-
carts.where("#{Plugins::Ecommerce::ProductItemDecorator.table_name}" =>
|
26
|
-
{product_id: product.id}).sum("#{Plugins::Ecommerce::ProductItem.table_name}.qty")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<article id="post_type-view" class="post_type_<%= @post_type.slug %>">
|
2
|
-
<%= render partial: 'partials/breadcrumb', locals: {breadcrumb: @post_type.the_breadcrumb } %>
|
3
|
-
<h1><%= @post_type.the_title %> <%= @post_type.the_edit_link %></h1>
|
4
|
-
<div class="content">
|
5
|
-
<%= raw @post_type.the_content %>
|
6
|
-
</div><br><br>
|
7
|
-
|
8
|
-
<% if @categories.present? %>
|
9
|
-
<div class="categories_list">
|
10
|
-
<%= render partial: "partials/categories_list", locals: {categories: @categories} %>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="row">
|
15
|
-
<% @posts.decorate.each_with_index do |post, index| %>
|
16
|
-
<%= raw "<div class='clearfix'></div>" if index%3 == 0 && index > 0 %>
|
17
|
-
<%= render 'post_types/commerce/product_widget', post: post %>
|
18
|
-
<% end %>
|
19
|
-
</div>
|
20
|
-
<%= content_tag("div", raw(ct('no_contents_found', default: 'No contents found.')), class: "alert alert-warning") if @posts.empty? %>
|
21
|
-
<%= will_paginate @posts, renderer: BootstrapPagination::Rails if @posts.present? %>
|
22
|
-
</article>
|
@@ -1,23 +0,0 @@
|
|
1
|
-
<article id="category-view" class="category_<%= @category.slug %>">
|
2
|
-
<%= render partial: 'partials/breadcrumb', locals: {breadcrumb: @category.the_breadcrumb } %>
|
3
|
-
<h1><%= @category.the_title %><%= @category.the_edit_link %></h1>
|
4
|
-
<div class="content">
|
5
|
-
<%= raw @category.the_content %>
|
6
|
-
</div><br><br>
|
7
|
-
|
8
|
-
<% if @children.present? %>
|
9
|
-
<div class="well">
|
10
|
-
<%= render partial: "partials/categories_list", locals: {categories: @children } %>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
|
14
|
-
<div class="row">
|
15
|
-
<% @posts.decorate.each_with_index do |post, index| %>
|
16
|
-
<%= raw "<div class='clearfix'></div>" if index%3 == 0 && index > 0 %>
|
17
|
-
<%= render 'post_types/commerce/product_widget', post: post %>
|
18
|
-
<% end %>
|
19
|
-
</div>
|
20
|
-
<%= content_tag("div", raw(ct('no_contents_found', default: 'No contents found')), class: "alert alert-warning") if @posts.empty? %>
|
21
|
-
<%= will_paginate @posts, renderer: BootstrapPagination::Rails if @posts.present? %>
|
22
|
-
|
23
|
-
</article>
|