spree_core 5.1.0.beta4 → 5.1.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/helpers/spree/base_helper.rb +6 -1
- data/app/helpers/spree/images_helper.rb +19 -16
- data/app/helpers/spree/shipment_helper.rb +12 -0
- data/app/jobs/spree/gift_cards/bulk_generate_job.rb +13 -0
- data/app/models/concerns/spree/parameterizable_name.rb +11 -0
- data/app/models/concerns/spree/product_scopes.rb +1 -5
- data/app/models/concerns/spree/stores/socials.rb +6 -2
- data/app/models/concerns/spree/user_methods.rb +2 -1
- data/app/models/spree/ability.rb +2 -0
- data/app/models/spree/address.rb +11 -3
- data/app/models/spree/gift_card.rb +162 -0
- data/app/models/spree/gift_card_batch.rb +79 -0
- data/app/models/spree/inventory_unit.rb +11 -4
- data/app/models/spree/line_item.rb +13 -2
- data/app/models/spree/option_type.rb +5 -15
- data/app/models/spree/option_value.rb +18 -12
- data/app/models/spree/order/checkout.rb +2 -0
- data/app/models/spree/order/gift_card.rb +51 -0
- data/app/models/spree/order/store_credit.rb +20 -1
- data/app/models/spree/order.rb +51 -6
- data/app/models/spree/order_merger.rb +12 -0
- data/app/models/spree/page_sections/featured_posts.rb +4 -0
- data/app/models/spree/payment_method/store_credit.rb +1 -1
- data/app/models/spree/payment_method.rb +1 -0
- data/app/models/spree/post.rb +1 -0
- data/app/models/spree/price.rb +7 -1
- data/app/models/spree/product/slugs.rb +103 -0
- data/app/models/spree/product.rb +7 -81
- data/app/models/spree/product_property.rb +2 -2
- data/app/models/spree/promotion_handler/coupon.rb +39 -0
- data/app/models/spree/property.rb +2 -8
- data/app/models/spree/reimbursement_type/reimbursement_helpers.rb +1 -1
- data/app/models/spree/return_item.rb +4 -0
- data/app/models/spree/shipment.rb +19 -0
- data/app/models/spree/shipping_method.rb +8 -9
- data/app/models/spree/store.rb +2 -0
- data/app/models/spree/store_credit.rb +9 -6
- data/app/models/spree/store_credit_event.rb +8 -4
- data/app/models/spree/taxon.rb +8 -1
- data/app/models/spree/theme.rb +1 -1
- data/app/models/spree/variant.rb +1 -1
- data/app/presenters/spree/csv/product_variant_presenter.rb +14 -3
- data/app/services/spree/addresses/phone_validator.rb +20 -0
- data/app/services/spree/cart/destroy.rb +1 -1
- data/app/services/spree/cart/recalculate.rb +1 -0
- data/app/services/spree/gift_cards/apply.rb +66 -0
- data/app/services/spree/gift_cards/redeem.rb +17 -0
- data/app/services/spree/gift_cards/remove.rb +38 -0
- data/app/services/spree/products/prepare_nested_attributes.rb +2 -2
- data/app/views/spree/addresses/_form.html.erb +1 -1
- data/app/views/spree/shared/_payment.html.erb +4 -4
- data/config/locales/en.yml +44 -14
- data/config/routes.rb +1 -0
- data/db/migrate/20250506073057_create_spree_gift_cards_and_spree_gift_card_batches.rb +37 -0
- data/db/migrate/20250530101236_enable_pg_trgm_extension.rb +13 -0
- data/db/migrate/20250605131334_add_missing_fields_to_users.rb +25 -0
- data/lib/generators/spree/install/install_generator.rb +0 -8
- data/lib/spree/core/configuration.rb +4 -0
- data/lib/spree/core/controller_helpers/store.rb +13 -1
- data/lib/spree/core/dependencies.rb +5 -0
- data/lib/spree/core/engine.rb +7 -1
- data/lib/spree/core/version.rb +1 -1
- data/lib/spree/core.rb +2 -1
- data/lib/spree/permitted_attributes.rb +22 -9
- data/lib/spree/testing_support/authorization_helpers.rb +5 -9
- data/lib/spree/testing_support/common_rake.rb +7 -1
- data/lib/spree/testing_support/factories/gift_card_batch_factory.rb +5 -0
- data/lib/spree/testing_support/factories/gift_card_factory.rb +17 -0
- data/lib/spree/testing_support/factories/page_section_factory.rb +2 -1
- data/lib/spree/testing_support/factories/post_factory.rb +4 -0
- data/lib/spree/testing_support/factories/promotion_rule_factory.rb +4 -0
- data/lib/spree/testing_support/factories/user_factory.rb +2 -2
- metadata +45 -11
- data/config/initializers/state_machine.rb +0 -37
data/config/locales/en.yml
CHANGED
@@ -50,10 +50,12 @@ en:
|
|
50
50
|
number: Number
|
51
51
|
verification_value: Verification Value
|
52
52
|
year: Year
|
53
|
+
spree/gift_card:
|
54
|
+
amount_used: Amount used
|
55
|
+
expires_at: Expires at
|
53
56
|
spree/inventory_unit:
|
54
57
|
state: State
|
55
58
|
spree/invitation:
|
56
|
-
expires_at: Expires at
|
57
59
|
inviter: Inviter
|
58
60
|
spree/line_item:
|
59
61
|
price: Price
|
@@ -151,6 +153,8 @@ en:
|
|
151
153
|
updated: Updated
|
152
154
|
user: User
|
153
155
|
spree/store:
|
156
|
+
address: Address
|
157
|
+
contact_phone: Contact Phone
|
154
158
|
mail_from_address: Mail From Address
|
155
159
|
meta_description: Meta Description
|
156
160
|
meta_keywords: Meta Keywords
|
@@ -227,6 +231,10 @@ en:
|
|
227
231
|
base:
|
228
232
|
card_expired: Card has expired
|
229
233
|
expiry_invalid: Card expiration is invalid
|
234
|
+
spree/gift_card:
|
235
|
+
attributes:
|
236
|
+
base:
|
237
|
+
cannot_destroy_used_gift_card: Can't delete a used gift card
|
230
238
|
spree/image:
|
231
239
|
attributes:
|
232
240
|
attachment:
|
@@ -581,6 +589,7 @@ en:
|
|
581
589
|
add_address: Add address
|
582
590
|
add_country: Add Country
|
583
591
|
add_coupon_code: Add Coupon Code
|
592
|
+
add_gift_card: Add Gift Card
|
584
593
|
add_new_address: Add new address
|
585
594
|
add_new_credit_card: Add a new card
|
586
595
|
add_new_header: Add New Header
|
@@ -668,6 +677,7 @@ en:
|
|
668
677
|
api_keys: API keys
|
669
678
|
apply: Apply
|
670
679
|
apply_only_on_full_priced_items: Apply only on full priced items
|
680
|
+
apply_store_credit: Apply Store Credit
|
671
681
|
approve: approve
|
672
682
|
approved_at: Approved at
|
673
683
|
approver: Approver
|
@@ -740,6 +750,7 @@ en:
|
|
740
750
|
capture: Capture
|
741
751
|
capture_events: Capture events
|
742
752
|
card_code: Card Verification Code (CVC)
|
753
|
+
card_expiration_placeholder: MM/YYYY
|
743
754
|
card_number: Card Number
|
744
755
|
card_type: Brand
|
745
756
|
card_type_is: Card type is
|
@@ -844,10 +855,8 @@ en:
|
|
844
855
|
coupon_codes: Coupon codes
|
845
856
|
create: Create
|
846
857
|
create_a_new_account: Create a new account
|
847
|
-
create_customer: Create customer
|
848
858
|
create_new: Create new
|
849
859
|
create_new_order: Create new order
|
850
|
-
create_new_team: Create new team
|
851
860
|
create_reimbursement: Create reimbursement
|
852
861
|
created_at: Created at
|
853
862
|
created_by: Created by
|
@@ -861,10 +870,10 @@ en:
|
|
861
870
|
credits: Credits
|
862
871
|
currencies: Currencies
|
863
872
|
currency: Currency
|
873
|
+
currency_and_country_help: This determines which vendors you can connect with and what customers see on your store.
|
864
874
|
currency_settings: Currency Settings
|
865
875
|
current: Current
|
866
876
|
current_password: Current password
|
867
|
-
current_promotion_usage: 'current usage: %{count}'
|
868
877
|
custom_code: Custom code
|
869
878
|
custom_font_code: Custom font code
|
870
879
|
customer: Customer
|
@@ -890,6 +899,7 @@ en:
|
|
890
899
|
default_country: Default Country
|
891
900
|
default_country_cannot_be_deleted: Default country cannot be deleted
|
892
901
|
default_currency: Default currency
|
902
|
+
default_locale: Default locale
|
893
903
|
default_post_categories:
|
894
904
|
articles: Articles
|
895
905
|
news: News
|
@@ -915,9 +925,12 @@ en:
|
|
915
925
|
destroy: Destroy
|
916
926
|
details: Details
|
917
927
|
developers: Developers
|
928
|
+
didn_t_receive_confirmation_instructions: Didn't receive confirmation instructions?
|
929
|
+
didn_t_receive_unlock_instructions: Didn't receive unlock instructions?
|
918
930
|
digital:
|
919
931
|
digital_delivery: Digital Delivery
|
920
932
|
digital_assets: Digital assets
|
933
|
+
digital_assets_help: Digital assets are files that can be downloaded by customers after purchase.
|
921
934
|
digital_link_unauthorized: You are not authorized to access this asset
|
922
935
|
dimension_units:
|
923
936
|
centimeter: Centimeter (cm)
|
@@ -944,7 +957,7 @@ en:
|
|
944
957
|
download: Download
|
945
958
|
draft: Draft
|
946
959
|
draft_mode: Draft Mode
|
947
|
-
draft_orders: Draft
|
960
|
+
draft_orders: Draft Orders
|
948
961
|
duplicate: Duplicate
|
949
962
|
duplicating: Duplicating
|
950
963
|
edit: Edit
|
@@ -1026,6 +1039,7 @@ en:
|
|
1026
1039
|
expiration: Expiration
|
1027
1040
|
expiration_date: Expiration Date
|
1028
1041
|
expired: Expired
|
1042
|
+
expires_at: Expires at
|
1029
1043
|
explore_taxon: Explore taxon
|
1030
1044
|
export: Export
|
1031
1045
|
export_mailer:
|
@@ -1080,8 +1094,14 @@ en:
|
|
1080
1094
|
general_settings: General Settings
|
1081
1095
|
generate_code: Generate coupon code
|
1082
1096
|
get_back_to_the: Get back to the
|
1083
|
-
gift_card: Gift
|
1084
|
-
|
1097
|
+
gift_card: Gift Card
|
1098
|
+
gift_card_already_redeemed: The Gift Card has already been redeemed.
|
1099
|
+
gift_card_applied: The Gift Card was successfully applied to your order!
|
1100
|
+
gift_card_batch: Gift Card Batch
|
1101
|
+
gift_card_expired: The Gift Card has expired.
|
1102
|
+
gift_card_removed: The Gift Card was successfully removed from your order
|
1103
|
+
gift_card_using_store_credit_error: You can't apply the Gift Card after you applied the store credit.
|
1104
|
+
gift_cards: Gift Cards
|
1085
1105
|
go_to_category: Go to category
|
1086
1106
|
go_to_facebook: Go to facebook
|
1087
1107
|
go_to_homepage: Go to Home Page
|
@@ -1172,7 +1192,6 @@ en:
|
|
1172
1192
|
iso: ISO Alpha-2
|
1173
1193
|
iso3: ISO Alpha-3
|
1174
1194
|
iso_name: ISO Name
|
1175
|
-
issue_gift_card: Issue Gift Card
|
1176
1195
|
issued_on: Issued On
|
1177
1196
|
item: Item
|
1178
1197
|
item_description: Item Description
|
@@ -1245,6 +1264,9 @@ en:
|
|
1245
1264
|
metadata: Metadata
|
1246
1265
|
min: Min
|
1247
1266
|
minimal_amount: Minimal Amount
|
1267
|
+
minimum_password_length:
|
1268
|
+
one: "(%{count} character minimum)"
|
1269
|
+
other: "(%{count} characters minimum)"
|
1248
1270
|
missing_return_authorization: Missing Return Authorization for %{item_name}.
|
1249
1271
|
month: Month
|
1250
1272
|
more: More
|
@@ -1274,6 +1296,7 @@ en:
|
|
1274
1296
|
new_customer_return: New Customer Return
|
1275
1297
|
new_digital_asset: New digital asset
|
1276
1298
|
new_domain: New domain
|
1299
|
+
new_gift_card: New Gift Card
|
1277
1300
|
new_image: New Image
|
1278
1301
|
new_line_item: Add line item
|
1279
1302
|
new_market: New market
|
@@ -1517,7 +1540,7 @@ en:
|
|
1517
1540
|
password_protected: Password protected
|
1518
1541
|
paste: Paste
|
1519
1542
|
path: Path
|
1520
|
-
pay:
|
1543
|
+
pay: Pay
|
1521
1544
|
payment: Payment
|
1522
1545
|
payment_amount: Payment amount
|
1523
1546
|
payment_attempts: failed attempts
|
@@ -1534,11 +1557,11 @@ en:
|
|
1534
1557
|
payment_source: Payment source
|
1535
1558
|
payment_state: Payment State
|
1536
1559
|
payment_states:
|
1537
|
-
balance_due: Balance
|
1560
|
+
balance_due: Balance Due
|
1538
1561
|
checkout: Checkout
|
1539
1562
|
complete: Complete
|
1540
1563
|
completed: Completed
|
1541
|
-
credit_owed: Credit
|
1564
|
+
credit_owed: Credit Owed
|
1542
1565
|
failed: Failed
|
1543
1566
|
paid: Paid
|
1544
1567
|
partially_refunded: Partially Refunded
|
@@ -1563,8 +1586,6 @@ en:
|
|
1563
1586
|
please_check_back_soon: Please check back soon.
|
1564
1587
|
please_define_payment_methods: Please define some payment methods first.
|
1565
1588
|
please_enter_reasonable_quantity: Please enter a reasonable quantity.
|
1566
|
-
please_select: Please select
|
1567
|
-
please_select_all_options: Please select all options
|
1568
1589
|
policies: Policies
|
1569
1590
|
populate_get_error: Something went wrong. Please try adding the item again.
|
1570
1591
|
post_categories: Post categories
|
@@ -1737,6 +1758,7 @@ en:
|
|
1737
1758
|
remember_me: Remember me
|
1738
1759
|
remove: Remove
|
1739
1760
|
remove_condition: Remove condition
|
1761
|
+
remove_gift_card_on_completed_order_error: You can't remove the gift card after the order was placed
|
1740
1762
|
remove_image: Remove Image
|
1741
1763
|
rename: Rename
|
1742
1764
|
report: Report
|
@@ -1897,6 +1919,7 @@ en:
|
|
1897
1919
|
including_tax: "%{price} (incl. %{tax_amount} %{tax_rate_name})"
|
1898
1920
|
shipping_total: Shipping total
|
1899
1921
|
shipping_zone: Shipping Zone
|
1922
|
+
shipping_zone_help: Zone will limit to which Countries or States products are shipped.
|
1900
1923
|
shop_all: Shop All
|
1901
1924
|
shop_by_taxonomy: Shop by %{taxonomy}
|
1902
1925
|
shopping_cart: Shopping Cart
|
@@ -1915,6 +1938,7 @@ en:
|
|
1915
1938
|
show_store_selector:
|
1916
1939
|
long: Display the Store selector in the main nav bar of Storefront and allow users to change Store and Currency
|
1917
1940
|
short: Show Store selector
|
1941
|
+
sign_in_with_provider: Sign in with %{provider}
|
1918
1942
|
sign_out: Sign out
|
1919
1943
|
sign_up: Sign Up
|
1920
1944
|
site_name: Site name
|
@@ -1935,6 +1959,7 @@ en:
|
|
1935
1959
|
ssl:
|
1936
1960
|
change_protocol: Please switch to using HTTP (rather than HTTPS) and retry this request.
|
1937
1961
|
standards_and_formats: Standards and formats
|
1962
|
+
standards_and_formats_help: Set the timezone, default unit system and weight unit for your store.
|
1938
1963
|
start: Start
|
1939
1964
|
start_typing_to_search_for_products: Start typing to search for products
|
1940
1965
|
start_typing_to_search_for_variants: Start typing to search for variants
|
@@ -2002,11 +2027,11 @@ en:
|
|
2002
2027
|
additional_payment_needed: Select another payment method for the remaining <strong>%{amount}</strong>.
|
2003
2028
|
allocated: Added
|
2004
2029
|
applicable_amount: "<strong>%{amount}</strong> in store credit will be applied to this order."
|
2005
|
-
apply: Apply
|
2006
2030
|
authorized: Authorized
|
2007
2031
|
available_amount: You have <strong>%{amount}</strong> in Store Credit available!
|
2008
2032
|
captured: Used
|
2009
2033
|
credit: Credit
|
2034
|
+
eligible: Eligible
|
2010
2035
|
errors:
|
2011
2036
|
cannot_change_used_store_credit: You cannot change a store credit that has already been used
|
2012
2037
|
unable_to_create: Unable to create store credit
|
@@ -2017,6 +2042,7 @@ en:
|
|
2017
2042
|
remaining_amount: You have <strong>%{amount}</strong> remaining in your account's Store Credit.
|
2018
2043
|
remove: Remove
|
2019
2044
|
store_credit_categories: Store Credit Categories
|
2045
|
+
store_credit_events: Store Credit Events
|
2020
2046
|
store_credit_name: Store Credit
|
2021
2047
|
store_credit_payment_method:
|
2022
2048
|
currency_mismatch: Store credit currency does not match order currency
|
@@ -2047,6 +2073,7 @@ en:
|
|
2047
2073
|
seo_robots: Please check <a href='https://developers.google.com/search/reference/robots_meta_tag' target='_blank'>this page for more help</a>
|
2048
2074
|
social_help: If you want to link to your social accounts in the footer part of your website please fill below fields
|
2049
2075
|
store_name: Store name
|
2076
|
+
store_name_help: This is the name of your store. It will be displayed in the header and in the footer.
|
2050
2077
|
store_not_set_as_default: Couldn't set store %{store} as a default store
|
2051
2078
|
store_set_as_default: Store %{store} is now a default store
|
2052
2079
|
store_set_default_button: Set as default
|
@@ -2135,6 +2162,7 @@ en:
|
|
2135
2162
|
timezone: Timezone
|
2136
2163
|
title: Title
|
2137
2164
|
title_link: Title link
|
2165
|
+
to: To
|
2138
2166
|
to_add_variants_you_must_first_define: To add variants, you must first define
|
2139
2167
|
toggle_menu: Toggle menu
|
2140
2168
|
top_suggestions: Top suggestions
|
@@ -2168,6 +2196,7 @@ en:
|
|
2168
2196
|
under_price: Under %{price}
|
2169
2197
|
unit: Unit
|
2170
2198
|
unit_system: Unit system
|
2199
|
+
unit_system_help: This will be used as the default unit system for your store. You can override this on a per-product basis.
|
2171
2200
|
unit_systems:
|
2172
2201
|
imperial_system: Imperial system
|
2173
2202
|
metric: metric
|
@@ -2229,6 +2258,7 @@ en:
|
|
2229
2258
|
webhooks: Webhooks
|
2230
2259
|
weight: Weight
|
2231
2260
|
weight_unit: Weight unit
|
2261
|
+
weight_unit_help: This will be used as the default weight unit for your store. You can override this on a per-product basis.
|
2232
2262
|
weight_units:
|
2233
2263
|
gram: Gram (g)
|
2234
2264
|
kilogram: Kilogram (kg)
|
data/config/routes.rb
CHANGED
@@ -5,6 +5,7 @@ Rails.application.routes.draw do
|
|
5
5
|
opts = options.slice(:protocol, :host, :port)
|
6
6
|
opts[:host] = Spree.cdn_host if Spree.cdn_host.present?
|
7
7
|
opts[:host] ||= Rails.application.routes.default_url_options[:host]
|
8
|
+
opts[:host] ||= Spree::Store.current.url_or_custom_domain if Spree::Store.current.present?
|
8
9
|
|
9
10
|
opts[:only_path] = true if opts[:host].blank?
|
10
11
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class CreateSpreeGiftCardsAndSpreeGiftCardBatches < ActiveRecord::Migration[7.2]
|
2
|
+
def change
|
3
|
+
create_table :spree_gift_card_batches, if_not_exists: true do |t|
|
4
|
+
t.references :store, null: false, index: true
|
5
|
+
t.references :created_by
|
6
|
+
t.integer :codes_count, default: 1, null: false
|
7
|
+
t.decimal :amount, precision: 10, scale: 2, null: false
|
8
|
+
t.string :currency, null: false
|
9
|
+
t.string :prefix
|
10
|
+
t.date :expires_at
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :spree_gift_cards, if_not_exists: true do |t|
|
16
|
+
t.references :store, null: false, index: true
|
17
|
+
t.references :user, index: true
|
18
|
+
t.references :gift_card_batch, index: true
|
19
|
+
t.references :created_by, index: true
|
20
|
+
t.string :code, null: false
|
21
|
+
t.string :state, null: false, index: true
|
22
|
+
t.decimal :amount, precision: 10, scale: 2, null: false
|
23
|
+
t.decimal :amount_authorized, precision: 10, scale: 2, null: false, default: 0
|
24
|
+
t.decimal :amount_used, precision: 10, scale: 2, null: false, default: 0
|
25
|
+
t.string :currency, null: false
|
26
|
+
|
27
|
+
t.date :expires_at, index: true
|
28
|
+
t.datetime :redeemed_at, index: true
|
29
|
+
t.timestamps
|
30
|
+
end
|
31
|
+
|
32
|
+
add_index :spree_gift_cards, :code, unique: { scope: :store_id }
|
33
|
+
|
34
|
+
add_column :spree_orders, :gift_card_id, :bigint, if_not_exists: true
|
35
|
+
add_index :spree_orders, :gift_card_id, if_not_exists: true
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class EnablePgTrgmExtension < ActiveRecord::Migration[7.2]
|
2
|
+
def up
|
3
|
+
if supports_extensions? && extension_available?('pg_trgm') && !extension_enabled?('pg_trgm')
|
4
|
+
enable_extension 'pg_trgm'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def down
|
9
|
+
if supports_extensions? && extension_available?('pg_trgm') && extension_enabled?('pg_trgm')
|
10
|
+
disable_extension 'pg_trgm'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# this fields were not present when someone used a custom user class
|
2
|
+
# so we need to ensure this is setup properly
|
3
|
+
class AddMissingFieldsToUsers < ActiveRecord::Migration[7.2]
|
4
|
+
def change
|
5
|
+
users_table = Spree.user_class.table_name
|
6
|
+
add_column users_table, :login, :string, if_not_exists: true
|
7
|
+
|
8
|
+
json_type = if respond_to?(:jsonb)
|
9
|
+
:jsonb
|
10
|
+
else
|
11
|
+
:json
|
12
|
+
end
|
13
|
+
|
14
|
+
add_column users_table, :public_metadata, json_type, if_not_exists: true
|
15
|
+
add_column users_table, :private_metadata, json_type, if_not_exists: true
|
16
|
+
|
17
|
+
add_reference users_table, :bill_address, if_not_exists: true
|
18
|
+
add_reference users_table, :ship_address, if_not_exists: true
|
19
|
+
|
20
|
+
admin_users_table = Spree.admin_user_class.table_name
|
21
|
+
add_column admin_users_table, :login, :string, if_not_exists: true
|
22
|
+
add_column admin_users_table, :public_metadata, json_type, if_not_exists: true
|
23
|
+
add_column admin_users_table, :private_metadata, json_type, if_not_exists: true
|
24
|
+
end
|
25
|
+
end
|
@@ -12,7 +12,6 @@ module Spree
|
|
12
12
|
class_option :sample, type: :boolean, default: false, banner: 'load sample data (migrations must be run)'
|
13
13
|
class_option :install_storefront, type: :boolean, default: false, banner: 'installs default rails storefront'
|
14
14
|
class_option :install_admin, type: :boolean, default: false, banner: 'installs default rails admin'
|
15
|
-
class_option :copy_storefront, type: :boolean, default: false, banner: 'copy all storefront views and stylesheets'
|
16
15
|
class_option :auto_accept, type: :boolean
|
17
16
|
class_option :user_class, type: :string
|
18
17
|
class_option :admin_email, type: :string
|
@@ -35,7 +34,6 @@ module Spree
|
|
35
34
|
@load_sample_data = options[:sample]
|
36
35
|
@install_storefront = options[:install_storefront]
|
37
36
|
@install_admin = options[:install_admin]
|
38
|
-
@copy_storefront = options[:copy_storefront]
|
39
37
|
@authentication = options[:authentication]
|
40
38
|
|
41
39
|
unless @run_migrations
|
@@ -92,12 +90,6 @@ module Spree
|
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
95
|
-
def copy_storefront
|
96
|
-
if @copy_storefront && Spree::Core::Engine.frontend_available?
|
97
|
-
generate 'spree:storefront:copy_storefront'
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
93
|
def configure_application
|
102
94
|
application <<-APP.strip_heredoc.indent!(4)
|
103
95
|
|
@@ -74,6 +74,10 @@ module Spree
|
|
74
74
|
preference :coupon_codes_web_limit, :integer, default: 500 # number of coupon codes to be generated in the web process, more than this will be generated in a background job
|
75
75
|
preference :coupon_codes_total_limit, :integer, default: 5000 # the maximum number of coupon codes to be generated
|
76
76
|
|
77
|
+
# gift cards
|
78
|
+
preference :gift_card_batch_web_limit, :integer, default: 500 # number of gift card codes to be generated in the web process, more than this will be generated in a background job
|
79
|
+
preference :gift_card_batch_limit, :integer, default: 50_000
|
80
|
+
|
77
81
|
attr_writer :searcher_class
|
78
82
|
end
|
79
83
|
end
|
@@ -9,6 +9,8 @@ module Spree
|
|
9
9
|
helper_method :current_store
|
10
10
|
helper_method :current_price_options
|
11
11
|
end
|
12
|
+
|
13
|
+
prepend_before_action :raise_record_not_found_if_store_is_not_found
|
12
14
|
end
|
13
15
|
|
14
16
|
def current_store
|
@@ -16,7 +18,7 @@ module Spree
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def store_locale
|
19
|
-
current_store.default_locale
|
21
|
+
@store_locale ||= current_store.default_locale
|
20
22
|
end
|
21
23
|
|
22
24
|
def ensure_current_store(object)
|
@@ -64,6 +66,16 @@ module Spree
|
|
64
66
|
def current_store_finder
|
65
67
|
Spree::Dependencies.current_store_finder.constantize
|
66
68
|
end
|
69
|
+
|
70
|
+
def raise_record_not_found_if_store_is_not_found
|
71
|
+
return if skip_store_lookup?
|
72
|
+
|
73
|
+
raise ActiveRecord::RecordNotFound if current_store.nil?
|
74
|
+
end
|
75
|
+
|
76
|
+
def skip_store_lookup?
|
77
|
+
Spree.root_domain.present? && Spree.root_domain.include?(request.env['SERVER_NAME'])
|
78
|
+
end
|
67
79
|
end
|
68
80
|
end
|
69
81
|
end
|
@@ -33,6 +33,11 @@ module Spree
|
|
33
33
|
checkout_get_shipping_rates_service: 'Spree::Checkout::GetShippingRates',
|
34
34
|
checkout_select_shipping_method_service: 'Spree::Checkout::SelectShippingMethod',
|
35
35
|
|
36
|
+
# gift cards
|
37
|
+
gift_card_apply_service: 'Spree::GiftCards::Apply',
|
38
|
+
gift_card_remove_service: 'Spree::GiftCards::Remove',
|
39
|
+
gift_card_redeem_service: 'Spree::GiftCards::Redeem',
|
40
|
+
|
36
41
|
# order
|
37
42
|
order_approve_service: 'Spree::Orders::Approve',
|
38
43
|
order_cancel_service: 'Spree::Orders::Cancel',
|
data/lib/spree/core/engine.rb
CHANGED
@@ -5,6 +5,7 @@ module Spree
|
|
5
5
|
module Core
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
Environment = Struct.new(:calculators,
|
8
|
+
:validators,
|
8
9
|
:preferences,
|
9
10
|
:dependencies,
|
10
11
|
:payment_methods,
|
@@ -27,6 +28,7 @@ module Spree
|
|
27
28
|
:integrations)
|
28
29
|
SpreeCalculators = Struct.new(:shipping_methods, :tax_rates, :promotion_actions_create_adjustments, :promotion_actions_create_item_adjustments)
|
29
30
|
PromoEnvironment = Struct.new(:rules, :actions)
|
31
|
+
SpreeValidators = Struct.new(:addresses)
|
30
32
|
isolate_namespace Spree
|
31
33
|
engine_name 'spree'
|
32
34
|
|
@@ -35,7 +37,7 @@ module Spree
|
|
35
37
|
end
|
36
38
|
|
37
39
|
initializer 'spree.environment', before: :load_config_initializers do |app|
|
38
|
-
app.config.spree = Environment.new(SpreeCalculators.new, Spree::Core::Configuration.new, Spree::Core::Dependencies.new)
|
40
|
+
app.config.spree = Environment.new(SpreeCalculators.new, SpreeValidators.new, Spree::Core::Configuration.new, Spree::Core::Dependencies.new)
|
39
41
|
|
40
42
|
app.config.active_record.yaml_column_permitted_classes ||= []
|
41
43
|
app.config.active_record.yaml_column_permitted_classes.concat([Symbol, BigDecimal, ActiveSupport::HashWithIndifferentAccess])
|
@@ -272,6 +274,10 @@ module Spree
|
|
272
274
|
Rails.application.config.spree.analytics_event_handlers = []
|
273
275
|
|
274
276
|
Rails.application.config.spree.integrations = []
|
277
|
+
|
278
|
+
Rails.application.config.spree.validators.addresses = [
|
279
|
+
Spree::Addresses::PhoneValidator
|
280
|
+
]
|
275
281
|
end
|
276
282
|
|
277
283
|
initializer 'spree.promo.register.promotions.actions' do |app|
|
data/lib/spree/core/version.rb
CHANGED
data/lib/spree/core.rb
CHANGED
@@ -12,6 +12,8 @@ module Spree
|
|
12
12
|
:digital_attributes,
|
13
13
|
:digital_link_attributes,
|
14
14
|
:export_attributes,
|
15
|
+
:gift_card_attributes,
|
16
|
+
:gift_card_batch_attributes,
|
15
17
|
:image_attributes,
|
16
18
|
:integration_attributes,
|
17
19
|
:inventory_unit_attributes,
|
@@ -105,6 +107,10 @@ module Spree
|
|
105
107
|
|
106
108
|
@@export_attributes = [:type, :format, :record_selection, :search_params]
|
107
109
|
|
110
|
+
@@gift_card_attributes = [:code, :amount, :expires_at, :user_id]
|
111
|
+
|
112
|
+
@@gift_card_batch_attributes = [:prefix, :codes_count, :amount, :expires_at]
|
113
|
+
|
108
114
|
@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]
|
109
115
|
|
110
116
|
@@integration_attributes = [:type, :active]
|
@@ -127,7 +133,7 @@ module Spree
|
|
127
133
|
|
128
134
|
@@page_attributes = [:name, :slug, :meta_title, :meta_description, :meta_keywords]
|
129
135
|
|
130
|
-
@@page_block_attributes = [:type, :name, :text, :position]
|
136
|
+
@@page_block_attributes = [:type, :name, :text, :position, :asset]
|
131
137
|
|
132
138
|
@@page_link_attributes = [:linkable_id, :linkable_type, :position, :label, :url, :open_in_new_tab]
|
133
139
|
|
@@ -145,7 +151,7 @@ module Spree
|
|
145
151
|
|
146
152
|
@@product_attributes = [
|
147
153
|
:name, :description, :available_on, :make_active_at, :discontinue_on, :permalink, :meta_description,
|
148
|
-
:meta_keywords, :price, :sku, :deleted_at, :prototype_id,
|
154
|
+
:meta_keywords, :meta_title, :price, :sku, :deleted_at, :prototype_id,
|
149
155
|
:option_values_hash, :weight, :height, :width, :depth,
|
150
156
|
:shipping_category_id, :tax_category_id,
|
151
157
|
:cost_currency, :cost_price, :compare_at_price,
|
@@ -164,7 +170,7 @@ module Spree
|
|
164
170
|
@@promotion_attributes = [:name, :description, :starts_at, :expires_at, :code, :usage_limit, :path, :match_policy,
|
165
171
|
:advertise, :promotion_category_id, :code_prefix, :kind, :number_of_codes, :multi_codes, store_ids: []]
|
166
172
|
|
167
|
-
@@promotion_rule_attributes = [:type, :preferred_match_policy, user_ids_to_add: [], product_ids_to_add: [], taxon_ids_to_add: []]
|
173
|
+
@@promotion_rule_attributes = [:type, :preferred_match_policy, preferred_eligible_values: [], user_ids_to_add: [], product_ids_to_add: [], taxon_ids_to_add: []]
|
168
174
|
|
169
175
|
@@promotion_action_attributes = [:type, :calculator_type, calculator_attributes: {}, promotion_action_line_items_attributes: [:id, :promotion_action_id, :variant_id, :quantity, :_destroy]]
|
170
176
|
|
@@ -180,11 +186,18 @@ module Spree
|
|
180
186
|
|
181
187
|
@@report_attributes = [:type, :date_from, :date_to, :currency]
|
182
188
|
|
183
|
-
@@return_authorization_attributes = [
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
189
|
+
@@return_authorization_attributes = [
|
190
|
+
:amount, :memo, :stock_location_id, :inventory_units_attributes,
|
191
|
+
:return_authorization_reason_id, {
|
192
|
+
return_items_attributes: [
|
193
|
+
:_destroy,
|
194
|
+
:id, :inventory_unit_id,
|
195
|
+
:preferred_reimbursement_type_id,
|
196
|
+
:return_authorization_id, :returned, :pre_tax_amount,
|
197
|
+
:acceptance_status, :exchange_variant_id, :resellable
|
198
|
+
]
|
199
|
+
}
|
200
|
+
]
|
188
201
|
|
189
202
|
@@return_authorization_reason_attributes = [:name, :active]
|
190
203
|
|
@@ -199,7 +212,7 @@ module Spree
|
|
199
212
|
|
200
213
|
@@shipping_category_attributes = [:name]
|
201
214
|
|
202
|
-
@@shipping_method_attributes = [:name, :code
|
215
|
+
@@shipping_method_attributes = [:name, :admin_name, :code, :tracking_url, :tax_category_id, :display_on,
|
203
216
|
:estimated_transit_business_days_min, :estimated_transit_business_days_max,
|
204
217
|
:calculator_type, :preferences, zone_ids: [], shipping_category_ids: [], calculator_attributes: {}]
|
205
218
|
|
@@ -15,15 +15,11 @@ module Spree
|
|
15
15
|
include CustomAbility
|
16
16
|
|
17
17
|
def stub_authorization!(&block)
|
18
|
-
|
19
|
-
|
20
|
-
let(:user) { Spree.admin_user_class.new(email: FFaker::Internet.email) }
|
18
|
+
let(:admin_user) { FactoryBot.create(:admin_user) }
|
21
19
|
|
22
20
|
before do
|
23
|
-
allow(controller).to receive(:current_ability).and_return(ability_class.new(nil))
|
24
|
-
|
25
21
|
if defined?(Spree::Admin::BaseController)
|
26
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(
|
22
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(admin_user)
|
27
23
|
end
|
28
24
|
end
|
29
25
|
end
|
@@ -44,12 +40,11 @@ module Spree
|
|
44
40
|
ability_class.register_ability(ability)
|
45
41
|
end
|
46
42
|
|
47
|
-
let(:
|
43
|
+
let(:admin_user) { FactoryBot.create(:admin_user) }
|
48
44
|
|
49
45
|
before do
|
50
|
-
allow(Spree.admin_user_class).to receive(:find_by).and_return(user)
|
51
46
|
if defined?(Spree::Admin::BaseController)
|
52
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(
|
47
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(admin_user)
|
53
48
|
end
|
54
49
|
end
|
55
50
|
end
|
@@ -73,4 +68,5 @@ end
|
|
73
68
|
RSpec.configure do |config|
|
74
69
|
config.extend Spree::TestingSupport::AuthorizationHelpers::Controller, type: :controller
|
75
70
|
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :feature
|
71
|
+
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :request
|
76
72
|
end
|
@@ -33,13 +33,19 @@ namespace :common do
|
|
33
33
|
system('bin/rails stimulus:install')
|
34
34
|
end
|
35
35
|
|
36
|
+
# install devise if it's not the legacy user, useful for testing storefront
|
37
|
+
if args[:authentication] == 'devise' && args[:user_class] != 'Spree::LegacyUser'
|
38
|
+
system('bin/rails g devise:install --force --auto-accept')
|
39
|
+
system("bin/rails g devise #{args[:user_class]} --force --auto-accept")
|
40
|
+
system('rm -rf spec') # we need to cleanup factories created by devise to avoid naming conflict
|
41
|
+
end
|
42
|
+
|
36
43
|
Spree::InstallGenerator.start [
|
37
44
|
"--lib_name=#{ENV['LIB_NAME']}",
|
38
45
|
'--auto-accept',
|
39
46
|
'--migrate=false',
|
40
47
|
'--seed=false',
|
41
48
|
'--sample=false',
|
42
|
-
'--copy_storefront=false',
|
43
49
|
"--install_storefront=#{args[:install_storefront]}",
|
44
50
|
"--install_admin=#{args[:install_admin]}",
|
45
51
|
"--user_class=#{args[:user_class]}",
|
@@ -0,0 +1,17 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :gift_card, class: Spree::GiftCard do
|
3
|
+
state { :active }
|
4
|
+
amount { 10.00 }
|
5
|
+
store { Spree::Store.default || create(:store) }
|
6
|
+
|
7
|
+
trait :redeemed do
|
8
|
+
state { :redeemed }
|
9
|
+
redeemed_at { Time.current }
|
10
|
+
amount_used { amount }
|
11
|
+
end
|
12
|
+
|
13
|
+
trait :expired do
|
14
|
+
expires_at { 1.day.ago }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|