solidus_frontend_devise_token_auth 2.8.0.alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +26 -0
- data/README.md +42 -0
- data/Rakefile +17 -0
- data/app/assets/config/solidus_frontend_manifest.js +4 -0
- data/app/assets/images/credit_cards/amex_cid.gif +0 -0
- data/app/assets/images/credit_cards/credit_card.gif +0 -0
- data/app/assets/images/credit_cards/discover_cid.gif +0 -0
- data/app/assets/images/credit_cards/icons/american_express.png +0 -0
- data/app/assets/images/credit_cards/icons/cirrus.png +0 -0
- data/app/assets/images/credit_cards/icons/delta.png +0 -0
- data/app/assets/images/credit_cards/icons/diners_club.png +0 -0
- data/app/assets/images/credit_cards/icons/directdebit.png +0 -0
- data/app/assets/images/credit_cards/icons/discover.png +0 -0
- data/app/assets/images/credit_cards/icons/egold.png +0 -0
- data/app/assets/images/credit_cards/icons/maestro.png +0 -0
- data/app/assets/images/credit_cards/icons/master.png +0 -0
- data/app/assets/images/credit_cards/icons/paypal.png +0 -0
- data/app/assets/images/credit_cards/icons/solo.png +0 -0
- data/app/assets/images/credit_cards/icons/switch.png +0 -0
- data/app/assets/images/credit_cards/icons/visa.png +0 -0
- data/app/assets/images/credit_cards/icons/visaelectron.png +0 -0
- data/app/assets/images/credit_cards/icons/westernunion.png +0 -0
- data/app/assets/images/credit_cards/icons/wirecard.png +0 -0
- data/app/assets/images/credit_cards/icons/worldpay.png +0 -0
- data/app/assets/images/credit_cards/master_cid.jpg +0 -0
- data/app/assets/images/credit_cards/visa_cid.gif +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/icons/add-to-cart.png +0 -0
- data/app/assets/images/icons/checkout.png +0 -0
- data/app/assets/images/icons/delete.png +0 -0
- data/app/assets/images/icons/update.png +0 -0
- data/app/assets/images/spinner.gif +0 -0
- data/app/assets/images/spree/frontend/cart.png +0 -0
- data/app/assets/javascripts/spree/frontend/cart.js +30 -0
- data/app/assets/javascripts/spree/frontend/checkout/address.js +127 -0
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +41 -0
- data/app/assets/javascripts/spree/frontend/checkout/payment.js +55 -0
- data/app/assets/javascripts/spree/frontend/checkout.js +24 -0
- data/app/assets/javascripts/spree/frontend/locale_selector.js +5 -0
- data/app/assets/javascripts/spree/frontend/product.js +81 -0
- data/app/assets/javascripts/spree/frontend.js +5 -0
- data/app/assets/stylesheets/spree/frontend/_skeleton.scss +242 -0
- data/app/assets/stylesheets/spree/frontend/_variables.scss +65 -0
- data/app/assets/stylesheets/spree/frontend/screen.css.scss +1387 -0
- data/app/assets/stylesheets/spree/frontend.css +5 -0
- data/app/controllers/spree/checkout_controller.rb +236 -0
- data/app/controllers/spree/content_controller.rb +11 -0
- data/app/controllers/spree/home_controller.rb +14 -0
- data/app/controllers/spree/locale_controller.rb +20 -0
- data/app/controllers/spree/orders_controller.rb +138 -0
- data/app/controllers/spree/products_controller.rb +52 -0
- data/app/controllers/spree/store_controller.rb +30 -0
- data/app/controllers/spree/taxons_controller.rb +31 -0
- data/app/helpers/spree/orders_helper.rb +18 -0
- data/app/helpers/spree/taxon_filters_helper.rb +13 -0
- data/app/models/spree/frontend_configuration.rb +10 -0
- data/app/views/spree/address/_form.html.erb +96 -0
- data/app/views/spree/address/_form_hidden.html.erb +12 -0
- data/app/views/spree/checkout/_address.html.erb +33 -0
- data/app/views/spree/checkout/_confirm.html.erb +25 -0
- data/app/views/spree/checkout/_coupon_code.html.erb +12 -0
- data/app/views/spree/checkout/_delivery.html.erb +108 -0
- data/app/views/spree/checkout/_payment.html.erb +67 -0
- data/app/views/spree/checkout/_summary.html.erb +76 -0
- data/app/views/spree/checkout/_terms_and_conditions.en.html.erb +1 -0
- data/app/views/spree/checkout/edit.html.erb +32 -0
- data/app/views/spree/checkout/existing_payment/_gateway.html.erb +9 -0
- data/app/views/spree/checkout/payment/_check.html.erb +0 -0
- data/app/views/spree/checkout/payment/_gateway.html.erb +36 -0
- data/app/views/spree/content/cvv.html.erb +13 -0
- data/app/views/spree/home/index.html.erb +12 -0
- data/app/views/spree/layouts/spree_application.html.erb +36 -0
- data/app/views/spree/orders/_adjustment_row.html.erb +8 -0
- data/app/views/spree/orders/_adjustments.html.erb +24 -0
- data/app/views/spree/orders/_form.html.erb +29 -0
- data/app/views/spree/orders/_line_item.html.erb +34 -0
- data/app/views/spree/orders/edit.html.erb +47 -0
- data/app/views/spree/orders/show.html.erb +22 -0
- data/app/views/spree/payments/_payment.html.erb +18 -0
- data/app/views/spree/products/_cart_form.html.erb +65 -0
- data/app/views/spree/products/_image.html.erb +8 -0
- data/app/views/spree/products/_promotions.html.erb +19 -0
- data/app/views/spree/products/_properties.html.erb +15 -0
- data/app/views/spree/products/_taxons.html.erb +14 -0
- data/app/views/spree/products/_thumbnails.html.erb +21 -0
- data/app/views/spree/products/index.html.erb +27 -0
- data/app/views/spree/products/show.html.erb +51 -0
- data/app/views/spree/shared/_address.html.erb +38 -0
- data/app/views/spree/shared/_filters.html.erb +27 -0
- data/app/views/spree/shared/_footer.html.erb +6 -0
- data/app/views/spree/shared/_head.html.erb +14 -0
- data/app/views/spree/shared/_header.html.erb +5 -0
- data/app/views/spree/shared/_image.html.erb +12 -0
- data/app/views/spree/shared/_link_to_cart.html.erb +1 -0
- data/app/views/spree/shared/_locale_selector.html.erb +25 -0
- data/app/views/spree/shared/_login_bar_items.html.erb +1 -0
- data/app/views/spree/shared/_main_nav_bar.html.erb +12 -0
- data/app/views/spree/shared/_nav_bar.html.erb +9 -0
- data/app/views/spree/shared/_order_details.html.erb +146 -0
- data/app/views/spree/shared/_products.html.erb +51 -0
- data/app/views/spree/shared/_search.html.erb +11 -0
- data/app/views/spree/shared/_shipment_tracking.html.erb +9 -0
- data/app/views/spree/shared/_sidebar.html.erb +3 -0
- data/app/views/spree/shared/_taxonomies.html.erb +9 -0
- data/app/views/spree/shared/unauthorized.html.erb +0 -0
- data/app/views/spree/store/cart_link.html.erb +1 -0
- data/app/views/spree/taxons/_taxon.html.erb +4 -0
- data/app/views/spree/taxons/show.html.erb +20 -0
- data/config/initializers/assets.rb +3 -0
- data/config/initializers/canonical_rails.rb +16 -0
- data/config/routes.rb +33 -0
- data/lib/generators/solidus/views/override_generator.rb +49 -0
- data/lib/solidus_frontend.rb +3 -0
- data/lib/spree/frontend/engine.rb +13 -0
- data/lib/spree/frontend/middleware/seo_assist.rb +52 -0
- data/lib/spree/frontend.rb +15 -0
- data/lib/spree_frontend.rb +3 -0
- data/lib/tasks/rake_util.rb +18 -0
- data/lib/tasks/taxon.rake +16 -0
- data/script/rails +10 -0
- data/solidus_frontend.gemspec +35 -0
- data/spec/controllers/controller_helpers_spec.rb +30 -0
- data/spec/controllers/locale_controller_spec.rb +57 -0
- data/spec/controllers/spree/checkout_controller_spec.rb +539 -0
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +37 -0
- data/spec/controllers/spree/content_controller_spec.rb +9 -0
- data/spec/controllers/spree/current_order_tracking_spec.rb +47 -0
- data/spec/controllers/spree/home_controller_spec.rb +29 -0
- data/spec/controllers/spree/orders_controller_ability_spec.rb +93 -0
- data/spec/controllers/spree/orders_controller_spec.rb +225 -0
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +33 -0
- data/spec/controllers/spree/products_controller_spec.rb +38 -0
- data/spec/controllers/spree/taxons_controller_spec.rb +14 -0
- data/spec/features/address_spec.rb +78 -0
- data/spec/features/automatic_promotion_adjustments_spec.rb +49 -0
- data/spec/features/caching/products_spec.rb +48 -0
- data/spec/features/caching/taxons_spec.rb +21 -0
- data/spec/features/cart_spec.rb +85 -0
- data/spec/features/checkout_spec.rb +690 -0
- data/spec/features/checkout_unshippable_spec.rb +37 -0
- data/spec/features/coupon_code_spec.rb +266 -0
- data/spec/features/currency_spec.rb +20 -0
- data/spec/features/free_shipping_promotions_spec.rb +60 -0
- data/spec/features/locale_spec.rb +27 -0
- data/spec/features/order_spec.rb +73 -0
- data/spec/features/products_spec.rb +291 -0
- data/spec/features/promotion_code_invalidation_spec.rb +54 -0
- data/spec/features/quantity_promotions_spec.rb +130 -0
- data/spec/features/taxons_spec.rb +158 -0
- data/spec/features/template_rendering_spec.rb +20 -0
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/generators/solidus/views/override_generator_spec.rb +50 -0
- data/spec/helpers/base_helper_spec.rb +13 -0
- data/spec/helpers/order_helper_spec.rb +14 -0
- data/spec/helpers/taxon_filters_helper_spec.rb +12 -0
- data/spec/spec_helper.rb +106 -0
- data/spec/support/features/fill_in_with_force.rb +12 -0
- data/spec/support/shared_contexts/checkout_setup.rb +12 -0
- data/spec/support/shared_contexts/custom_products.rb +28 -0
- data/spec/support/shared_contexts/locales.rb +16 -0
- data/spec/views/spree/checkout/_summary_spec.rb +11 -0
- metadata +337 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c643011044310b77ea816605d978591b759dcbe36598c08b73dde6c0709f3915
|
4
|
+
data.tar.gz: 430d788235a829198973a8a912d005338d7525f04d97a684437932d424a050f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa488980e9fa0ce736003dad7dc6796efd423e014de322af7fea80877e68dae66dafbbb88f0cd74fd6ed58c2b776102a27439accdaa4e5ee9f7a4c7f06c50c17
|
7
|
+
data.tar.gz: 88beffcbe773391970bb4ec82c5bf3c5b2e9169ecfde4f0e8ddea6a7d660fd4a3f3aa41f30314dbd88653a12cca00a11353c31f474afe635c4df0901d7fb34b0
|
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2007-2014, Spree Commerce, Inc. and other contributors
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# solidus\_frontend
|
2
|
+
|
3
|
+
Frontend contains controllers and views implementing a storefront and cart for Solidus.
|
4
|
+
|
5
|
+
## Override views
|
6
|
+
|
7
|
+
In order to customize a view you should copy the file into your host app. Using Deface is not
|
8
|
+
recommended as it provides lots of headaches while debugging and degrades your shops performance.
|
9
|
+
|
10
|
+
Solidus provides a generator to help with copying the right view into your host app.
|
11
|
+
|
12
|
+
Simply call the generator to copy all views into your host app.
|
13
|
+
|
14
|
+
```bash
|
15
|
+
$ bundle exec rails g solidus:views:override
|
16
|
+
```
|
17
|
+
|
18
|
+
If you only want to copy certain views into your host app, you can provide the `--only` argument:
|
19
|
+
|
20
|
+
```bash
|
21
|
+
$ bundle exec rails g solidus:views:override --only products/show
|
22
|
+
```
|
23
|
+
|
24
|
+
The argument to `--only` can also be a substring of the name of the view from the `app/views/spree` folder:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
$ bundle exec rails g solidus:views:override --only product
|
28
|
+
```
|
29
|
+
|
30
|
+
This will copy all views whose directory or filename contains the string "product".
|
31
|
+
|
32
|
+
### Handle upgrades
|
33
|
+
|
34
|
+
After upgrading Solidus to a new version run the generator again and follow on screen instructions.
|
35
|
+
|
36
|
+
## Testing
|
37
|
+
|
38
|
+
Run the tests
|
39
|
+
|
40
|
+
```bash
|
41
|
+
bundle exec rspec
|
42
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'spree/testing_support/dummy_app/rake_tasks'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new
|
10
|
+
task default: :spec
|
11
|
+
|
12
|
+
DummyApp::RakeTasks.new(
|
13
|
+
gem_root: File.expand_path(__dir__),
|
14
|
+
lib_name: 'solidus_frontend'
|
15
|
+
)
|
16
|
+
|
17
|
+
task test_app: 'db:reset'
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,30 @@
|
|
1
|
+
Spree.ready(function($) {
|
2
|
+
if ($("form#update-cart").is("*")) {
|
3
|
+
$("form#update-cart a.delete")
|
4
|
+
.show()
|
5
|
+
.one("click", function() {
|
6
|
+
$(this)
|
7
|
+
.parents(".line-item")
|
8
|
+
.first()
|
9
|
+
.find("input.line_item_quantity")
|
10
|
+
.val(0);
|
11
|
+
$(this)
|
12
|
+
.parents("form")
|
13
|
+
.first()
|
14
|
+
.submit();
|
15
|
+
return false;
|
16
|
+
});
|
17
|
+
}
|
18
|
+
$("form#update-cart").submit(function() {
|
19
|
+
$("form#update-cart #update-button").attr("disabled", true);
|
20
|
+
});
|
21
|
+
});
|
22
|
+
|
23
|
+
Spree.fetch_cart = function(cartLinkUrl) {
|
24
|
+
Spree.ajax({
|
25
|
+
url: cartLinkUrl || Spree.pathFor("cart_link"),
|
26
|
+
success: function(data) {
|
27
|
+
$("#link-to-cart").html(data);
|
28
|
+
}
|
29
|
+
});
|
30
|
+
};
|
@@ -0,0 +1,127 @@
|
|
1
|
+
Spree.ready(function($) {
|
2
|
+
if ($("#checkout_form_address").is("*")) {
|
3
|
+
// Hidden by default to support browsers with javascript disabled
|
4
|
+
$(".js-address-fields").show();
|
5
|
+
|
6
|
+
var getCountryId = function(region) {
|
7
|
+
return $("#" + region + "country select").val();
|
8
|
+
};
|
9
|
+
|
10
|
+
var statesByCountry = {};
|
11
|
+
|
12
|
+
var updateState = function(region) {
|
13
|
+
var countryId = getCountryId(region);
|
14
|
+
if (countryId != null) {
|
15
|
+
if (statesByCountry[countryId] == null) {
|
16
|
+
$.get(
|
17
|
+
Spree.routes.states_search,
|
18
|
+
{
|
19
|
+
country_id: countryId
|
20
|
+
},
|
21
|
+
function(data) {
|
22
|
+
statesByCountry[countryId] = {
|
23
|
+
states: data.states,
|
24
|
+
states_required: data.states_required
|
25
|
+
};
|
26
|
+
fillStates(region);
|
27
|
+
}
|
28
|
+
);
|
29
|
+
} else {
|
30
|
+
fillStates(region);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
};
|
34
|
+
|
35
|
+
var fillStates = function(region) {
|
36
|
+
var countryId = getCountryId(region);
|
37
|
+
var data = statesByCountry[countryId];
|
38
|
+
if (data == null) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
var statesRequired = data.states_required;
|
42
|
+
var states = data.states;
|
43
|
+
var statePara = $("#" + region + "state");
|
44
|
+
var stateSelect = statePara.find("select");
|
45
|
+
var stateInput = statePara.find("input");
|
46
|
+
if (states.length > 0) {
|
47
|
+
var selected = parseInt(stateSelect.val());
|
48
|
+
stateSelect.html("");
|
49
|
+
var statesWithBlank = [
|
50
|
+
{
|
51
|
+
name: "",
|
52
|
+
id: ""
|
53
|
+
}
|
54
|
+
].concat(states);
|
55
|
+
$.each(statesWithBlank, function(idx, state) {
|
56
|
+
var opt;
|
57
|
+
opt = $(document.createElement("option"))
|
58
|
+
.attr("value", state.id)
|
59
|
+
.html(state.name);
|
60
|
+
if (selected === state.id) {
|
61
|
+
opt.prop("selected", true);
|
62
|
+
}
|
63
|
+
stateSelect.append(opt);
|
64
|
+
});
|
65
|
+
stateSelect.prop("disabled", false).show();
|
66
|
+
stateInput.hide().prop("disabled", true);
|
67
|
+
statePara.show();
|
68
|
+
if (statesRequired) {
|
69
|
+
stateSelect.addClass("required");
|
70
|
+
statePara.addClass("field-required");
|
71
|
+
} else {
|
72
|
+
stateSelect.removeClass("required");
|
73
|
+
statePara.removeClass("field-required");
|
74
|
+
}
|
75
|
+
stateInput.removeClass("required");
|
76
|
+
} else {
|
77
|
+
stateSelect.hide().prop("disabled", true);
|
78
|
+
stateInput.show();
|
79
|
+
if (statesRequired) {
|
80
|
+
statePara.addClass("field-required");
|
81
|
+
stateInput.addClass("required");
|
82
|
+
} else {
|
83
|
+
stateInput.val("");
|
84
|
+
statePara.removeClass("field-required");
|
85
|
+
stateInput.removeClass("required");
|
86
|
+
}
|
87
|
+
statePara.toggle(!!statesRequired);
|
88
|
+
stateInput.prop("disabled", !statesRequired);
|
89
|
+
stateSelect.removeClass("required");
|
90
|
+
}
|
91
|
+
};
|
92
|
+
|
93
|
+
$("#bcountry select").change(function() {
|
94
|
+
updateState("b");
|
95
|
+
});
|
96
|
+
|
97
|
+
$("#scountry select").change(function() {
|
98
|
+
updateState("s");
|
99
|
+
});
|
100
|
+
|
101
|
+
updateState("b");
|
102
|
+
|
103
|
+
var order_use_billing = $("input#order_use_billing");
|
104
|
+
order_use_billing.change(function() {
|
105
|
+
update_shipping_form_state(order_use_billing);
|
106
|
+
});
|
107
|
+
|
108
|
+
var update_shipping_form_state = function(order_use_billing) {
|
109
|
+
if (order_use_billing.is(":checked")) {
|
110
|
+
$("#shipping .inner").hide();
|
111
|
+
$("#shipping .inner input, #shipping .inner select").prop(
|
112
|
+
"disabled",
|
113
|
+
true
|
114
|
+
);
|
115
|
+
} else {
|
116
|
+
$("#shipping .inner").show();
|
117
|
+
$("#shipping .inner input, #shipping .inner select").prop(
|
118
|
+
"disabled",
|
119
|
+
false
|
120
|
+
);
|
121
|
+
updateState("s");
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
update_shipping_form_state(order_use_billing);
|
126
|
+
}
|
127
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
Spree.onCouponCodeApply = function(e) {
|
2
|
+
e.preventDefault();
|
3
|
+
var couponCodeField = $("#order_coupon_code");
|
4
|
+
var couponCode = $.trim(couponCodeField.val());
|
5
|
+
if (couponCode === "") {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
var couponStatus = $("#coupon_status");
|
9
|
+
var successClass = "success";
|
10
|
+
var errorClass = "alert";
|
11
|
+
couponStatus.removeClass([successClass, errorClass].join(" "));
|
12
|
+
var data = {
|
13
|
+
order_token: Spree.current_order_token,
|
14
|
+
coupon_code: couponCode
|
15
|
+
};
|
16
|
+
var req = Spree.ajax({
|
17
|
+
method: "PUT",
|
18
|
+
url: Spree.routes.apply_coupon_code(Spree.current_order_id),
|
19
|
+
data: JSON.stringify(data),
|
20
|
+
contentType: "application/json"
|
21
|
+
});
|
22
|
+
req.done(function(data) {
|
23
|
+
window.location.reload();
|
24
|
+
couponCodeField.val("");
|
25
|
+
couponStatus
|
26
|
+
.addClass(successClass)
|
27
|
+
.html("Coupon code applied successfully.");
|
28
|
+
});
|
29
|
+
req.fail(function(xhr) {
|
30
|
+
var handler;
|
31
|
+
// handler = JSON.parse(xhr.responseText)
|
32
|
+
handler = xhr.responseJSON;
|
33
|
+
couponStatus.addClass(errorClass).html(handler["error"]);
|
34
|
+
});
|
35
|
+
};
|
36
|
+
|
37
|
+
Spree.ready(function($) {
|
38
|
+
$("#coupon-code-apply-button").click(function(e) {
|
39
|
+
Spree.onCouponCodeApply(e);
|
40
|
+
});
|
41
|
+
});
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Spree.ready(function($) {
|
2
|
+
Spree.onPayment = function() {
|
3
|
+
if ($("#checkout_form_payment").is("*")) {
|
4
|
+
if ($("#existing_cards").is("*")) {
|
5
|
+
$("#payment-method-fields").hide();
|
6
|
+
$("#payment-methods").hide();
|
7
|
+
|
8
|
+
$("#use_existing_card_yes").click(function() {
|
9
|
+
$("#payment-method-fields").hide();
|
10
|
+
$("#payment-methods").hide();
|
11
|
+
$(".existing-cc-radio").prop("disabled", false);
|
12
|
+
});
|
13
|
+
|
14
|
+
$("#use_existing_card_no").click(function() {
|
15
|
+
$("#payment-method-fields").show();
|
16
|
+
$("#payment-methods").show();
|
17
|
+
$(".existing-cc-radio").prop("disabled", true);
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
$(".cardNumber").payment("formatCardNumber");
|
22
|
+
$(".cardExpiry").payment("formatCardExpiry");
|
23
|
+
$(".cardCode").payment("formatCardCVC");
|
24
|
+
|
25
|
+
$(".cardNumber").change(function() {
|
26
|
+
$(this)
|
27
|
+
.parent()
|
28
|
+
.siblings(".ccType")
|
29
|
+
.val($.payment.cardType(this.value));
|
30
|
+
});
|
31
|
+
|
32
|
+
$(
|
33
|
+
'input[type="radio"][name="order[payments_attributes][][payment_method_id]"]'
|
34
|
+
).click(function() {
|
35
|
+
$("#payment-methods li").hide();
|
36
|
+
if (this.checked) {
|
37
|
+
$("#payment_method_" + this.value).show();
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
$("#cvv_link").on("click", function(event) {
|
42
|
+
var windowName = "cvv_info";
|
43
|
+
var windowOptions =
|
44
|
+
"left=20,top=20,width=500,height=500,toolbar=0,resizable=0,scrollbars=1";
|
45
|
+
window.open($(this).attr("href"), windowName, windowOptions);
|
46
|
+
event.preventDefault();
|
47
|
+
});
|
48
|
+
|
49
|
+
// Activate already checked payment method if form is re-rendered
|
50
|
+
// i.e. if user enters invalid data
|
51
|
+
$('input[type="radio"]:checked').click();
|
52
|
+
}
|
53
|
+
};
|
54
|
+
Spree.onPayment();
|
55
|
+
});
|
@@ -0,0 +1,24 @@
|
|
1
|
+
//= require jquery.payment
|
2
|
+
//= require_self
|
3
|
+
//= require spree/frontend/checkout/address
|
4
|
+
//= require spree/frontend/checkout/payment
|
5
|
+
//= require spree/frontend/checkout/coupon-code
|
6
|
+
|
7
|
+
Spree.disableSaveOnClick = function() {
|
8
|
+
$("form.edit_order").submit(function() {
|
9
|
+
$(this)
|
10
|
+
.find(":submit, :image")
|
11
|
+
.attr("disabled", true)
|
12
|
+
.removeClass("primary")
|
13
|
+
.addClass("disabled");
|
14
|
+
});
|
15
|
+
};
|
16
|
+
|
17
|
+
Spree.ready(function($) {
|
18
|
+
var termsCheckbox = $("#accept_terms_and_conditions");
|
19
|
+
termsCheckbox.change(function() {
|
20
|
+
var submitBtn = $(this.closest("form")).find(":submit");
|
21
|
+
submitBtn.prop("disabled", !this.checked);
|
22
|
+
submitBtn.toggleClass("disabled", !this.checked);
|
23
|
+
});
|
24
|
+
});
|
@@ -0,0 +1,81 @@
|
|
1
|
+
Spree.ready(function($) {
|
2
|
+
Spree.addImageHandlers = function() {
|
3
|
+
var thumbnails = $("#product-images ul.thumbnails");
|
4
|
+
$("#main-image").data("selectedThumb", $("#main-image img").attr("src"));
|
5
|
+
if (!thumbnails.find("li.selected").length) {
|
6
|
+
thumbnails
|
7
|
+
.find("li")
|
8
|
+
.eq(0)
|
9
|
+
.addClass("selected");
|
10
|
+
}
|
11
|
+
thumbnails.find("a").on("click", function(event) {
|
12
|
+
$("#main-image").data(
|
13
|
+
"selectedThumb",
|
14
|
+
$(event.currentTarget).attr("href")
|
15
|
+
);
|
16
|
+
$("#main-image").data(
|
17
|
+
"selectedThumbId",
|
18
|
+
$(event.currentTarget)
|
19
|
+
.parent()
|
20
|
+
.attr("id")
|
21
|
+
);
|
22
|
+
thumbnails.find("li").removeClass("selected");
|
23
|
+
$(event.currentTarget)
|
24
|
+
.parent("li")
|
25
|
+
.addClass("selected");
|
26
|
+
return false;
|
27
|
+
});
|
28
|
+
thumbnails.find("li").on("mouseenter", function(event) {
|
29
|
+
$("#main-image img").attr(
|
30
|
+
"src",
|
31
|
+
$(event.currentTarget)
|
32
|
+
.find("a")
|
33
|
+
.attr("href")
|
34
|
+
);
|
35
|
+
});
|
36
|
+
thumbnails.find("li").on("mouseleave", function(event) {
|
37
|
+
$("#main-image img").attr("src", $("#main-image").data("selectedThumb"));
|
38
|
+
});
|
39
|
+
};
|
40
|
+
|
41
|
+
Spree.showVariantImages = function(variantId) {
|
42
|
+
$("li.vtmb").hide();
|
43
|
+
$("li.tmb-" + variantId).show();
|
44
|
+
var currentThumb = $("#" + $("#main-image").data("selectedThumbId"));
|
45
|
+
if (!currentThumb.hasClass("vtmb-" + variantId)) {
|
46
|
+
var thumb = $($("#product-images ul.thumbnails li:visible.vtmb").eq(0));
|
47
|
+
if (!(thumb.length > 0)) {
|
48
|
+
thumb = $($("#product-images ul.thumbnails li:visible").eq(0));
|
49
|
+
}
|
50
|
+
var newImg = thumb.find("a").attr("href");
|
51
|
+
$("#product-images ul.thumbnails li").removeClass("selected");
|
52
|
+
thumb.addClass("selected");
|
53
|
+
$("#main-image img").attr("src", newImg);
|
54
|
+
$("#main-image").data("selectedThumb", newImg);
|
55
|
+
$("#main-image").data("selectedThumbId", thumb.attr("id"));
|
56
|
+
}
|
57
|
+
};
|
58
|
+
|
59
|
+
Spree.updateVariantPrice = function(variant) {
|
60
|
+
var variantPrice = variant.data("price");
|
61
|
+
if (variantPrice) {
|
62
|
+
$(".price.selling").text(variantPrice);
|
63
|
+
}
|
64
|
+
};
|
65
|
+
|
66
|
+
var radios = $('#product-variants input[type="radio"]');
|
67
|
+
if (radios.length > 0) {
|
68
|
+
var selectedRadio = $(
|
69
|
+
'#product-variants input[type="radio"][checked="checked"]'
|
70
|
+
);
|
71
|
+
Spree.showVariantImages(selectedRadio.attr("value"));
|
72
|
+
Spree.updateVariantPrice(selectedRadio);
|
73
|
+
}
|
74
|
+
|
75
|
+
Spree.addImageHandlers();
|
76
|
+
|
77
|
+
radios.click(function(event) {
|
78
|
+
Spree.showVariantImages(this.value);
|
79
|
+
Spree.updateVariantPrice($(this));
|
80
|
+
});
|
81
|
+
});
|