radiant-shop-extension 0.11.5 → 0.11.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/app/controllers/admin/shop/discounts/discountables_controller.rb +44 -0
- data/app/controllers/admin/shop/discounts_controller.rb +64 -0
- data/app/controllers/admin/shop/orders_controller.rb +19 -3
- data/app/controllers/admin/shop/packages_controller.rb +1 -3
- data/app/controllers/admin/shop/products_controller.rb +1 -2
- data/app/controllers/admin/shop/variants_controller.rb +3 -4
- data/app/models/form_address.rb +4 -2
- data/app/models/form_discount.rb +39 -0
- data/app/models/form_line_item.rb +1 -11
- data/app/models/shop_category.rb +3 -0
- data/app/models/shop_customer.rb +0 -9
- data/app/models/shop_discount.rb +37 -0
- data/app/models/shop_discountable.rb +64 -0
- data/app/models/shop_line_item.rb +24 -1
- data/app/models/shop_order.rb +41 -28
- data/app/models/shop_product.rb +11 -0
- data/app/models/shop_product_variant.rb +3 -0
- data/app/models/shop_variant.rb +1 -3
- data/app/views/admin/shop/discounts/edit.html.haml +11 -0
- data/app/views/admin/shop/discounts/edit/_foot.html.haml +16 -0
- data/app/views/admin/shop/discounts/edit/_form.html.haml +15 -0
- data/app/views/admin/shop/discounts/edit/_head.html.haml +4 -0
- data/app/views/admin/shop/discounts/edit/_inputs.html.haml +2 -0
- data/app/views/admin/shop/discounts/edit/_meta.html.haml +8 -0
- data/app/views/admin/shop/discounts/edit/_parts.html.haml +9 -0
- data/app/views/admin/shop/discounts/edit/_popups.html.haml +4 -0
- data/app/views/admin/shop/discounts/edit/buttons/_browse_categories.html.haml +1 -0
- data/app/views/admin/shop/discounts/edit/buttons/_browse_products.html.haml +1 -0
- data/app/views/admin/shop/discounts/edit/inputs/_amount.html.haml +3 -0
- data/app/views/admin/shop/discounts/edit/inputs/_code.html.haml +3 -0
- data/app/views/admin/shop/discounts/edit/inputs/_name.html.haml +3 -0
- data/app/views/admin/shop/discounts/edit/meta/_finish.html.haml +5 -0
- data/app/views/admin/shop/discounts/edit/meta/_start.html.haml +5 -0
- data/app/views/admin/shop/discounts/edit/parts/_categories.html.haml +3 -0
- data/app/views/admin/shop/discounts/edit/parts/_products.html.haml +3 -0
- data/app/views/admin/shop/discounts/edit/popups/_browse_categories.html.haml +6 -0
- data/app/views/admin/shop/discounts/edit/popups/_browse_products.html.haml +6 -0
- data/app/views/admin/shop/discounts/edit/shared/_category.html.haml +11 -0
- data/app/views/admin/shop/discounts/edit/shared/_product.html.haml +12 -0
- data/app/views/admin/shop/discounts/index.html.haml +13 -0
- data/app/views/admin/shop/discounts/index/_discount.html.haml +13 -0
- data/app/views/admin/shop/discounts/index/_foot.html.haml +5 -0
- data/app/views/admin/shop/discounts/index/_head.html.haml +2 -0
- data/app/views/admin/shop/discounts/index/buttons/_new_discount.html.haml +1 -0
- data/app/views/admin/shop/discounts/new.html.haml +11 -0
- data/app/views/admin/shop/discounts/remove.html.haml +12 -0
- data/app/views/admin/shop/orders/index.html.haml +1 -1
- data/app/views/admin/shop/orders/index/_foot.html.haml +3 -1
- data/app/views/admin/shop/orders/index/_head.html.haml +1 -3
- data/app/views/admin/shop/packages/index.html.haml +1 -1
- data/app/views/admin/shop/packages/index/_foot.html.haml +3 -2
- data/app/views/admin/shop/packages/index/_head.html.haml +1 -3
- data/app/views/admin/shop/packages/index/buttons/_new_package.html.haml +1 -0
- data/app/views/admin/shop/products/index.html.haml +1 -1
- data/app/views/admin/shop/products/index/_foot.html.haml +3 -2
- data/app/views/admin/shop/products/index/_head.html.haml +1 -3
- data/app/views/admin/shop/products/index/buttons/_add_category.html.haml +1 -0
- data/app/views/admin/shop/products/index/buttons/_variants.html.haml +1 -1
- data/app/views/admin/shop/variants/index.html.haml +1 -1
- data/app/views/admin/shop/variants/index/_foot.html.haml +3 -2
- data/app/views/admin/shop/variants/index/_head.html.haml +1 -3
- data/app/views/admin/shop/variants/index/buttons/_add_variant.html.haml +1 -0
- data/app/views/admin/shop/variants/index/buttons/_categories.html.haml +1 -0
- data/config/routes.rb +11 -5
- data/db/migrate/20101010071143_create_discounts.rb +29 -0
- data/db/migrate/20101010072225_modify_categories_remove_variant.rb +9 -0
- data/db/migrate/20101010130034_change_discountables_add_observer.rb +15 -0
- data/db/migrate/20101011063133_change_orders_set_limits_to_null.rb +11 -0
- data/lib/shop/interface/discounts.rb +34 -0
- data/lib/shop/interface/orders.rb +2 -2
- data/lib/shop/interface/packages.rb +2 -2
- data/lib/shop/interface/products.rb +2 -2
- data/lib/shop/interface/variants.rb +2 -2
- data/lib/shop/models/form_extension.rb +12 -1
- data/lib/shop/models/user.rb +18 -0
- data/lib/shop/tags/cart.rb +24 -0
- data/lib/shop/tags/helpers.rb +1 -1
- data/lib/shop/tags/item.rb +26 -11
- data/lib/shop/tags/tax.rb +73 -0
- data/lib/tasks/shop_extension_tasks.rake +1 -1
- data/mockups/discounts/new-edit.bmml +49 -49
- data/public/javascripts/admin/extensions/shop/discounts/edit.js +76 -0
- data/public/stylesheets/sass/admin/extensions/shop/discounts/edit.sass +125 -0
- data/public/stylesheets/sass/admin/extensions/shop/index.sass +14 -40
- data/radiant-shop-extension.gemspec +70 -7
- data/shop_extension.rb +23 -12
- data/spec/controllers/admin/shop/discounts/discountables_controller_spec.rb +73 -0
- data/spec/controllers/admin/shop/discounts_controller_spec.rb +81 -0
- data/spec/controllers/admin/shop/orders_controller_spec.rb +35 -0
- data/spec/datasets/forms.rb +23 -12
- data/spec/datasets/shop_discountables.rb +22 -0
- data/spec/datasets/shop_discounts.rb +29 -0
- data/spec/lib/shop/tags/cart_spec.rb +75 -1
- data/spec/lib/shop/tags/item_spec.rb +4 -7
- data/spec/lib/shop/tags/tax_spec.rb +201 -0
- data/spec/models/form_discount_spec.rb +63 -0
- data/spec/models/shop_category_spec.rb +8 -0
- data/spec/models/shop_discount_spec.rb +130 -0
- data/spec/models/shop_discountable_spec.rb +114 -0
- data/spec/models/shop_line_item_spec.rb +9 -1
- data/spec/models/shop_order_spec.rb +253 -199
- data/spec/models/shop_product_spec.rb +31 -2
- data/spec/models/shop_variant_spec.rb +0 -15
- metadata +97 -21
- data/app/views/admin/shop/products/index/buttons/_discounts.html.haml +0 -1
- data/app/views/admin/shop/products/index/buttons/_packages.html.haml +0 -1
@@ -0,0 +1 @@
|
|
1
|
+
= link_to image('plus') + " " + t("add_package"), new_admin_shop_package_path
|
@@ -1,7 +1,8 @@
|
|
1
1
|
%ul
|
2
2
|
- render_region :foot do |foot|
|
3
|
-
- foot.
|
4
|
-
|
3
|
+
- foot.buttons do
|
4
|
+
- @buttons.each do |button|
|
5
|
+
%li= render :partial => "admin/shop/products/index/buttons/#{button}"
|
5
6
|
|
6
7
|
:javascript
|
7
8
|
if(typeof(ROUTES) === 'undefined') ROUTES = new Array();
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to image('plus') + " " + t("add_category"), new_admin_shop_category_path
|
@@ -1 +1 @@
|
|
1
|
-
= link_to t("variants"), admin_shop_variants_path
|
1
|
+
= link_to t("variants"), admin_shop_variants_path
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to image('plus') + " " + t("add_variant"), new_admin_shop_variant_path
|
@@ -0,0 +1 @@
|
|
1
|
+
= link_to t("products"), admin_shop_products_path
|
data/config/routes.rb
CHANGED
@@ -7,20 +7,26 @@ ActionController::Routing::Routes.draw do |map|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
shop.resources :products, :except => :new, :collection => { :sort => :put } do |product|
|
10
|
-
product.resources :images, :controller => 'products/images', :collection => { :sort => :put }
|
11
|
-
product.resources :variants, :controller => 'products/variants',
|
12
|
-
product.resources :variant_templates, :controller => 'products/variant_templates',
|
10
|
+
product.resources :images, :controller => 'products/images', :only => [:index, :create, :destroy], :collection => { :sort => :put }
|
11
|
+
product.resources :variants, :controller => 'products/variants', :only => [ :create, :destroy]
|
12
|
+
product.resources :variant_templates, :controller => 'products/variant_templates', :only => [ :update ]
|
13
|
+
product.resources :discounts, :controller => 'products/discounts', :only => [ :create, :destroy]
|
14
|
+
product.resources :discount_templates,:controller => 'products/discount_templates', :only => [ :update ]
|
13
15
|
end
|
14
16
|
|
15
17
|
shop.resources :packages, :member => { :remove => :get } do |packages|
|
16
|
-
packages.resources :packings, :controller => 'packages/packings', :collection => { :sort => :put }
|
18
|
+
packages.resources :packings, :controller => 'packages/packings', :only => [:create, :update, :destroy], :collection => { :sort => :put }
|
19
|
+
end
|
20
|
+
|
21
|
+
shop.resources :discounts, :member => { :remove => :get } do |discounts|
|
22
|
+
discounts.resources :discountables, :controller => 'discounts/discountables', :only => [:create,:destroy]
|
17
23
|
end
|
18
24
|
|
19
25
|
shop.resources :variants
|
20
26
|
|
21
27
|
shop.resources :customers
|
22
28
|
|
23
|
-
shop.resources :orders
|
29
|
+
shop.resources :orders, :except => [ :destroy ], :collection => { :export => :get }
|
24
30
|
end
|
25
31
|
|
26
32
|
admin.resources :shops, :as => 'shop', :only => [ :index ]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class CreateDiscounts < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :shop_discounts do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :code
|
6
|
+
t.decimal :amount
|
7
|
+
|
8
|
+
t.datetime :starts_at
|
9
|
+
t.datetime :finishes_at
|
10
|
+
|
11
|
+
t.integer :created_by
|
12
|
+
t.integer :updated_by
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
|
17
|
+
create_table :shop_discountables do |t|
|
18
|
+
t.integer :discount_id
|
19
|
+
t.integer :discounted_id
|
20
|
+
t.string :discounted_type
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
remove_table :shop_discounts
|
27
|
+
remove_table :shop_discounteds
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ChangeDiscountablesAddObserver < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :shop_discountables, :created_by, :integer
|
4
|
+
add_column :shop_discountables, :created_at, :datetime
|
5
|
+
add_column :shop_discountables, :updated_by, :integer
|
6
|
+
add_column :shop_discountables, :updated_at, :datetime
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
remove_column :shop_discountables, :created_by
|
11
|
+
remove_column :shop_discountables, :created_at
|
12
|
+
remove_column :shop_discountables, :updated_at
|
13
|
+
remove_column :shop_discountables, :updated_by
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class ChangeOrdersSetLimitsToNull < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
change_column :shop_discounts, :starts_at, :datetime, :default => nil
|
4
|
+
change_column :shop_discounts, :finishes_at, :datetime, :default => nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
change_column :shop_discounts, :starts_at, :datetime
|
9
|
+
change_column :shop_discounts, :finishes_at, :datetime
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Shop
|
2
|
+
module Interface
|
3
|
+
module Discounts
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
attr_accessor :discounts
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def load_default_shop_discounts_regions
|
15
|
+
returning OpenStruct.new do |discounts|
|
16
|
+
discounts.edit = Radiant::AdminUI::RegionSet.new do |edit|
|
17
|
+
edit.main.concat %w{head form popups}
|
18
|
+
edit.form.concat %w{inputs meta parts foot}
|
19
|
+
edit.foot.concat %w{buttons timestamp}
|
20
|
+
end
|
21
|
+
discounts.new = discounts.edit
|
22
|
+
discounts.index = Radiant::AdminUI::RegionSet.new do |index|
|
23
|
+
index.head.concat %w{}
|
24
|
+
index.body.concat %w{name code amount modify}
|
25
|
+
index.foot.concat %w{buttons}
|
26
|
+
end
|
27
|
+
discounts.remove = discounts.index
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -20,9 +20,9 @@ module Shop
|
|
20
20
|
end
|
21
21
|
orders.new = orders.edit
|
22
22
|
orders.index = Radiant::AdminUI::RegionSet.new do |index|
|
23
|
-
index.head.concat %w{
|
23
|
+
index.head.concat %w{}
|
24
24
|
index.body.concat %w{price status updated customer}
|
25
|
-
index.foot.concat %w{}
|
25
|
+
index.foot.concat %w{buttons}
|
26
26
|
end
|
27
27
|
orders.remove = orders.index
|
28
28
|
end
|
@@ -20,9 +20,9 @@ module Shop
|
|
20
20
|
end
|
21
21
|
packages.new = packages.edit
|
22
22
|
packages.index = Radiant::AdminUI::RegionSet.new do |index|
|
23
|
-
index.head.concat %w{
|
23
|
+
index.head.concat %w{}
|
24
24
|
index.body.concat %w{name modify}
|
25
|
-
index.foot.concat %w{
|
25
|
+
index.foot.concat %w{buttons}
|
26
26
|
end
|
27
27
|
packages.remove = packages.index
|
28
28
|
end
|
@@ -20,11 +20,11 @@ module Shop
|
|
20
20
|
end
|
21
21
|
products.new = products.edit
|
22
22
|
products.index = Radiant::AdminUI::RegionSet.new do |index|
|
23
|
-
index.head.concat %w{
|
23
|
+
index.head.concat %w{}
|
24
24
|
index.category.concat %w{move name handle modify}
|
25
25
|
index.products.concat %w{body}
|
26
26
|
index.product.concat %w{move icon name sku modify}
|
27
|
-
index.foot.concat %w{
|
27
|
+
index.foot.concat %w{buttons}
|
28
28
|
end
|
29
29
|
products.remove = products.index
|
30
30
|
end
|
@@ -20,9 +20,9 @@ module Shop
|
|
20
20
|
end
|
21
21
|
variants.new = variants.edit
|
22
22
|
variants.index = Radiant::AdminUI::RegionSet.new do |index|
|
23
|
-
index.head.concat %w{
|
23
|
+
index.head.concat %w{}
|
24
24
|
index.body.concat %w{name modify}
|
25
|
-
index.foot.concat %w{
|
25
|
+
index.foot.concat %w{buttons}
|
26
26
|
end
|
27
27
|
variants.remove = variants.index
|
28
28
|
end
|
@@ -10,11 +10,22 @@ module Shop
|
|
10
10
|
@order.update_attribute(:customer_id, (current_customer.id rescue nil)) # either assign it to a user, or don't
|
11
11
|
end
|
12
12
|
|
13
|
+
# Uses the page session data to find or create the current order
|
14
|
+
def find_or_create_current_order
|
15
|
+
begin
|
16
|
+
find_current_order
|
17
|
+
rescue
|
18
|
+
@order = ShopOrder.create
|
19
|
+
@result[:session] = { :shop_order => @order.id }
|
20
|
+
@order.update_attribute(:customer_id, (current_customer.id rescue nil)) # either assign it to a user, or don't
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
13
24
|
# Returns the current logged in ShopCustomer (if it exists)
|
14
25
|
def current_customer
|
15
26
|
return @shop_customer if @shop_customer.present?
|
16
27
|
return current_user if current_user.present?
|
17
|
-
@shop_customer = ShopCustomer.find(current_user.id)
|
28
|
+
@shop_customer = ShopCustomer.find(current_user.id) rescue nil
|
18
29
|
end
|
19
30
|
end
|
20
31
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Shop
|
2
|
+
module Models
|
3
|
+
module User
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
has_many :orders, :class_name => 'ShopOrder', :foreign_key => :customer_id
|
8
|
+
has_many :billings, :through => :orders
|
9
|
+
has_many :shippings, :through => :orders
|
10
|
+
|
11
|
+
accepts_nested_attributes_for :orders, :allow_destroy => true
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/shop/tags/cart.rb
CHANGED
@@ -23,6 +23,30 @@ module Shop
|
|
23
23
|
tag.expand unless tag.locals.shop_order.present?
|
24
24
|
end
|
25
25
|
|
26
|
+
# Expand the payment context for the cart
|
27
|
+
desc %{ Expand the payment context for the cart }
|
28
|
+
tag 'shop:cart:payment' do |tag|
|
29
|
+
tag.expand
|
30
|
+
end
|
31
|
+
|
32
|
+
# Expand if the user has paid for their cart
|
33
|
+
desc %{ Expand if the user has paid for their cart }
|
34
|
+
tag 'shop:cart:payment:if_paid' do |tag|
|
35
|
+
tag.expand if tag.locals.shop_order.payment.present? and tag.locals.shop_order.paid?
|
36
|
+
end
|
37
|
+
|
38
|
+
# Expand unless the user has paid for their cart
|
39
|
+
desc %{ Expand unless the user has paid for their cart }
|
40
|
+
tag 'shop:cart:payment:unless_paid' do |tag|
|
41
|
+
tag.expand unless tag.locals.shop_order.payment.present? and tag.locals.shop_order.paid?
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the date of the payment
|
45
|
+
desc %{ Returns the date of the payment }
|
46
|
+
tag 'shop:cart:payment:date' do |tag|
|
47
|
+
tag.locals.shop_order.payment.created_at.to_s(:long)
|
48
|
+
end
|
49
|
+
|
26
50
|
# Display the cart id / status
|
27
51
|
[:id, :status, :quantity, :weight].each do |symbol|
|
28
52
|
desc %{ outputs the #{symbol} to the cart }
|
data/lib/shop/tags/helpers.rb
CHANGED
@@ -244,7 +244,7 @@ module Shop
|
|
244
244
|
result
|
245
245
|
end
|
246
246
|
|
247
|
-
def currency(number,attr)
|
247
|
+
def currency(number,attr = {})
|
248
248
|
number_to_currency(number.to_f,
|
249
249
|
:precision =>(attr[:precision] || Radiant::Config['shop.price_precision']).to_i,
|
250
250
|
:unit => attr[:unit] || Radiant::Config['shop.price_unit'],
|
data/lib/shop/tags/item.rb
CHANGED
@@ -59,11 +59,35 @@ module Shop
|
|
59
59
|
end
|
60
60
|
|
61
61
|
# Output the related elements attributes
|
62
|
-
[:name, :sku
|
62
|
+
[:name, :sku].each do |symbol|
|
63
63
|
desc %{ outputs the #{symbol} of the current cart item }
|
64
64
|
tag "shop:cart:item:#{symbol}" do |tag|
|
65
65
|
tag.locals.shop_line_item.item.send(symbol)
|
66
|
-
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
[:price, :value, :discounted].each do |symbol|
|
70
|
+
desc %{ outputs the #{symbol} of the current cart item }
|
71
|
+
tag "shop:cart:item:#{symbol}" do |tag|
|
72
|
+
attr = tag.attr.symbolize_keys
|
73
|
+
item = tag.locals.shop_line_item
|
74
|
+
|
75
|
+
Helpers.currency(item.send(symbol),attr)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc %{ expands if the item has a discount}
|
80
|
+
tag "shop:cart:item:if_discounted" do |tag|
|
81
|
+
item = tag.locals.shop_line_item
|
82
|
+
|
83
|
+
tag.expand if item.price != item.value
|
84
|
+
end
|
85
|
+
|
86
|
+
desc %{ expands if the item has a discount}
|
87
|
+
tag "shop:cart:item:unless_discounted" do |tag|
|
88
|
+
item = tag.locals.shop_line_item
|
89
|
+
|
90
|
+
tag.expand if item.price == item.value
|
67
91
|
end
|
68
92
|
|
69
93
|
desc %{ generates a link to the items generated page }
|
@@ -78,15 +102,6 @@ module Shop
|
|
78
102
|
%{<a href="#{item.slug}"#{attributes}>#{text}</a>}
|
79
103
|
end
|
80
104
|
|
81
|
-
# Output the price of the line item
|
82
|
-
desc %{ outputs the total price of the current cart item }
|
83
|
-
tag 'shop:cart:item:price' do |tag|
|
84
|
-
attr = tag.attr.symbolize_keys
|
85
|
-
item = tag.locals.shop_line_item
|
86
|
-
|
87
|
-
Helpers.currency(item.price,attr)
|
88
|
-
end
|
89
|
-
|
90
105
|
end
|
91
106
|
end
|
92
107
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Shop
|
2
|
+
module Tags
|
3
|
+
module Tax
|
4
|
+
include Radiant::Taggable
|
5
|
+
|
6
|
+
# Expand regardless of tax conditions
|
7
|
+
tag 'shop:cart:tax' do |tag|
|
8
|
+
tag.locals.shop_tax = {
|
9
|
+
:strategy => Radiant::Config['shop.tax_strategy'],
|
10
|
+
:name => Radiant::Config['shop.tax_name'],
|
11
|
+
:percentage => Radiant::Config['shop.tax_percentage'],
|
12
|
+
}
|
13
|
+
tag.expand
|
14
|
+
end
|
15
|
+
|
16
|
+
# Expand if tax is configured
|
17
|
+
desc %{ Expand if tax is configured }
|
18
|
+
tag 'shop:cart:tax:if_tax' do |tag|
|
19
|
+
tag.expand if ['inclusive','exclusive'].include?(tag.locals.shop_tax[:strategy])
|
20
|
+
end
|
21
|
+
|
22
|
+
# Expand unless tax is configured
|
23
|
+
desc %{ Expand unless tax is configured }
|
24
|
+
tag 'shop:cart:tax:unless_tax' do |tag|
|
25
|
+
tag.expand unless ['inclusive','exclusive'].include?(tag.locals.shop_tax[:strategy])
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return the strategy of the tax
|
29
|
+
desc %{ Return the name of the tax }
|
30
|
+
tag 'shop:cart:tax:strategy' do |tag|
|
31
|
+
tag.locals.shop_tax[:strategy]
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return the strategy of the tax
|
35
|
+
desc %{ Return the name of the tax }
|
36
|
+
tag 'shop:cart:tax:strategy' do |tag|
|
37
|
+
tag.locals.shop_tax[:strategy]
|
38
|
+
end
|
39
|
+
|
40
|
+
# Return the name of the tax
|
41
|
+
desc %{ Return the name of the tax }
|
42
|
+
tag 'shop:cart:tax:name' do |tag|
|
43
|
+
tag.locals.shop_tax[:name]
|
44
|
+
end
|
45
|
+
|
46
|
+
# Return the percentage of the tax
|
47
|
+
desc %{ Return the name of the tax }
|
48
|
+
tag 'shop:cart:tax:percentage' do |tag|
|
49
|
+
tag.locals.shop_tax[:percentage]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Return the cost of tax on the cart
|
53
|
+
desc %{ Return the cost of tax on the cart }
|
54
|
+
tag 'shop:cart:tax:cost' do |tag|
|
55
|
+
attr = tag.attr.symbolize_keys
|
56
|
+
Helpers.currency(tag.locals.shop_order.tax,attr)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Expand if tax is inclusive
|
60
|
+
desc %{ Expand if tax is inclusive }
|
61
|
+
tag 'shop:cart:tax:if_inclusive' do |tag|
|
62
|
+
tag.expand if tag.locals.shop_tax[:strategy] === 'inclusive'
|
63
|
+
end
|
64
|
+
|
65
|
+
# Expand if tax is exclusive
|
66
|
+
desc %{ Expand if tax is exclusive }
|
67
|
+
tag 'shop:cart:tax:if_exclusive' do |tag|
|
68
|
+
tag.expand if tag.locals.shop_tax[:strategy] === 'exclusive'
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|