stall 0.3.3 → 0.3.4
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/para/stall/inputs/variant-select.coffee +4 -3
- data/app/assets/javascripts/stall.coffee +3 -1
- data/app/assets/javascripts/stall/add-product-to-wish-list-button.coffee +99 -0
- data/app/assets/javascripts/stall/add-to-wish-list-button.coffee +17 -0
- data/app/assets/javascripts/stall/product-list-form.coffee +31 -0
- data/app/controllers/stall/cart_line_items_controller.rb +21 -0
- data/app/controllers/stall/curated_product_lists_controller.rb +6 -0
- data/app/controllers/stall/line_items_controller.rb +14 -7
- data/app/controllers/stall/products_breadcrumbs.rb +8 -1
- data/app/controllers/stall/products_controller.rb +12 -0
- data/app/controllers/stall/wish_list_line_items_controller.rb +52 -0
- data/app/controllers/stall/wish_lists_controller.rb +7 -0
- data/app/helpers/stall/add_to_cart_helper.rb +3 -2
- data/app/helpers/stall/add_to_wish_list_helper.rb +30 -0
- data/app/helpers/stall/products_helper.rb +13 -0
- data/app/models/stall/models/cart.rb +0 -6
- data/app/models/stall/models/customer.rb +9 -0
- data/app/models/stall/models/line_item.rb +13 -0
- data/app/models/stall/models/product.rb +1 -1
- data/app/models/stall/models/product_list.rb +4 -0
- data/app/models/stall/models/variant.rb +4 -0
- data/app/models/stall/models/wish_list.rb +18 -0
- data/app/models/wish_list.rb +3 -0
- data/app/services/stall/add_to_cart_service.rb +4 -47
- data/app/services/stall/add_to_product_list_service.rb +63 -0
- data/app/services/stall/add_to_wish_list_service.rb +17 -0
- data/app/services/stall/available_stocks_service.rb +1 -1
- data/app/services/stall/shipping_fee_calculator_service.rb +22 -9
- data/app/views/admin/products/_form.html.haml +5 -0
- data/app/views/checkout/steps/_informations.html.haml +1 -1
- data/app/views/stall/addresses/_fields.html.haml +4 -4
- data/app/views/stall/{line_items → cart_line_items}/_add_error.html.haml +0 -0
- data/app/views/stall/{line_items → cart_line_items}/_added.html.haml +2 -2
- data/app/views/stall/{line_items → cart_line_items}/_form.html.haml +1 -1
- data/app/views/stall/carts/_widget.html.haml +1 -1
- data/app/views/stall/carts/show.html.haml +4 -4
- data/app/views/stall/curated_product_lists/show.html.haml +1 -1
- data/app/views/stall/customers/_fields.html.haml +1 -1
- data/app/views/stall/customers/_sign_in.html.haml +2 -2
- data/app/views/stall/products/_list.html.haml +2 -0
- data/app/views/stall/products/_product.html.haml +2 -1
- data/app/views/stall/wish_list_line_items/_add_error.html.haml +17 -0
- data/app/views/stall/wish_list_line_items/_added.html.haml +19 -0
- data/app/views/stall/wish_list_line_items/_button.html.haml +3 -0
- data/app/views/stall/wish_list_line_items/_form.html.haml +12 -0
- data/app/views/stall/wish_lists/show.html.haml +21 -0
- data/config/locales/stall.fr.yml +26 -0
- data/db/migrate/20170425085606_add_weight_to_stall_products_and_variants.rb +6 -0
- data/db/migrate/20170426163450_add_vat_rate_to_stall_products.rb +5 -0
- data/db/migrate/20170522062334_change_variants_weight_default_to_nil.rb +11 -0
- data/lib/generators/stall/install/templates/initializer.rb +18 -0
- data/lib/stall.rb +1 -0
- data/lib/stall/addressable.rb +35 -4
- data/lib/stall/addresses/copy_source_to_target.rb +14 -10
- data/lib/stall/addresses/prefill_target_from_source.rb +10 -6
- data/lib/stall/config.rb +4 -0
- data/lib/stall/engine.rb +1 -0
- data/lib/stall/routes.rb +42 -19
- data/lib/stall/sellable.rb +1 -1
- data/lib/stall/shipping/calculator.rb +1 -1
- data/lib/stall/shipping/country_weight_table_calculator.rb +3 -2
- data/lib/stall/version.rb +1 -1
- data/lib/stall/wish_list_helper.rb +93 -0
- metadata +26 -6
- data/app/assets/javascripts/stall/cart-form.coffee +0 -28
data/lib/stall/sellable.rb
CHANGED
@@ -8,7 +8,8 @@ module Stall
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def price
|
11
|
-
|
11
|
+
# Convert weight from grams to kilograms.
|
12
|
+
total_weight = (cart.total_weight / 1000.0)
|
12
13
|
|
13
14
|
# Browse the data hash to find a suitable country code for the cart's
|
14
15
|
# total weight
|
@@ -58,7 +59,7 @@ module Stall
|
|
58
59
|
|
59
60
|
csv.each do |row|
|
60
61
|
max_weight = row.first.to_f
|
61
|
-
price = BigDecimal.new(row[index])
|
62
|
+
price = BigDecimal.new(row[index]) if row[index]
|
62
63
|
hash[country_code][max_weight] = price
|
63
64
|
end
|
64
65
|
end
|
data/lib/stall/version.rb
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
module Stall
|
2
|
+
module WishListHelper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
if respond_to?(:helper_method)
|
7
|
+
helper_method :current_wish_list
|
8
|
+
end
|
9
|
+
|
10
|
+
if respond_to?(:after_action)
|
11
|
+
after_action :store_wish_list_to_cookies
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def current_wish_list
|
16
|
+
RequestStore.store[wish_list_key] ||= load_current_wish_list
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def current_wish_list_key
|
22
|
+
params[:wish_list_key].try(:to_sym) || :default
|
23
|
+
end
|
24
|
+
|
25
|
+
def load_current_wish_list(identifier = current_wish_list_key)
|
26
|
+
if (wish_list = find_wish_list(identifier))
|
27
|
+
return prepare_wish_list(wish_list)
|
28
|
+
end
|
29
|
+
|
30
|
+
# If no token was stored or the token does not exist anymore, create a
|
31
|
+
# new wish_list and store the new token
|
32
|
+
#
|
33
|
+
prepare_wish_list(wish_list_class.new(identifier: identifier))
|
34
|
+
end
|
35
|
+
|
36
|
+
def prepare_wish_list(wish_list)
|
37
|
+
wish_list.tap do
|
38
|
+
wish_list.customer = current_customer if current_customer
|
39
|
+
# Keep track of potential customer locale switching to allow e-mailing
|
40
|
+
# him in his last used locale
|
41
|
+
#
|
42
|
+
# Only applicable if the locale is an available locale to avoid strange
|
43
|
+
# issues with some URL locale management systems that could set the
|
44
|
+
# `assets` prefix as a locale, for instance.
|
45
|
+
if wish_list.customer && I18n.locale.in?(I18n.available_locales)
|
46
|
+
wish_list.customer.locale = I18n.locale
|
47
|
+
end
|
48
|
+
|
49
|
+
# Only update locale change for existing wish_lists. New wish_lists don't need
|
50
|
+
# to be saved, avoiding each robot or simple visitors to create a
|
51
|
+
# wish_list on large shops.
|
52
|
+
wish_list.save unless wish_list.new_record?
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def find_wish_list(identifier, ensure_active_wish_list = true)
|
57
|
+
if (wish_list_token = cookies.encrypted[wish_list_key(identifier)])
|
58
|
+
if (current_wish_list = ProductList.find_by_token(wish_list_token)) &&
|
59
|
+
(!ensure_active_wish_list || current_wish_list.active?)
|
60
|
+
then
|
61
|
+
return current_wish_list
|
62
|
+
else
|
63
|
+
# Remove any wish_list that can't be fetched, either because it's already
|
64
|
+
# paid, or because it was cleaned out
|
65
|
+
remove_wish_list_from_cookies(identifier)
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def remove_wish_list_from_cookies(identifier = current_wish_list_key)
|
72
|
+
cookies.delete(wish_list_key(identifier))
|
73
|
+
end
|
74
|
+
|
75
|
+
def wish_list_key(identifier = current_wish_list_key, namespace: nil)
|
76
|
+
['stall', 'wish_list', namespace, identifier.to_s].compact.join('.')
|
77
|
+
end
|
78
|
+
|
79
|
+
def wish_list_class
|
80
|
+
WishList
|
81
|
+
end
|
82
|
+
|
83
|
+
def store_wish_list_to_cookies
|
84
|
+
if current_wish_list.persisted? && current_wish_list.active?
|
85
|
+
store_wish_list_cookie_for(current_wish_list.identifier, current_wish_list)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def store_wish_list_cookie_for(identifier, wish_list, namespace: nil)
|
90
|
+
cookies.encrypted.permanent[wish_list_key(identifier, namespace: namespace)] = wish_list.token
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -413,9 +413,11 @@ files:
|
|
413
413
|
- app/assets/javascripts/para/stall/inputs/variants-matrix/properties_select.coffee
|
414
414
|
- app/assets/javascripts/para/stall/inputs/variants-matrix/variant.coffee
|
415
415
|
- app/assets/javascripts/stall.coffee
|
416
|
+
- app/assets/javascripts/stall/add-product-to-wish-list-button.coffee
|
416
417
|
- app/assets/javascripts/stall/add-to-cart-form.coffee
|
418
|
+
- app/assets/javascripts/stall/add-to-wish-list-button.coffee
|
417
419
|
- app/assets/javascripts/stall/addresses-fields.coffee
|
418
|
-
- app/assets/javascripts/stall/
|
420
|
+
- app/assets/javascripts/stall/product-list-form.coffee
|
419
421
|
- app/assets/javascripts/stall/products-filters.coffee
|
420
422
|
- app/assets/javascripts/stall/remote-sign-in-form.coffee
|
421
423
|
- app/assets/stylesheets/para/stall.sass
|
@@ -425,6 +427,7 @@ files:
|
|
425
427
|
- app/controllers/para/stall/admin/shipping_notes_controller.rb
|
426
428
|
- app/controllers/stall/application_controller.rb
|
427
429
|
- app/controllers/stall/cart_credits_controller.rb
|
430
|
+
- app/controllers/stall/cart_line_items_controller.rb
|
428
431
|
- app/controllers/stall/carts_controller.rb
|
429
432
|
- app/controllers/stall/checkout/steps_controller.rb
|
430
433
|
- app/controllers/stall/checkout_base_controller.rb
|
@@ -438,7 +441,10 @@ files:
|
|
438
441
|
- app/controllers/stall/products_breadcrumbs.rb
|
439
442
|
- app/controllers/stall/products_controller.rb
|
440
443
|
- app/controllers/stall/products_search.rb
|
444
|
+
- app/controllers/stall/wish_list_line_items_controller.rb
|
445
|
+
- app/controllers/stall/wish_lists_controller.rb
|
441
446
|
- app/helpers/stall/add_to_cart_helper.rb
|
447
|
+
- app/helpers/stall/add_to_wish_list_helper.rb
|
442
448
|
- app/helpers/stall/application_helper.rb
|
443
449
|
- app/helpers/stall/checkout_helper.rb
|
444
450
|
- app/helpers/stall/credit_notes_helper.rb
|
@@ -447,6 +453,7 @@ files:
|
|
447
453
|
- app/helpers/stall/payments_helper.rb
|
448
454
|
- app/helpers/stall/prices_helper.rb
|
449
455
|
- app/helpers/stall/products_filters_helper.rb
|
456
|
+
- app/helpers/stall/products_helper.rb
|
450
457
|
- app/mailers/stall/admin_mailer.rb
|
451
458
|
- app/mailers/stall/base_mailer.rb
|
452
459
|
- app/mailers/stall/customer_mailer.rb
|
@@ -507,11 +514,15 @@ files:
|
|
507
514
|
- app/models/stall/models/user_omniauth_account.rb
|
508
515
|
- app/models/stall/models/variant.rb
|
509
516
|
- app/models/stall/models/variant_property_value.rb
|
517
|
+
- app/models/stall/models/wish_list.rb
|
510
518
|
- app/models/user.rb
|
511
519
|
- app/models/user_omniauth_account.rb
|
512
520
|
- app/models/variant.rb
|
513
521
|
- app/models/variant_property_value.rb
|
522
|
+
- app/models/wish_list.rb
|
514
523
|
- app/services/stall/add_to_cart_service.rb
|
524
|
+
- app/services/stall/add_to_product_list_service.rb
|
525
|
+
- app/services/stall/add_to_wish_list_service.rb
|
515
526
|
- app/services/stall/available_stocks_service.rb
|
516
527
|
- app/services/stall/base_service.rb
|
517
528
|
- app/services/stall/cart_credit_note_creation_service.rb
|
@@ -556,6 +567,9 @@ files:
|
|
556
567
|
- app/views/stall/addresses/_fields.html.haml
|
557
568
|
- app/views/stall/addresses/_nested_fields.html.haml
|
558
569
|
- app/views/stall/admin_mailer/order_paid_email.html.haml
|
570
|
+
- app/views/stall/cart_line_items/_add_error.html.haml
|
571
|
+
- app/views/stall/cart_line_items/_added.html.haml
|
572
|
+
- app/views/stall/cart_line_items/_form.html.haml
|
559
573
|
- app/views/stall/carts/_cart.html.haml
|
560
574
|
- app/views/stall/carts/_widget.html.haml
|
561
575
|
- app/views/stall/carts/show.html.haml
|
@@ -567,9 +581,6 @@ files:
|
|
567
581
|
- app/views/stall/customer_mailer/order_shipped_email.html.haml
|
568
582
|
- app/views/stall/customers/_fields.html.haml
|
569
583
|
- app/views/stall/customers/_sign_in.html.haml
|
570
|
-
- app/views/stall/line_items/_add_error.html.haml
|
571
|
-
- app/views/stall/line_items/_added.html.haml
|
572
|
-
- app/views/stall/line_items/_form.html.haml
|
573
584
|
- app/views/stall/manufacturers/show.html.haml
|
574
585
|
- app/views/stall/payments/_fields.html.haml
|
575
586
|
- app/views/stall/payments/manual_payment_gateway/_form.html.haml
|
@@ -588,6 +599,11 @@ files:
|
|
588
599
|
- app/views/stall/shared/mailers/_cart.html.haml
|
589
600
|
- app/views/stall/shared/mailers/_shipping_note.html.haml
|
590
601
|
- app/views/stall/shipments/_fields.html.haml
|
602
|
+
- app/views/stall/wish_list_line_items/_add_error.html.haml
|
603
|
+
- app/views/stall/wish_list_line_items/_added.html.haml
|
604
|
+
- app/views/stall/wish_list_line_items/_button.html.haml
|
605
|
+
- app/views/stall/wish_list_line_items/_form.html.haml
|
606
|
+
- app/views/stall/wish_lists/show.html.haml
|
591
607
|
- config/locales/stall.en.yml
|
592
608
|
- config/locales/stall.fr.yml
|
593
609
|
- db/migrate/20151103154313_create_stall_line_items.rb
|
@@ -638,6 +654,9 @@ files:
|
|
638
654
|
- db/migrate/20170321104203_create_stall_images.rb
|
639
655
|
- db/migrate/20170321112248_remove_image_attachment_to_stall_products.rb
|
640
656
|
- db/migrate/20170411134756_add_stock_to_stall_variants.rb
|
657
|
+
- db/migrate/20170425085606_add_weight_to_stall_products_and_variants.rb
|
658
|
+
- db/migrate/20170426163450_add_vat_rate_to_stall_products.rb
|
659
|
+
- db/migrate/20170522062334_change_variants_weight_default_to_nil.rb
|
641
660
|
- lib/ext/ransack.rb
|
642
661
|
- lib/generators/stall/checkout/step/step_generator.rb
|
643
662
|
- lib/generators/stall/checkout/step/templates/step.html.haml.erb
|
@@ -713,6 +732,7 @@ files:
|
|
713
732
|
- lib/stall/utils.rb
|
714
733
|
- lib/stall/utils/config_dsl.rb
|
715
734
|
- lib/stall/version.rb
|
735
|
+
- lib/stall/wish_list_helper.rb
|
716
736
|
- lib/tasks/stall_tasks.rake
|
717
737
|
homepage: https://github.com/glyph-fr/stall
|
718
738
|
licenses:
|
@@ -1,28 +0,0 @@
|
|
1
|
-
class Stall.CartForm extends Vertebra.View
|
2
|
-
events:
|
3
|
-
'change [data-quantity-field]': 'formUpdated'
|
4
|
-
'cocoon:after-remove': 'formUpdated'
|
5
|
-
'ajax:success': 'updateSuccess'
|
6
|
-
|
7
|
-
initialize: ->
|
8
|
-
@clean()
|
9
|
-
|
10
|
-
clean: ->
|
11
|
-
@$('[data-cart-update-button]').hide(0)
|
12
|
-
|
13
|
-
formUpdated: (e) ->
|
14
|
-
@$el.submit()
|
15
|
-
|
16
|
-
updateSuccess: (e, resp) ->
|
17
|
-
@updateCartFormWith(resp)
|
18
|
-
|
19
|
-
updateCartFormWith: (markup) =>
|
20
|
-
$form = $(markup).find('[data-cart-form]')
|
21
|
-
@$el.html($form.html())
|
22
|
-
@clean()
|
23
|
-
|
24
|
-
|
25
|
-
Stall.onDomReady ->
|
26
|
-
if ($cartForm = $('[data-cart-form]')).length
|
27
|
-
cartForm = new Stall.CartForm(el: $cartForm)
|
28
|
-
$cartForm.data('stall.cart-form', cartForm)
|