spree_core 3.6.6 → 3.7.0.rc1
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/spree.js +60 -0
- data/app/finders/spree/countries/find.rb +31 -0
- data/app/finders/spree/credit_cards/find.rb +12 -0
- data/app/finders/spree/line_items/find_by_variant.rb +13 -0
- data/app/finders/spree/orders/find_current.rb +34 -0
- data/app/finders/spree/products/find.rb +93 -0
- data/app/finders/spree/taxons/find.rb +79 -0
- data/app/helpers/spree/base_helper.rb +7 -3
- data/app/helpers/spree/products_helper.rb +2 -1
- data/app/models/concerns/spree/adjustment_source.rb +11 -6
- data/app/models/concerns/spree/user_address.rb +2 -2
- data/app/models/concerns/spree/vat_price_calculation.rb +2 -1
- data/app/models/spree/ability.rb +2 -2
- data/app/models/spree/address.rb +23 -14
- data/app/models/spree/adjustable/adjustments_updater.rb +1 -1
- data/app/models/spree/adjustable/promotion_accumulator.rb +2 -1
- data/app/models/spree/adjustment.rb +18 -3
- data/app/models/spree/asset/support/active_storage.rb +1 -1
- data/app/models/spree/calculator.rb +1 -4
- data/app/models/spree/calculator/flexi_rate.rb +8 -11
- data/app/models/spree/calculator/returns/default_refund_amount.rb +3 -1
- data/app/models/spree/calculator/shipping/flexi_rate.rb +13 -13
- data/app/models/spree/country.rb +4 -0
- data/app/models/spree/credit_card.rb +8 -2
- data/app/models/spree/customer_return.rb +1 -0
- data/app/models/spree/fulfilment_changer.rb +117 -0
- data/app/models/spree/gateway.rb +1 -0
- data/app/models/spree/gateway/bogus.rb +3 -2
- data/app/models/spree/image.rb +13 -0
- data/app/models/spree/image/configuration/active_storage.rb +3 -3
- data/app/models/spree/inventory_unit.rb +1 -1
- data/app/models/spree/line_item.rb +3 -2
- data/app/models/spree/order.rb +72 -28
- data/app/models/spree/order/checkout.rb +10 -0
- data/app/models/spree/order/store_credit.rb +14 -35
- data/app/models/spree/order_contents.rb +22 -118
- data/app/models/spree/order_inventory.rb +6 -2
- data/app/models/spree/order_merger.rb +1 -3
- data/app/models/spree/order_promotion.rb +10 -0
- data/app/models/spree/order_updater.rb +11 -8
- data/app/models/spree/payment.rb +9 -3
- data/app/models/spree/payment/processing.rb +4 -4
- data/app/models/spree/preferences/store.rb +3 -3
- data/app/models/spree/product.rb +32 -0
- data/app/models/spree/product/scopes.rb +13 -34
- data/app/models/spree/product_property.rb +1 -1
- data/app/models/spree/promotion.rb +2 -0
- data/app/models/spree/promotion/actions/create_adjustment.rb +6 -1
- data/app/models/spree/promotion/actions/create_item_adjustments.rb +10 -2
- data/app/models/spree/promotion/actions/create_line_items.rb +3 -2
- data/app/models/spree/promotion/actions/free_shipping.rb +1 -0
- data/app/models/spree/promotion/rules/item_total.rb +2 -2
- data/app/models/spree/promotion_handler/coupon.rb +10 -6
- data/app/models/spree/promotion_handler/page.rb +1 -1
- data/app/models/spree/promotion_handler/promotion_duplicator.rb +4 -4
- data/app/models/spree/refund.rb +1 -1
- data/app/models/spree/reimbursement/reimbursement_type_engine.rb +1 -0
- data/app/models/spree/reimbursement_tax_calculator.rb +2 -2
- data/app/models/spree/return_item.rb +7 -4
- data/app/models/spree/return_item/eligibility_validator/default.rb +6 -6
- data/app/models/spree/return_item/exchange_variant_eligibility/same_product.rb +1 -1
- data/app/models/spree/shipment.rb +27 -34
- data/app/models/spree/shipping_method.rb +2 -0
- data/app/models/spree/shipping_rate.rb +31 -16
- data/app/models/spree/stock/adjuster.rb +1 -0
- data/app/models/spree/stock/estimator.rb +2 -0
- data/app/models/spree/stock/inventory_unit_builder.rb +5 -5
- data/app/models/spree/stock/packer.rb +1 -0
- data/app/models/spree/stock/quantifier.rb +16 -4
- data/app/models/spree/stock_item.rb +1 -0
- data/app/models/spree/stock_location.rb +1 -1
- data/app/models/spree/stock_movement.rb +1 -0
- data/app/models/spree/stock_transfer.rb +1 -1
- data/app/models/spree/store_credit.rb +5 -10
- data/app/models/spree/tax_rate.rb +3 -0
- data/app/models/spree/taxon.rb +2 -2
- data/app/models/spree/taxon_image.rb +18 -0
- data/app/models/spree/{taxon_icon → taxon_image}/configuration/active_storage.rb +2 -2
- data/app/models/spree/{taxon_icon → taxon_image}/configuration/paperclip.rb +1 -1
- data/app/models/spree/variant.rb +28 -2
- data/app/models/spree/zone.rb +5 -5
- data/app/paginators/spree/shared/paginate.rb +19 -0
- data/app/services/spree/cart/add_item.rb +43 -0
- data/app/services/spree/cart/create.rb +21 -0
- data/app/services/spree/cart/recalculate.rb +32 -0
- data/app/services/spree/cart/remove_item.rb +37 -0
- data/app/services/spree/cart/remove_line_item.rb +16 -0
- data/app/services/spree/cart/set_quantity.rb +22 -0
- data/app/services/spree/cart/update.rb +37 -0
- data/app/services/spree/checkout/add_store_credit.rb +51 -0
- data/app/services/spree/checkout/advance.rb +18 -0
- data/app/services/spree/checkout/complete.rb +23 -0
- data/app/services/spree/checkout/get_shipping_rates.rb +48 -0
- data/app/services/spree/checkout/next.rb +13 -0
- data/app/services/spree/checkout/remove_store_credit.rb +17 -0
- data/app/services/spree/checkout/update.rb +13 -0
- data/app/services/spree/compare_line_items.rb +21 -0
- data/app/services/spree/generate_token.rb +20 -0
- data/app/sorters/spree/products/sort.rb +58 -0
- data/config/locales/en.yml +20 -1
- data/db/default/spree/countries.rb +1 -1
- data/db/default/spree/default_reimbursement_type.rb +1 -1
- data/db/default/spree/roles.rb +2 -2
- data/db/default/spree/states.rb +2 -1
- data/db/default/spree/stores.rb +1 -1
- data/db/default/spree/zones.rb +5 -6
- data/db/migrate/20120831092320_spree_one_two.rb +36 -36
- data/db/migrate/20120831092359_spree_promo_one_two.rb +1 -1
- data/db/migrate/20130211190146_create_spree_stock_items.rb +1 -1
- data/db/migrate/20130211191120_create_spree_stock_locations.rb +1 -1
- data/db/migrate/20130301162924_create_shipping_method_categories.rb +1 -1
- data/db/migrate/20130304162240_create_spree_shipping_rates.rb +1 -1
- data/db/migrate/20130305143310_create_stock_movements.rb +1 -1
- data/db/migrate/20130418125341_create_spree_stock_transfers.rb +1 -1
- data/db/migrate/20140205120320_create_spree_payment_capture_events.rb +1 -1
- data/db/migrate/20140309023735_migrate_old_preferences.rb +5 -1
- data/db/migrate/20140309024355_create_spree_stores.rb +1 -1
- data/db/migrate/20140625214618_create_spree_refunds.rb +1 -1
- data/db/migrate/20140702140656_create_spree_return_authorization_inventory_unit.rb +1 -1
- data/db/migrate/20140713140455_create_spree_return_authorization_reasons.rb +1 -1
- data/db/migrate/20140713140527_create_spree_refund_reasons.rb +1 -1
- data/db/migrate/20140715182625_create_spree_promotion_categories.rb +1 -1
- data/db/migrate/20140718133010_create_spree_customer_returns.rb +1 -1
- data/db/migrate/20140725131539_create_spree_reimbursements.rb +1 -1
- data/db/migrate/20140731150017_create_spree_reimbursement_types.rb +1 -1
- data/db/migrate/20150118210639_create_spree_store_credits.rb +1 -1
- data/db/migrate/20150118211500_create_spree_store_credit_categories.rb +1 -1
- data/db/migrate/20150118212051_create_spree_store_credit_events.rb +1 -1
- data/db/migrate/20150118212101_create_spree_store_credit_types.rb +1 -1
- data/db/migrate/20150309161154_ensure_payments_have_numbers.rb +6 -2
- data/db/migrate/20180613080857_rename_guest_token_to_token_in_orders.rb +5 -0
- data/db/migrate/20180915160001_add_timestamps_to_spree_prices.rb +12 -0
- data/db/migrate/20181024100754_add_deleted_at_to_spree_credit_cards.rb +6 -0
- data/lib/generators/spree/custom_user/custom_user_generator.rb +1 -3
- data/lib/generators/spree/dummy/dummy_generator.rb +30 -33
- data/lib/generators/spree/dummy/templates/rails/database.yml +6 -1
- data/lib/generators/spree/dummy/templates/rails/test.rb +2 -0
- data/lib/generators/spree/dummy_model/dummy_model_generator.rb +1 -1
- data/lib/generators/spree/install/install_generator.rb +2 -1
- data/lib/spree/core.rb +2 -4
- data/lib/spree/core/controller_helpers/auth.rb +15 -5
- data/lib/spree/core/controller_helpers/common.rb +0 -11
- data/lib/spree/core/controller_helpers/order.rb +6 -6
- data/lib/spree/core/controller_helpers/respond_with.rb +3 -1
- data/lib/spree/core/controller_helpers/strong_parameters.rb +1 -0
- data/lib/spree/core/engine.rb +9 -3
- data/lib/spree/core/importer/order.rb +8 -12
- data/lib/spree/core/product_duplicator.rb +6 -1
- data/lib/spree/core/product_filters.rb +15 -14
- data/lib/spree/core/query_filters.rb +11 -0
- data/lib/spree/core/query_filters/comparable.rb +46 -0
- data/lib/spree/core/query_filters/date.rb +8 -0
- data/lib/spree/core/query_filters/number.rb +8 -0
- data/lib/spree/core/query_filters/text.rb +32 -0
- data/lib/spree/core/token_generator.rb +2 -2
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/i18n.rb +1 -1
- data/lib/spree/migrations.rb +2 -0
- data/lib/spree/money.rb +12 -12
- data/lib/spree/permitted_attributes.rb +11 -6
- data/lib/spree/service_module.rb +98 -0
- data/lib/spree/testing_support/capybara_config.rb +20 -0
- data/lib/spree/testing_support/capybara_ext.rb +6 -3
- data/lib/spree/testing_support/factories.rb +1 -1
- data/lib/spree/testing_support/factories/address_factory.rb +10 -9
- data/lib/spree/testing_support/factories/adjustment_factory.rb +8 -6
- data/lib/spree/testing_support/factories/country_factory.rb +4 -4
- data/lib/spree/testing_support/factories/credit_card_factory.rb +7 -5
- data/lib/spree/testing_support/factories/customer_return_factory.rb +1 -1
- data/lib/spree/testing_support/factories/image_factory.rb +7 -1
- data/lib/spree/testing_support/factories/inventory_unit_factory.rb +5 -4
- data/lib/spree/testing_support/factories/line_item_factory.rb +3 -2
- data/lib/spree/testing_support/factories/options_factory.rb +2 -3
- data/lib/spree/testing_support/factories/order_factory.rb +16 -12
- data/lib/spree/testing_support/factories/order_promotion_factory.rb +6 -0
- data/lib/spree/testing_support/factories/payment_factory.rb +9 -7
- data/lib/spree/testing_support/factories/payment_method_factory.rb +8 -8
- data/lib/spree/testing_support/factories/price_factory.rb +2 -2
- data/lib/spree/testing_support/factories/product_factory.rb +10 -10
- data/lib/spree/testing_support/factories/promotion_category_factory.rb +1 -1
- data/lib/spree/testing_support/factories/promotion_factory.rb +14 -4
- data/lib/spree/testing_support/factories/property_factory.rb +2 -2
- data/lib/spree/testing_support/factories/prototype_factory.rb +3 -3
- data/lib/spree/testing_support/factories/refund_factory.rb +6 -6
- data/lib/spree/testing_support/factories/reimbursement_factory.rb +1 -1
- data/lib/spree/testing_support/factories/reimbursement_type_factory.rb +2 -2
- data/lib/spree/testing_support/factories/return_authorization_factory.rb +4 -3
- data/lib/spree/testing_support/factories/role_factory.rb +1 -1
- data/lib/spree/testing_support/factories/shipment_factory.rb +3 -3
- data/lib/spree/testing_support/factories/shipping_method_factory.rb +4 -4
- data/lib/spree/testing_support/factories/state_factory.rb +2 -5
- data/lib/spree/testing_support/factories/stock_factory.rb +3 -3
- data/lib/spree/testing_support/factories/stock_item_factory.rb +1 -1
- data/lib/spree/testing_support/factories/stock_location_factory.rb +7 -7
- data/lib/spree/testing_support/factories/stock_movement_factory.rb +3 -3
- data/lib/spree/testing_support/factories/store_credit_category_factory.rb +2 -2
- data/lib/spree/testing_support/factories/store_credit_type_factory.rb +1 -1
- data/lib/spree/testing_support/factories/store_factory.rb +5 -4
- data/lib/spree/testing_support/factories/tax_rate_factory.rb +2 -1
- data/lib/spree/testing_support/factories/user_factory.rb +4 -4
- data/lib/spree/testing_support/factories/variant_factory.rb +15 -15
- data/lib/spree/testing_support/factories/zone_factory.rb +3 -3
- data/lib/spree/testing_support/image_helpers.rb +19 -0
- data/lib/tasks/core.rake +21 -4
- data/lib/tasks/exchanges.rake +4 -4
- data/spree_core.gemspec +3 -3
- data/vendor/assets/javascripts/fetch.umd.js +531 -0
- data/vendor/assets/javascripts/polyfill.min.js +1 -0
- metadata +50 -17
- data/app/assets/javascripts/spree.js.coffee +0 -59
- data/app/models/spree/taxon_icon.rb +0 -5
- data/lib/generators/spree/dummy/templates/initializers/custom_user.rb +0 -1
- data/lib/spree/core/environment.rb +0 -15
- data/lib/spree/core/environment/calculators.rb +0 -11
- data/lib/spree/core/environment_extension.rb +0 -28
- data/lib/spree/core/validators/email.rb +0 -8
- data/lib/spree/promo/environment.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49eb4666a35ce5b88c3ce5bc92b0cf34503851edee70623f215bc674ea3d322f
|
4
|
+
data.tar.gz: cefaa50b133701b0572392a03c11bdf4544e9ca97aa0eaa34e5293cd2892336f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d422e99c814605fe9cbb9ce7eaf3bedd80e93f6298446bd6a9b30cc8d1d3d8e8d870926222aa437bb6d58a0ec725bfb1192a0d28c48c1cadc9a97e0dd3d504d
|
7
|
+
data.tar.gz: caf99f8ededb70977b1e1eba5adcaff62a60108d62b469b82d885921539f8acc1f84528a9161d28f48f7f6ab7755e866eb34392df936904dc1aaaa29a59becf6
|
@@ -0,0 +1,60 @@
|
|
1
|
+
//= require jsuri
|
2
|
+
function Spree () {}
|
3
|
+
|
4
|
+
Spree.ready = function (callback) {
|
5
|
+
jQuery(callback)
|
6
|
+
return jQuery(document).on('page:load turbolinks:load', function () {
|
7
|
+
return callback(jQuery)
|
8
|
+
})
|
9
|
+
}
|
10
|
+
|
11
|
+
Spree.mountedAt = function () {
|
12
|
+
return window.SpreePaths.mounted_at
|
13
|
+
}
|
14
|
+
|
15
|
+
Spree.adminPath = function () {
|
16
|
+
return window.SpreePaths.admin
|
17
|
+
}
|
18
|
+
|
19
|
+
Spree.pathFor = function (path) {
|
20
|
+
var locationOrigin = (window.location.protocol + '//' + window.location.hostname) + (window.location.port ? ':' + window.location.port : '')
|
21
|
+
return this.url('' + locationOrigin + (this.mountedAt()) + path, this.url_params).toString()
|
22
|
+
}
|
23
|
+
|
24
|
+
Spree.adminPathFor = function (path) {
|
25
|
+
return this.pathFor('' + (this.adminPath()) + path)
|
26
|
+
}
|
27
|
+
|
28
|
+
Spree.url = function (uri, query) {
|
29
|
+
if (uri.path === void 0) {
|
30
|
+
// eslint-disable-next-line no-undef
|
31
|
+
uri = new Uri(uri)
|
32
|
+
}
|
33
|
+
if (query) {
|
34
|
+
$.each(query, function (key, value) {
|
35
|
+
return uri.addQueryParam(key, value)
|
36
|
+
})
|
37
|
+
}
|
38
|
+
return uri
|
39
|
+
}
|
40
|
+
|
41
|
+
Spree.ajax = function (urlOrSettings, settings) {
|
42
|
+
var url
|
43
|
+
if (typeof urlOrSettings === 'string') {
|
44
|
+
return $.ajax(Spree.url(urlOrSettings).toString(), settings)
|
45
|
+
} else {
|
46
|
+
url = urlOrSettings['url']
|
47
|
+
delete urlOrSettings['url']
|
48
|
+
return $.ajax(Spree.url(url).toString(), urlOrSettings)
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
Spree.routes = {
|
53
|
+
states_search: Spree.pathFor('api/v1/states'),
|
54
|
+
apply_coupon_code: function (orderId) {
|
55
|
+
return Spree.pathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
|
56
|
+
},
|
57
|
+
cart: Spree.pathFor('cart')
|
58
|
+
}
|
59
|
+
|
60
|
+
Spree.url_params = {}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Spree
|
2
|
+
module Countries
|
3
|
+
class Find
|
4
|
+
def initialize(scope, params)
|
5
|
+
@scope = scope
|
6
|
+
|
7
|
+
@shippable = String(params[:filter][:shippable]) unless params[:filter].nil?
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
countries = by_shippability(scope)
|
12
|
+
|
13
|
+
countries
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
attr_reader :shippable, :scope
|
19
|
+
|
20
|
+
def shippable?
|
21
|
+
shippable.present?
|
22
|
+
end
|
23
|
+
|
24
|
+
def by_shippability(countries)
|
25
|
+
return countries unless shippable?
|
26
|
+
|
27
|
+
countries.joins(zones: :shipping_methods).distinct
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Spree
|
2
|
+
module CreditCards
|
3
|
+
class Find
|
4
|
+
def execute(scope:, params:)
|
5
|
+
return scope.default.take if params[:id].eql?('default')
|
6
|
+
return scope.where(payment_method_id: params[:filter]['payment_method_id']) if params[:filter].present?
|
7
|
+
|
8
|
+
scope
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Spree
|
2
|
+
module LineItems
|
3
|
+
class FindByVariant
|
4
|
+
def execute(order:, variant:, options: {})
|
5
|
+
order.line_items.detect do |line_item|
|
6
|
+
next unless line_item.variant_id == variant.id
|
7
|
+
|
8
|
+
CompareLineItems.new.call(order: order, line_item: line_item, options: options).value
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Spree
|
2
|
+
module Orders
|
3
|
+
class FindCurrent
|
4
|
+
def execute(user:, store:, **params)
|
5
|
+
params = params.merge(store_id: store.id)
|
6
|
+
|
7
|
+
order = incomplete_orders.find_by(params)
|
8
|
+
|
9
|
+
return order unless order.nil?
|
10
|
+
return if user.nil?
|
11
|
+
|
12
|
+
incomplete_orders.order(created_at: :desc).find_by(store: store, user: user)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def incomplete_orders
|
18
|
+
Spree::Order.incomplete.includes(scope_includes)
|
19
|
+
end
|
20
|
+
|
21
|
+
def scope_includes
|
22
|
+
{
|
23
|
+
line_items: [
|
24
|
+
variant: [
|
25
|
+
:images,
|
26
|
+
option_values: :option_type,
|
27
|
+
product: :product_properties,
|
28
|
+
]
|
29
|
+
]
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module Spree
|
2
|
+
module Products
|
3
|
+
class Find
|
4
|
+
def initialize(scope:, params:, current_currency:)
|
5
|
+
@scope = scope
|
6
|
+
|
7
|
+
@ids = String(params.dig(:filter, :ids)).split(',')
|
8
|
+
@price = String(params.dig(:filter, :price)).split(',')
|
9
|
+
@currency = params[:currency] || current_currency
|
10
|
+
@taxons = String(params.dig(:filter, :taxons)).split(',')
|
11
|
+
@name = params.dig(:filter, :name)
|
12
|
+
@options = params.dig(:filter, :options).try(:to_unsafe_hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
products = by_ids(scope)
|
17
|
+
products = by_price(products)
|
18
|
+
products = by_taxons(products)
|
19
|
+
products = by_name(products)
|
20
|
+
products = by_options(products)
|
21
|
+
|
22
|
+
products
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :ids, :price, :currency, :taxons, :name, :options, :scope
|
28
|
+
|
29
|
+
def ids?
|
30
|
+
ids.present?
|
31
|
+
end
|
32
|
+
|
33
|
+
def price?
|
34
|
+
price.present?
|
35
|
+
end
|
36
|
+
|
37
|
+
def taxons?
|
38
|
+
taxons.present?
|
39
|
+
end
|
40
|
+
|
41
|
+
def name?
|
42
|
+
name.present?
|
43
|
+
end
|
44
|
+
|
45
|
+
def options?
|
46
|
+
options.present?
|
47
|
+
end
|
48
|
+
|
49
|
+
def name_matcher
|
50
|
+
Spree::Product.arel_table[:name].matches("%#{name}%")
|
51
|
+
end
|
52
|
+
|
53
|
+
def by_ids(products)
|
54
|
+
return products unless ids?
|
55
|
+
|
56
|
+
products.where(id: ids)
|
57
|
+
end
|
58
|
+
|
59
|
+
def by_price(products)
|
60
|
+
return products unless price?
|
61
|
+
|
62
|
+
products.joins(master: :default_price).
|
63
|
+
distinct.
|
64
|
+
where(
|
65
|
+
spree_prices: {
|
66
|
+
amount: price.min..price.max,
|
67
|
+
currency: currency
|
68
|
+
}
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def by_taxons(products)
|
73
|
+
return products unless taxons?
|
74
|
+
|
75
|
+
products.joins(:taxons).distinct.where(spree_taxons: { id: taxons })
|
76
|
+
end
|
77
|
+
|
78
|
+
def by_name(products)
|
79
|
+
return products unless name?
|
80
|
+
|
81
|
+
products.where(name_matcher)
|
82
|
+
end
|
83
|
+
|
84
|
+
def by_options(products)
|
85
|
+
return products unless options?
|
86
|
+
|
87
|
+
options.map do |key, value|
|
88
|
+
products.with_option_value(key, value)
|
89
|
+
end.inject(:&)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module Spree
|
2
|
+
module Taxons
|
3
|
+
class Find
|
4
|
+
def initialize(scope:, params:)
|
5
|
+
@scope = scope
|
6
|
+
|
7
|
+
@ids = String(params[:ids]).split(',')
|
8
|
+
@parent = params[:parent_id]
|
9
|
+
@taxonomy = params[:taxonomy_id]
|
10
|
+
@name = params[:name]
|
11
|
+
@roots = params[:roots]
|
12
|
+
end
|
13
|
+
|
14
|
+
def execute
|
15
|
+
taxons = by_ids(scope)
|
16
|
+
taxons = by_parent(taxons)
|
17
|
+
taxons = by_taxonomy(taxons)
|
18
|
+
taxons = by_roots(taxons)
|
19
|
+
taxons = by_name(taxons)
|
20
|
+
|
21
|
+
taxons
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
attr_reader :ids, :parent, :taxonomy, :roots, :name, :scope
|
27
|
+
|
28
|
+
def ids?
|
29
|
+
ids.present?
|
30
|
+
end
|
31
|
+
|
32
|
+
def parent?
|
33
|
+
parent.present?
|
34
|
+
end
|
35
|
+
|
36
|
+
def taxonomy?
|
37
|
+
taxonomy.present?
|
38
|
+
end
|
39
|
+
|
40
|
+
def roots?
|
41
|
+
roots.present?
|
42
|
+
end
|
43
|
+
|
44
|
+
def name?
|
45
|
+
name.present?
|
46
|
+
end
|
47
|
+
|
48
|
+
def by_ids(taxons)
|
49
|
+
return taxons unless ids?
|
50
|
+
|
51
|
+
taxons.where(id: ids)
|
52
|
+
end
|
53
|
+
|
54
|
+
def by_parent(taxons)
|
55
|
+
return taxons unless parent?
|
56
|
+
|
57
|
+
taxons.where(parent_id: parent)
|
58
|
+
end
|
59
|
+
|
60
|
+
def by_taxonomy(taxons)
|
61
|
+
return taxons unless taxonomy?
|
62
|
+
|
63
|
+
taxons.where(taxonomy_id: taxonomy)
|
64
|
+
end
|
65
|
+
|
66
|
+
def by_roots(taxons)
|
67
|
+
return taxons unless roots?
|
68
|
+
|
69
|
+
taxons.roots
|
70
|
+
end
|
71
|
+
|
72
|
+
def by_name(taxons)
|
73
|
+
return taxons unless name?
|
74
|
+
|
75
|
+
taxons.where(name: name)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -80,8 +80,12 @@ module Spree
|
|
80
80
|
end
|
81
81
|
|
82
82
|
# human readable list of variant options
|
83
|
-
def variant_options(
|
84
|
-
|
83
|
+
def variant_options(variant, _options = {})
|
84
|
+
ActiveSupport::Deprecation.warn(<<-DEPRECATION, caller)
|
85
|
+
BaseHelper#variant_options is deprecated and will be removed in Spree 4.0.
|
86
|
+
Please use Variant#options_text or LineItem#options_text
|
87
|
+
DEPRECATION
|
88
|
+
variant.options_text
|
85
89
|
end
|
86
90
|
|
87
91
|
def frontend_available?
|
@@ -91,7 +95,7 @@ module Spree
|
|
91
95
|
private
|
92
96
|
|
93
97
|
def create_product_image_tag(image, product, options, style)
|
94
|
-
options
|
98
|
+
options[:alt] = image.alt.blank? ? product.name : image.alt
|
95
99
|
image_tag main_app.url_for(image.url(style)), options
|
96
100
|
end
|
97
101
|
|
@@ -14,6 +14,7 @@ module Spree
|
|
14
14
|
variant_amount = variant.amount_in(current_currency)
|
15
15
|
product_amount = variant.product.amount_in(current_currency)
|
16
16
|
return if variant_amount == product_amount || product_amount.nil?
|
17
|
+
|
17
18
|
diff = variant.amount_in(current_currency) - product_amount
|
18
19
|
amount = Spree::Money.new(diff.abs, currency: current_currency).to_html
|
19
20
|
label = diff > 0 ? :add : :subtract
|
@@ -63,7 +64,7 @@ module Spree
|
|
63
64
|
|
64
65
|
if product.available?
|
65
66
|
Spree.t(:available)
|
66
|
-
elsif product.available_on
|
67
|
+
elsif product.available_on&.future?
|
67
68
|
Spree.t(:pending_sale)
|
68
69
|
else
|
69
70
|
Spree.t(:no_available_date_set)
|
@@ -11,16 +11,21 @@ module Spree
|
|
11
11
|
|
12
12
|
def create_adjustment(order, adjustable, included = false)
|
13
13
|
amount = compute_amount(adjustable)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
|
15
|
+
return if amount.zero?
|
16
|
+
|
17
|
+
adjustments.new(
|
18
|
+
adjustable: adjustable,
|
19
|
+
amount: amount,
|
20
|
+
included: included,
|
21
|
+
label: label,
|
22
|
+
order: order
|
23
|
+
).save
|
20
24
|
end
|
21
25
|
|
22
26
|
def create_unique_adjustment(order, adjustable)
|
23
27
|
return if already_adjusted?(adjustable)
|
28
|
+
|
24
29
|
create_adjustment(order, adjustable)
|
25
30
|
end
|
26
31
|
|
@@ -15,14 +15,14 @@ module Spree
|
|
15
15
|
|
16
16
|
def persist_order_address(order)
|
17
17
|
b_address = bill_address || build_bill_address
|
18
|
-
b_address.attributes = order.bill_address.
|
18
|
+
b_address.attributes = order.bill_address.value_attributes
|
19
19
|
b_address.save
|
20
20
|
update_attributes(bill_address_id: b_address.id)
|
21
21
|
|
22
22
|
# May not be present if delivery step has been removed
|
23
23
|
if order.ship_address
|
24
24
|
s_address = ship_address || build_ship_address
|
25
|
-
s_address.attributes = order.ship_address.
|
25
|
+
s_address.attributes = order.ship_address.value_attributes
|
26
26
|
s_address.save
|
27
27
|
update_attributes(ship_address_id: s_address.id)
|
28
28
|
end
|
@@ -2,6 +2,7 @@ module Spree
|
|
2
2
|
module VatPriceCalculation
|
3
3
|
def gross_amount(amount, price_options)
|
4
4
|
return amount unless outside_default_vat_zone?(price_options)
|
5
|
+
|
5
6
|
round_to_two_places(add_foreign_vat_for(amount, price_options))
|
6
7
|
end
|
7
8
|
|
@@ -41,7 +42,7 @@ module Spree
|
|
41
42
|
end
|
42
43
|
|
43
44
|
def round_to_two_places(amount)
|
44
|
-
BigDecimal
|
45
|
+
BigDecimal(amount.to_s).round(2, BigDecimal::ROUND_HALF_UP)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|